Home


I thought I had the first with free  90s2313 polyphonic code but then  I found this russian site with a toy keyboard
it using Babelfish

About the System

The90S2313 proves to be an inexpensive platfrom for microcontroller development for the hobbyist, A serial programmer can be built for a few dollars and the chips themselves can be had for a similar price   I was able to purchase the AT90S2313-10PI chip at an electroonic parts outlet for NZ$4.15 (approx equiv US$2.90) each while the "electronics toystore" lists the softer -10PC  in their catalog for NZ$15.75

In implementing this simple polyphonic engine I have become aware of the limitations of this device. most notably the lack of a hardware multiply means that I had to forego implementing direct control of the ampplitude. and the lack of memory which left me without room for more than table with a simple sine wave.

Note however that all waveforms can be decomposed into sine waves by fourier analysis, and amplitude can be controlled by playing the same frequency in two channels but with differing phases. I have not tried to implement these features.

This code was originally developed to provide music for the doorbell function of a driveway gate controller and as most of the 2K rom was needed to provide all the feature I wanted for that I used only a 64 byte table (containing 1/4 of the sine wave)

According to Nyquist's theorem the reliably reproduced frequency is just below 1/2 of the sample rate so with the MPU runninbg at the maximum 10MHz and the 8-bit PWM output in it's fastest (8-bit) mode that means a rate of 1e7 / 510 = 19608KHz or so the maximum frequency is approx 9KHz
So basically you get "AM radio quality" sound.

At 510 cycles per sample the MPU can synthesise 15 fixed amplitude sine wave channels (using my code) If fewer channels are needed and there are spare IO pins the code cpould be modified to use an an R-2R network (or other hardware DAC) could be used to give a greater bandwidth, or greater resolution, or a combination of both.

Initial development was done using a STK200 board that had been modified with a pin header socket for the crystal to allow the regular 4Mhz crystal to be replaced with a 10Mhz device.  Were I to modify another STK board I'd use half of a 6 pin DIP socket with the middle pin removed. off-the shelf crystals will just plug straight in. with the pin header sopcket off-the shelf crystals are a little loose and work best if soldered to a piece of pin header strip.


picture of my slightlly modified STK200 attached to an amplified internal PC speaker
obligatory harware pic

The source code was developed using the free avra assembler , and may contain some constructs not supported by the atmel avr assembler



To the source    back to home    download source code (zip archive)
 
comments? suggestions? email me!










Hosted by www.Geocities.ws

1