| ??? 06/11/03 19:47 Read: times |
#48088 - RE: How to generate variable sine wave Responding to: ???'s previous message |
The "simplest" approach is to have your PWM duty cycle controlled by a sine wave table(in code memory)..
The PWM duty cycle is used to control the output voltage (through a low pass filter - check the Microchip app note detailing PWM filters) , The sine wave table is used for the PWM values , as you step through the sine wave table (at the chosen frequency )the sine wave will be output via the PWM filter.. The sine wave table is calculated via a simple basic program or suchlike
eg
10 OPEN "table.c" FOR OUTPUT AS #1
15 CLS
20 PRINT #1, "// Table generated by TABLE.BAS": PRINT #1, " int const ref_sine_table[] = { "
50 amplitude = 100: ADdiv = 256: thirdamplitude = 0
75 PRINT : PRINT "Generating table in TABLE.C.....": PRINT
100 FOR i = 0 TO (ADdiv - 1) STEP 1
110 table = amplitude * SIN((i * 2 * 3.1415926#) / (ADdiv - 1)): '+ ADdiv / 2
130 PRINT #1, INT(table); ",": PRINT INT(table); i; ","
140 NEXT i
200 PRINT #1, " } ;": PRINT " } ;"
If all goes well you will now have a sine wave that alternates from 0v to 5v , with 2.5v as the pseudo crossing point (not based on the code above)...it would be easy to bias an op amp at 2.5v to give a true +/- voltage swing.. If you definately have to do it by PWM ,some of the siemans chip with the capcom modules can work up to this frequency.. There is/was a programmable sine wave generator ,the ML2036 that with a 4meg crystal ,can cover the range of 0.5 to 32khz ,and may be an easier proposition. |
| Topic | Author | Date |
| How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| PWM Audio Reproduction | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
| RE: How to generate variable sine wave | 01/01/70 00:00 | |
RE: How to generate variable sine wave | 01/01/70 00:00 |



