\главная\р.л. конструкции\...

PIC Tone generator

   This program uses an 8 bit DAC along with a 16F84 PIC microcontroller to generate a keyed sine wave. The 16F84 uses an RC clock which can be varied (with a suitable potentiometer) to allow a variable frequency control for the sine wave output. A key or keyer output can be connected to pin 1 of the PIC to control the tone output.

 This program uses a conventional DDS (Direct Digital Synthesis) phase  accumulator type of algorithm. This is fully explained in the Motorola application note AN1222 referenced above so instead of re-explaining  how it works, here are a few important characteristics of this algorithm. First, the frequency of the tone is easy to control, just change the accumulation constant. In this code this isn't really an advantage since the PIC RC clock has been made variable. Second, the waveform has a certain jitter or "crawl" to it, which is easy to see with an osciioscope. This is due to the fact that the algorithm does not hit exactly the same points of the sine table in each successive cycle of the waveform. Third, because of this preceeding "crawl", it's hard to end the waveform at an exact point - you can get close, but it takes multiple PIC cycles to calculate and compare the present position with the desired ending point. In this program, the waveform just ends when key-up is detected - this may increase the key-up thump a bit when the notone routine slams the waveform back to midscale. These disadvantages of the conventional DDS are dealt with in the  stepdds.asm program which uses the same hardware setup in a different way to generate the tone output.


Click here for:
Project Schematic using an R-2R DAC
Alternate Schematic using a 6 bit binary DAC 
Qbasic program to generate a 256 step sine table
Qbasic program to generate a 128 step sine table
Qbasic program to generate a 64 step sine table
First trial program using a conventional DDS algorithm
Second trial program using a step DDS algorithm

Final program using step DDS and a ramp up/down of the tone

A triangle waveform table - insert in place of the sine table

A sawtooth waveform table - insert in place of the sine table

Readme.txt


PIC pinout:

Pin Name Function / Connection
1 ra2 key input, pulled up to +5V with a 10K resistor
2 ra3 no connect
3 ra4 no connect
4 MCLR pulled up to +5V with a 10K resistor
5 Vss Ground 
6 rb0 connected to 20k dac resistor
7 rb1 connected to 20k dac resistor
8 rb2 connected to 20k dac resistor
9 rb3 connected to 20k dac resistor
10 rb4 connected to 20k dac resistor
11 rb5 connected to 20k dac resistor
12 rb6 connected to 20k dac resistor
13 rb7 connected to 20k dac resistor
14 Vdd +5V
15 osc2 no connect
16 osc1 connected to the RC timing circuit, R = 10k pot, C = 22 pf
17 ra0 no connect
18 ra1 no connect

 


© 2001 - YO5OFH, Csaba Gajdos

Возврат