| ??? 06/12/03 04:51 Read: times |
#48128 - RE: How to generate variable sine wave Responding to: ???'s previous message |
Hallo Sathish,
There are several ways to proceed. As you did not told us, what specifications circuit must fullfill (harmonic distortion, frequency resolution, etc.) I would try the following two ways. If I had some port lines free I would try the following: ![]() 27C256 contains one digitized period of sinus function. Mcu must deliver exactly every 12.207µsec a new 15bit address. 12.207µsec means an actualization rate of 81.92kHz. This is more than 4 times higher than maximum frequency of 20kHz. Keep in mind that actualization rate is constant, means it is always the same, equally which frequency is fabricated. This allows the use of restoration low-pass filter with fixed corner frequency, here about 20kHz with 9-pole dampening. Frequency fabrication is done the following: Assume 20Hz is to be fabricated. 27C256 contains 32768 samples, representing ONE period of sinus function. For one 20Hz period, means a time interval of 50msec, actualization rate of 81.92kHz gives 4096 samples per period. So, every 8th sample of 327678 samples sitting inside of 27C256 must be output. Mcu has to do the following to achieve this: At first, Mcu produces address '000,0000,0000,0000' (binary). After outputing it to according port lines, P 3.X line is switched high and afterwards low again. By doing so, output of 27C256 is latched and converted into analog voltage. Then, exactly 12.207µsec later, a different address is output: Address is actualized by simple adding decimal '8', means '000,0000,0000,1000' (binary). Every 12.207µsec a new address is output to 27C256, which is derived from the preceeding by simply adding decimal '8'! So, each frequency to be fabricated has it's own address OFFSET: For 20Hz offset is decimal '8', for 40Hz offset is decimal '16', ... , for 20480Hz offset is decimal '8192'. Resolution is ONE digit of this offset. E.g., when using an offset of '9' instead of '8' frequency fabricated is 22.5Hz. So, resolution is 2.5Hz or 12.5% at 20Hz. At 20480Hz resolution is the following: Using offset of '8193' instead of '8192' gives a frequency of 20482.5Hz. So, absolute resolution is also 2.5Hz, but relative resolution is now 0.012%. For being able to fabricate exactly 20000Hz, an offset of '8000' must be used. Formula for calculating offset of certain frequency to be fabricated is: 'offset' = 32768 x 12.207031µsec x f Of course, actualization rate need not to be exactly 1 / 12.207031µsec = 81.92kHz. But then, 20.000Hz cannot be produced exactly. -------------------------- If on the other hand several free port lines are not available, but only one port line, then following circuit can help to fabricate sinus wave. ![]() Mcu must produce a square wave with exactly the frequency of wished sinus wave. Then, a PLL circuit is used to fabricate sinus wave, which has the same frequency as square wave. Note, that for XR2206 chip not all needed electronic parts are drawn in the schematic. So, have a look at datasheet, for finding what is also needed. From CD4046 only the phase comparator is used. Output of this phase comparator is feeded to obligatory PLL loop filter, which in combination with transistors produces the correct signal for XR2206. This loop filter must be developed very carefully, in order to achieve a good compromise between ripple, which results in frequency jitter, and settling time, which is the time, the PLL needs to produce correct frequency. Loop filter highly depends on frequency range of XR2206, and it's the best to make several frequency ranges by switching several well suited capacitors C to according pins of XR2206. This can be done by analog switches, like CD4066, or so. Here some developing work has to be done by you: If settling time must be short, more frequency jitter has to be accepted and vice versa. Hope it helps a little bit, Kai |
| 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 |





