Author |
Message |
Unkie Al
Joined: Nov 02, 2007 Posts: 24 Location: Washington DC
|
Posted: 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? |
 |
|
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.
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.
U.A. |
|
Back to top
|
|
 |
yusynth

Joined: Nov 24, 2005 Posts: 1314 Location: France
|
Posted: Mon Dec 03, 2007 6:20 am Post subject:
|
 |
|
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
|
|
 |
Unkie Al
Joined: Nov 02, 2007 Posts: 24 Location: Washington DC
|
Posted: Wed Dec 05, 2007 7:45 am Post subject:
|
 |
|
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 , the thing has some promise.
There goes at least a month of winter weekends shot trying to figure this thing out
AP |
|
Back to top
|
|
 |
DrJustice

Joined: Sep 13, 2004 Posts: 2112 Location: Morokulien
Audio files: 4
|
Posted: Wed Dec 05, 2007 1:32 pm Post subject:
|
 |
|
Hi Al!
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
|
|
 |
yerpa58
Joined: Mar 08, 2008 Posts: 57 Location: Wisconsin
Audio files: 4
|
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24436 Location: The Netherlands, Enschede
Audio files: 297
G2 patch files: 320
|
Posted: Sat Mar 08, 2008 8:41 pm Post subject:
|
 |
|
yerpa58
looks like good links. _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
Back to top
|
|
 |
yusynth

Joined: Nov 24, 2005 Posts: 1314 Location: France
|
Posted: Sun Mar 09, 2008 1:33 am Post subject:
|
 |
|
Blue Hell wrote: | yerpa58
looks like good links. |
Yes they are, since the same links were already given three posts before  _________________ Yves |
|
Back to top
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24436 Location: The Netherlands, Enschede
Audio files: 297
G2 patch files: 320
|
Posted: Sun Mar 09, 2008 10:54 am Post subject:
|
 |
|
Oops, sorry, those earlier ones look good as well  _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
Back to top
|
|
 |
yerpa58
Joined: Mar 08, 2008 Posts: 57 Location: Wisconsin
Audio files: 4
|
Posted: Sun Mar 09, 2008 11:55 am Post subject:
|
 |
|
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
|
|
 |
Sam_Zen

Joined: Mar 08, 2008 Posts: 251 Location: NL
|
Posted: Mon Apr 28, 2008 7:49 pm Post subject:
|
 |
|
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
|
|
 |
Tony Deff
Joined: May 25, 2008 Posts: 51 Location: Suffolk, UK
|
Posted: Wed May 28, 2008 2:39 pm Post subject:
The PIC as a musical note generator Subject description: Is the PIC TOS "tosh"? |
 |
|
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.
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!
(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
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24436 Location: The Netherlands, Enschede
Audio files: 297
G2 patch files: 320
|
Posted: Wed May 28, 2008 5:18 pm Post subject:
Re: The PIC as a musical note generator Subject description: Is the PIC TOS "tosh"? |
 |
|
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
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
also .. could someone please turn down the thermostat a bit.
 |
|
Back to top
|
|
 |
Tony Deff
Joined: May 25, 2008 Posts: 51 Location: Suffolk, UK
|
Posted: Sun Jun 01, 2008 12:37 pm Post subject:
PIC programming impossibilty Subject description: Challenge to programmers |
 |
|
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 |
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
|
|
 |
blue hell
Site Admin

Joined: Apr 03, 2004 Posts: 24436 Location: The Netherlands, Enschede
Audio files: 297
G2 patch files: 320
|
Posted: Sun Jun 01, 2008 1:35 pm Post subject:
Re: PIC programming impossibilty Subject description: Challenge to programmers |
 |
|
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
(and the obtainable frequencies are a bit lower, multiply by 11/12) _________________ Jan
also .. could someone please turn down the thermostat a bit.
 |
|
Back to top
|
|
 |
Gordon2
Joined: Apr 13, 2017 Posts: 2 Location: Ulm, Germany
|
Posted: Thu Apr 13, 2017 8:19 am Post subject:
|
 |
|
from topic :
http://electro-music.com/forum/post-427676.html#427676
Not using a pic but this might be interesting:
It's quite easy to use a very cheap chinese altera CPLD board (eg EPM1270t144) to make a top octave generator. In fact you can get most of the lower octaves as well from one board, even all free phase if you want. The biggest difficulty is getting your head around the (free) 2GB Quartus II software for programming. I use schematic entry as opposed to Verilog or VHDL entry.
You don't even need to use optimised divider ratios as the clock frequency is so high - 48MHz - that practically any ratios are accurate enough (ie accuracy better than 1 cent). The main limitation is the number of I/P and O/P pins. Would be great if a midi decoder could be included in the design - a bit beyond me!
Gordon Nudd |
|
Back to top
|
|
 |
|