electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Developers' Corner
Can PIC microcontroller = TOS?
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [14 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Unkie Al



Joined: Nov 02, 2007
Posts: 24
Location: Washington DC

PostPosted: Sun Dec 02, 2007 9:14 pm    Post subject: Can PIC microcontroller = TOS?
Subject description: Old top-octave chips are gone. Can a PIC do the job today?
Reply with quote  Mark this post and the followings unread

The old Top Octave Synthesizer chips from 70s-80s vintage poly synths are pretty much a relic now, with remaining new-old stock approaching $40-50 per chip. Mad

I have only a rudimentary knowledge of PIC microcontrollers, but it seems to me that one can be programmed to perform the functions necessary to generate a complete chromatic octave from a single frequency input (with division such as x/239, x/301 etc, where x=clock frequency). Follow that up with a pile of flipflops for further octave division, and its like having a PAIA Organtua dropped into your lap.

Has anyone explored the potential of using a PIC for this purpose? I have done numerous searches on the web but have come up with nothing. It's tempting, especially because the stability would be rock-solid, and a PIC would be $10 or less, compared to the cost of the afore-mentioned 25-year old TOS chip.

If you or someone you know is doing something along these lines, I'd be grateful to know more. thumright

U.A.
Back to top
View user's profile Send private message
yusynth



Joined: Nov 24, 2005
Posts: 1233
Location: France

PostPosted: Mon Dec 03, 2007 6:20 am    Post subject: Reply with quote  Mark this post and the followings unread

Oldcrow who is known for some of his reverse engineering of synth modules had a very old project (1997) with a PIC16C54 to emulate a top octave generator.

You can still find it here :http://chip.aeug.org/oct54all.asm and some other PIC projects for music :

http://chip.aeug.org/other.html

_________________
Yves

Last edited by yusynth on Wed Dec 05, 2007 7:52 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Unkie Al



Joined: Nov 02, 2007
Posts: 24
Location: Washington DC

PostPosted: Wed Dec 05, 2007 7:45 am    Post subject: Reply with quote  Mark this post and the followings unread

I am in receipt of an email from Jarek Ziembicki - the developer of the AVRSYNTH described well on Laurie Biddolph's pages - and he suggests the use of an FPGA (field-programmable gate array) to design an alternative to a top-octave generator.

I am not an E.E., so until this morning had never heard of an FPGA. But I looked up a PDF of the Atmel line of FPGAs, and damn Shocked , the thing has some promise.

There goes at least a month of winter weekends shot trying to figure this thing out Laughing

AP
Back to top
View user's profile Send private message
DrJustice



Joined: Sep 13, 2004
Posts: 2052
Location: Morokulien
Audio files: 3

PostPosted: Wed Dec 05, 2007 1:32 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Al!

welcome to electro-music.com!

FPGA's are indeed awesome. Here's a couple of forum threads on the subject: one here, and another here.

Another device type that may be suited for this is a CPLD (Complex Programmable Logic device), which is effectively a smaller cousin of the FPGA. The main differentiating features are that CPLD's have a built in non volatile memory for the configuration data, they're usually very power efficient and they haven't got as many gates as FPGA's. We are starting to see the first FPGA's with built configuration memory now, and some are quite power efficient too, thus the boundary between CPLD and FPGA may be getting less clear in the future.

Other than that, I reckon a PIC or an SX or similar high speed microcontroller will do fine as a TOS.

DJ
--
Back to top
View user's profile Send private message Visit poster's website
yerpa58



Joined: Mar 08, 2008
Posts: 56
Location: Wisconsin
Audio files: 4

PostPosted: Sat Mar 08, 2008 6:56 pm    Post subject: Example od PIC as octave synthesizer Reply with quote  Mark this post and the followings unread

have you checked:

http://chip.aeug.org/oct54all.asm

also good stuff on:

http://chip.aeug.org/other.html
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20680
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Sat Mar 08, 2008 8:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

welcome yerpa58

looks like good links.

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
yusynth



Joined: Nov 24, 2005
Posts: 1233
Location: France

PostPosted: Sun Mar 09, 2008 1:33 am    Post subject: Reply with quote  Mark this post and the followings unread

Blue Hell wrote:
welcome yerpa58

looks like good links.

Yes they are, since the same links were already given three posts before Wink

_________________
Yves
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20680
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Sun Mar 09, 2008 10:54 am    Post subject: Reply with quote  Mark this post and the followings unread

Oops, sorry, those earlier ones look good as well Laughing
_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
yerpa58



Joined: Mar 08, 2008
Posts: 56
Location: Wisconsin
Audio files: 4

PostPosted: Sun Mar 09, 2008 11:55 am    Post subject: Reply with quote  Mark this post and the followings unread

oops my bad. Has anybody tried the PIC version? I once took four of the old Mostek chips and wired them directly thru a 37-key keyboard. No other electronics, pressing a key just ran the sqare wave right from the TOS chip to a wire bus that went to an output jack for connection to an amplifier. A 555 timer clocked the TOS chips, and had a potentiometer for overall "tuning". Later on, I might have added a transformer to couple the over-hot output to an amp. Anyway, it sounded like a hurdy-gurdy, no envelope, no velocity info. The coolest sound I ever got out of it was pressing down all 37 keys at once and then thru a wah-wah pedal while turning the pot on the 555. It made a sound I describe as "chrome (chromatic) wind". Now that you have brought back the memories, I'm thinking of doing it again with the PIC.
Back to top
View user's profile Send private message Visit poster's website
Sam_Zen



Joined: Mar 08, 2008
Posts: 251
Location: NL

PostPosted: Mon Apr 28, 2008 7:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

I remember having a toy keyboard, which I opened of course, finding a one-bit PIC-processor.
It could indeed produce 'harmonic' notes.

_________________
0.618033988
Back to top
View user's profile Send private message Visit poster's website
Tony Deff



Joined: May 25, 2008
Posts: 42
Location: Suffolk, UK

PostPosted: Wed May 28, 2008 2:39 pm    Post subject: The PIC as a musical note generator
Subject description: Is the PIC TOS "tosh"?
Reply with quote  Mark this post and the followings unread

The PIC series has had a lot of promotional spin, such that if you announced you'd built an entire electronic organ into a PIC and just needed interfacing to a keyboard, stops and speakers, someone, somewhere, would believe it. Embarassed

As I understand the problem, the timers in most of the PICs are pretty basic, designed for a simple 8-bit time-out. This means that there is a "latency" or timing over-head whereby time must be spent polling the timer to see if it has finished, else time must be spent reacting to an interrupt, toggling an output pin and resetting the timer. They say to you "By the way, did you know your timer has over-flowed?" Presumably, that's why they're not used in missions to Mars, where a little more precision is required.

Some micro-controllers (DS89C420, AT89S8252) have 16-bit auto-reload and a direct output which allows you to set-up the generation of a square-wave, then to go away and do something else.

With a PIC, timing over-heads must be carefully calculated and compensated for, else you will have pretty poor precision at the higher frequencies. Talking of frequencies, the timers have to be synchronised by effectively dividing the clock speed by 4, so you may think you're running at an impressive 16MHz.

To emulate the achievement of those old-fashioned TOG (TOS) chips, running at 4.25 MHz, you would need a clock-rate 8 times this, because you have to toggle the output twice to get a whole output cycle.

The programs that claim to generate the top-octave are open enough about it not actually being the octave required to get the 8th & 16th harmonics of the top keyboard octave, but it may not be obvious that the outputs will have poor accuracy and frequency jitter. The world works like this:

Suppose that we are trying to derive outputs that toggle every 508, 538, 570, 604, 640 (etc. etc.) clock cycles. We could theoretically toggle an output bit on the count of 508, then another output bit 30 counts later, then yet another output bit 32 counts later etc. etc.

Life is not that simple. You cannot do that next time around or you'll simply get 12 phase-shifted outputs. Sooner or later, we will be required to toggle two or more outputs within one or two clock cycles, or perhaps simultaneously. The first co-incidence will be after 508×538 clocks, then you get all sorts of pseudo-random permutations; 508×570, 538×570, 570×640×761

The PIC program that attempts this impossibility merely responds to a time-out as best it can and determines that several more pins are overdue for toggling. Pulse-width jitter.

The PIC16F877 has one 16-bit timer/counter and two PWM (pulse-width modulation) modules.
This offers some interesting possibilities, in that by controlling pulse-width we get some even harmonics and thus may not need as high a frequency as with square-waves.

Application Notes AN539 & AN564 may be downloaded for data on setting-up & using PWM.
Application Note AN654 implements PWM by software.
Application Note AN543 has data on Tone Generation.

The PIC16C781/782 also has a PWM mode, plus an 8-bit DAC, offering the interesting possibilities of generating custom waveforms (but don't get your hopes up too high).

___________________

Another possibility is to use the PIC's consistent instruction-timing to implement a software frequency generator. If you have a 16MHz. clock, and implement a 955-instruction delay (which ends by toggling an output pin) then you will have a top-C (8372Hz) within an absolute pitch of 1-cent (± crystal error).

The equal-temperament scale to within 1-cent relative is obtained by instruction count loops of:

C 955
B 1012 (Ich glaube das ist H in Deutsch, si en Francais/Espanol/Italiano, h im Svenska/Norsk/Dansk)
Bb 1072 (Deutsch =B, Francais =si bémol, Svenska =b, Nederlands =bes)
A 1136
Ab 1203
G 1275
F# 1351
F 1431
E 1516
Eb 1606
D 1702
C# 1803

For a "programmable note-generator", this data can be put into a table and the note selected by the state of input pins. Admittedly, this is only one note (I thought about how to generate several notes, but it gave me a severe headache).

What about 12 identical PICs, and a cascading method that showed the PIC its place in the chain, so that the input code transposed the entire instrument?

___________________

Yet another possibility is to use the PICs for what they were intended: controllers! Idea
(What a revolutionary idea! Wonder if anyone else has though of that?)
The 8253 chip has 3×16-bit counters (plus control register) that can be programmed as square-wave generators. Four of these plus a PIC would enable a dynamically-progammable top-octave (where you could change not just the key, but the entire tuning system!)

You might just assign two or three 8253 chips to 6 or 9 active voices, if that's enough polyphony for you. In the UK, Bardwell is selling-off these chips "for a song"!
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20680
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Wed May 28, 2008 5:18 pm    Post subject: Re: The PIC as a musical note generator
Subject description: Is the PIC TOS "tosh"?
Reply with quote  Mark this post and the followings unread

Tone-Deaf wrote:
Another possibility is to use the PIC's consistent instruction-timing to implement a software frequency generator. If you have a 16MHz. clock, and implement a 955-instruction delay (which ends by toggling an output pin) then you will have a top-C (8372Hz) within an absolute pitch of 1-cent (± crystal error).

The equal-temperament scale to within 1-cent relative is obtained by instruction count loops of:

C 955
B 1012 (Ich glaube das ist H in Deutsch, si en Francais/Espanol/Italiano, h im Svenska/Norsk/Dansk)
Bb 1072 (Deutsch =B, Francais =si bémol, Svenska =b, Nederlands =bes)
A 1136
Ab 1203
G 1275
F# 1351
F 1431
E 1516
Eb 1606
D 1702
C# 1803


When I work that out for a 40 MHz PIC18 doing 12 notes I end up with a top octave running from 43 .. 82 Hz Laughing

Code:

tos_loop

                                                ; // ------------------

  decfsz  <@" note_counter_1_l">                ; //  1   2   2
  bra     n1_1                                  ; //  2


  decfsz  <@" note_counter_1_h">                ; //      1   2
  bra     n1_2                                  ; //      2

  btg     <@" tos"> + 0, 0                      ; //          1

  movlw   <@" note_divisor_1"> >> 0 & 0xff      ; //          1
  movwf   <@" note_counter_1"> + 0              ; //          1
  movlf   <@" note_divisor_1"> >> 8 & 0xff      ; //          1
  movwf   <@" note_counter_1"> + 1              ; //          1
  bra     n1_3                                  ; //          2
                                                ; // ------------------
                                                ; //  3   5  11


n1_1

  nop                                           ; // 3 + 2 = 5
  nop

n1_2

  nop                                           ; // 5 + 6 = 11
  nop
  nop
  nop
  nop
  nop

                                                ; // 11
n1_3


  ; // etc ... 11 * 11 = 121 cycles


  movff   <@" tos"> + 0, portc          ; // 2
  movff   <@" tos"> + 1, portd          ; // 2

  bra     tos_loop                      ; // 2

  ; // total of 127 instruction cycles for 12 notes.
  ; //
  ; // At 40 MHz the instruction speed is 10 Mips
  ; // 10 Mips / 127 -> 78 kHz
  ; // lowest  note has 1803 rounds leaving us at : 43 Hz
  ; // highest note has  955 rounds leaving us at : 82 Hz


_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Tony Deff



Joined: May 25, 2008
Posts: 42
Location: Suffolk, UK

PostPosted: Sun Jun 01, 2008 12:37 pm    Post subject: PIC programming impossibilty
Subject description: Challenge to programmers
Reply with quote  Mark this post and the followings unread

Quote:
When I work that out for a 40 MHz PIC18 doing 12 notes I end up with a top octave running from 43 .. 82 Hz

Embarassed
Oops, sorry; what they call a "senior moment"— I forgot about the four clock-phases per instruction. We'd have to use 32MHz. and generate a pseudo-square wave in order to meet the required top frequency.

477 + 478 ; 8,000,000/ 955 = 8376.96Hz
506 + 506 ; 8,000,000/1012 = 7905.14Hz
536 + 536 ; 8,000,000/1072 = 7462.69Hz
568 + 568 ; 8,000,000/1136 = 7042.25Hz (/16 = 440.14Hz)
601 + 602 ; 8,000,000/1203 = 6650.04Hz
637 + 638 ; 8,000,000/1275 = 6274.51Hz

[Out of interest, the common divisor set 239, 253, ... 451] which operates from 2MHz. is a quarter-scale approximation of this one. That has an accuracy of 2.34 cents, this one is under 1 cent].

My rambling appears to have confused you. I was only saying that the above frequencies could be generated SINGLY, but they could be made selectable by means of digital inputs.

You have applied clever programming to a specification I never intended, resulting in a confusing program that has me (and anyone else?) baffled.
What does it do? It might be generating phase-shifted outputs of the same low frequency!

What I was trying to say is:

§ It is a wasted effort (I'd better not say "waste of time!") trying to use the PIC timer to resolve top-octave frequencies to 1-cent.

§ You can use software-timing loops to generate 1 note of the scale at a time, to within 1-cent.

§ Regardless of method, claiming that you can generate more than one note at a time, to the required precision, is like claiming that you have invented the perpetual-motion machine. It cannot be done.


Here is a gauntlet (a challenge) to PIC programmers, designed to show the scale (excuse the pun) of the problem involved ....

Program a PIC to generate just two simultaneous notes, a whole-tone apart, using the two modest divisors of 49 & 55 (which have an astonishing 0.02¢ interval accuracy). It is up to you whether to use timers or whatever.

These small numbers allow us to demonstrate the problem fairly quickly.
You need to toggle one port bit on clocks 49, 98, 147, 196, 245, 294, 343, 392, 441 ...
simultaneously toggling another bit on clocks 55, 110, 165, 220, 275, 330, 385, 440 ...

Start by setting the two bits together (the "Mark" period of both waveforms).
Your software clock is ticking from there!

You have 49 instructions to prepare to toggle the first bit, but only 6 for the second. (49+6=55)
You have 43 instructions to prepare to toggle the first bit, but have 12 for the second (98+12 =110).
You have 37 instructions to prepare to toggle the first bit, and have 18 for the second (147+18=165).

Notice that one set of time-intervals is increasing by 6, the other is decreasing by 6.
Whether you handle this by an algorithm or a look-up table is up to you.

Approaching "cross-over", the phasing gets too close to be able to respond, as you can see between clocks 440 & 441. Pseudo-random phasing will occur over 55×49 (=2695 cycles), when a simultaneous changing of both bits will again be required.

I don't know if this can be done with some very clever programming.

Afterwards, consider how you would generate 12 notes simultaneous notes, envisaging a situation where (say) you need to change 5 port bits within a (say) 12 instruction cycles?
It won't happen often, but all sorts of unfortunate combinations will occur.


On a more positive note (another pun), even if the PIC only generated a single (selectable) frequency, the mark-space ratio could also be selectable via digital inputs. The resulting different tone-colours (with even harmonics) may make the provision of high audio frequencies (for overtones) unnecessary.
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20680
Location: The Netherlands, Enschede
Audio files: 156
G2 patch files: 318

PostPosted: Sun Jun 01, 2008 1:35 pm    Post subject: Re: PIC programming impossibilty
Subject description: Challenge to programmers
Reply with quote  Mark this post and the followings unread

Tone-Deaf wrote:
You have applied clever programming to a specification I never intended, resulting in a confusing program that has me (and anyone else?) baffled.
What does it do? It might be generating phase-shifted outputs of the same low frequency!


It's just 12 individual dividers in a loop but as I was interested in the timing only I didn't spell it all out. I know it is not what you meant to build, it was just out of curiosity of how bad things would become trying to make a TOS for 12 notes with great accuracy ... it's baaad Wink

(and the obtainable frequencies are a bit lower, multiply by 11/12)

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [14 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Developers' Corner
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use