Mobi Groups
Download Free Apps & Games @ PHONEKY.com

VintageComputers - Topics
Create Your Own App Store

* VintageComputers > Topics


Subject: dsPIC based audio synthesizer
Replies: 16 Views: 2448

plzgvhug 18.02.12 - 02:55am
Hello folks, its been a while since i wrote anything so i thought i would tell you what im up to... I decided to add a synthesizer to my home made Z80 computer. I tried out several an*logue circuits as prototypes using op amps but they didnt sound that good. *

plzgvhug 18.02.12 - 03:04am
The classic designs of over 30 years ago used alot of discrete parts and chips that you cant get now and i dont have alot of board space. So ive decided to use a Digital Signal Processor or DSP to do all the work. I looked at many types of DSP and the microchip 16bit dsPIC looked like a good solution. *

plzgvhug 18.02.12 - 03:10am
I choose the dsPIC33FJ128GP802 which is available in standard dual inline package which makes it easy to prototype with and also because it has 128Kb flash ROM AND 16kb RAM. It also has a 12 bit ADC, dual 16 bit DAC'S, serial port, I2C bus, SPI bus and a host of other features. *

plzgvhug 18.02.12 - 03:18am
I wired the dsPIC up on a breadboard and connect it to my pickit3 usb programmer. Next i download and install the free version of the C30 C compiler which integrates itself into the MPLAB development inviroment. This free microchip PC based app allows me to write my software and program the dsPIC. *

plzgvhug 18.02.12 - 03:26am
There is alot of complex info i had to read to use the chip and get it running. It runs at 40Mhz and can do 40 MIPS execution speed. The first program i wrote was a simple turn an LED on and off at around 1 second intervals. *

plzgvhug 18.02.12 - 03:37am
Then i had to study the data sheet info some more as next i wrote a program to output a SAW wave using the 16 bit DAC's. The sample rate of the DAC's is upto 100K samples per second and they have 256x oversampling. Next i wrote another program to output a SINE wave but this is proving difficult. Sometimes i get a sine output but then i change a parameter in the program and it stops working. *

plzgvhug 18.02.12 - 03:47am
My SINE program looks like this... I create an array to hold a 256 samples of the sine wave values. Next i create a pointer (x) to the array. Next i create variables for amplitude and frequency and finally a constant PI. Thats 3.14159. Next i calculate the values for each sample and save them to the array so the code looks like this... *

plzgvhug 18.02.12 - 03:56am
ARRAY[X]=Amplitude * SIN(x*2*PI*FREQ/(ARRAYLENGTH)) ...... I put this inside a FOR loop like this.... For(x =0; x= ARRAYLENGTH; x++) sine function goes here *

plzgvhug 18.02.12 - 04:05am
You put the sine function in curly brackets (not shown).... Next you create another FOR loop and inside that you put ... DAC.OUTPUT = (signed int) ARRAY[x] ... Put all of the above inside a while loop so it just continously outputs the array data to the DAC... I know this isnt very clear! *

plzgvhug 18.02.12 - 04:22am
Lastly i had to write a routine to handle interrupts from the DAC. This updates the data buffer in the DAC when its ready for new sample data. I can tell you this has been a difficult learning curve and so far has taken me about 3 months. *

plzgvhug 18.02.12 - 04:29am
Once ive got my head around this more and everything works reliably as expected i want to get the dspic to handle data from its serial port in the form of MIDI NOTE data and play the sinewave at different frequencys for the notes of a keyboard... I will reply when i have progressed towards this but if you have any questions please ask, thanks *

plzgvhug 19.02.12 - 01:34am
hurray.GIF today ive got my dsPIC to reliably output sine waves and be able to change both frequency and amplitude and see the changes on my oscilloscope. Ive also learnt that if you use too big a numbers in the calculations or the result of a calculation gets too big they can cause overflow errors. Tomorrow im going to write some overflow TRAP and divide by zero TRAP interrupt routines to deal with these kinds of problems. *

plzgvhug 4.03.12 - 11:50pm
New pic uploaded showing my dsPIC hardware on a breadboard under test. See photo for additional info. *

plzgvhug 26.03.12 - 12:43am
Hello again, ive started the build of my dsPIC based synth onto the piece of veroboard that is mounted onto the top rear of the Z80 computer i made previously. I added new photos (synth part 1, synth part 2, synth part 3) to the files section. The project is not finished yet but the four dsPIC33 devices are running some simple code to generate sine waves. I have to build the final low pass filter stages to the audio outputs, add the serial communication link between the synth board and the Z80 board below and link the DAC'S and ADC'S of the dsPIC's to make the final audio signal paths. *

plzgvhug 12.04.12 - 12:14am
Over the past couple of weeks ive been slowly building the final parts into the synth board and also writing the software over this easter break (when not on Prodigits!). The software is very challanging because im learning how to design things that are new to me. Im currently working on the envelope generator and the MIDI data recieve and processing routine. So it will an uphill hike for a while yet folks. *

plzgvhug 14.04.12 - 12:11am
The code for the envelope generator is mostly working now and the ATTACK phase of the envelope works and controls the amplitude of the digital oscillator and the paramaters - velocity and attack time work correctly. When the attack phase is over and it does the DECAY phase everything goes wrong. Still got some work to do here. *

plzgvhug 27.04.12 - 12:24am
Ive finaly got the DECAY phase of the envelope generator to work correctly now. Its taken my so long because i thought i could do it with just a few simple calculation but it wouldnt work right. I had to resort to looking at other peoples code to figure it out. The DECAY phase starts after the ATTACK phase and the output level falls to the SUSTAIN level. SUSTAIN is dead easy because the output level just stays the same and waits until the key is released and then do the RELEASE phase which is similar to the decay stage but falls to zero. *


* Reply
* VintageComputers Forum


Search:
topics replies


* VintageComputers

Create Your Own App Store

topTop
groupsGroups
mainProdigits

Create Your Own App Store