Test
|
I see. However, the use of the term PWM is a bit of a misnomer here, isn't it? It seems like you just want 50% duty cycle (or what I think of as just a square wave). I guess PWM HW reduces the burden on the PIC but that's just an optimization. You can get a lot higher frequencies by diddling the output pin directly and its not THAT much overhead if done from an ISR. --- In , "Moonshadow" <moonshadow@n...> wrote: > Try the "electronics" button on ... > > http://homepage.ntlworld.com/moonshadow/New_Folder/index.htm > > It covers square to sine conversion with PICS. > > Hope it helps .... John > > ----- Original Message ----- > From: Phil > To: > Sent: Monday, January 19, 2004 12:46 PM > Subject: [piclist] Re: sine wave genaration using pic 16f8xx > I'm sure I'm missing something obvious here but how do you get a sine > wave out of pulse width modulation? I assume you could feed the > digital output through a cap but isn't a sine wave symetrical? (i.e. > each 1/4 cycle is the same length) Isn't PWM output, except for 50% > duty, asymetrical? > > --- In , Chad Russel <chadrussel@y...> wrote: > > The maximum frequency depends on the processor, clock frequency, and > > the accuracy of the sine wave. > > > > Approximately as follows: > > > > If you want 1 khz and you have a 10 bit PWM and want maximum > > resolution, then frequency of the PWM will have to be 1024 times > the 1 > > khz or 1.024 Mhz and the frequency of timer 2 will have to 1024 > times > > that or 1.048576 Ghz. Obviously there must be a compromise, in > > resolution probably. If you could live with 8 bits of resolution, > the > > cycle time would be 256 * 256 * frequency or 65.536 Mhz. > > > > I have not checked this carefully, so if someone disagrees... the > > maximum frequency would be (clock/4) / (2^resolution bits)^2. > > 4 Mhz osc and 8 bits = 15.258 Hz > > 20 Mhz osc and 8 bits = 76.294 Hz > > > > In reality, some bits will never be used, so some cycles could be > > skipped to reduce the number, but not many. > > > > Chad > > > > --- edubillirambabu <edubilliramu98@y...> wrote: > > > hai > > > I need 1khz sine wave in PWM mode using PIC16F8xx. > > > What is the maximum frequency of sine wave that can be generated > in > > > PWM mode using the pic?? > > > please reply if any one knows it. > > > Regards > > > Ramu > > > > > > > > > > > > > > > __________________________________ > > to unsubscribe, go to http://www.yahoogroups.com and follow the instructions > -------------------------------- ---------- > Yahoo! Groups Links > > a.. To |
See class D amplifiers. Here is one reference: http://users.ece.gatech.edu/~mleach/ece4435/f01/ClassD2.pdf --- Phil <> wrote: > I'm sure I'm missing something obvious here but how do you get a sine > > wave out of pulse width modulation? I assume you could feed the > digital output through a cap but isn't a sine wave symetrical? (i.e. > each 1/4 cycle is the same length) Isn't PWM output, except for 50% > duty, asymetrical? > > --- In , Chad Russel <chadrussel@y...> wrote: > > The maximum frequency depends on the processor, clock frequency, > and > > the accuracy of the sine wave. > > > > Approximately as follows: > > > > If you want 1 khz and you have a 10 bit PWM and want maximum > > resolution, then frequency of the PWM will have to be 1024 times > the 1 > > khz or 1.024 Mhz and the frequency of timer 2 will have to 1024 > times > > that or 1.048576 Ghz. Obviously there must be a compromise, in > > resolution probably. If you could live with 8 bits of resolution, > the > > cycle time would be 256 * 256 * frequency or 65.536 Mhz. > > > > I have not checked this carefully, so if someone disagrees... the > > maximum frequency would be (clock/4) / (2^resolution bits)^2. > > 4 Mhz osc and 8 bits = 15.258 Hz > > 20 Mhz osc and 8 bits = 76.294 Hz > > > > In reality, some bits will never be used, so some cycles could be > > skipped to reduce the number, but not many. > > > > Chad > > > > --- edubillirambabu <edubilliramu98@y...> wrote: > > > hai > > > I need 1khz sine wave in PWM mode using PIC16F8xx. > > > What is the maximum frequency of sine wave that can be generated > in > > > PWM mode using the pic?? > > > please reply if any one knows it. > > > Regards > > > Ramu > > > > > > > > > > > > > > > __________________________________ > > > __________________________________ |
If you run a PWM signal through a low pass filter, you get a DC voltage that is proportional to the duty cycle times Vcc (assuming the PWM switches between Vcc and 0V). If you vary the PWM, the DC voltage varies. The trick here is to have the cutoff frequency low enough so the PWM switching frequency is adequately attenuated while the audio you're trying to generate is not attenuated. Harold FCC Rules Online at http://www.hallikainen.com -- "Phil" <> wrote: I'm sure I'm missing something obvious here but how do you get a sine wave out of pulse width modulation? I assume you could feed the digital output through a cap but isn't a sine wave symetrical? (i.e. each 1/4 cycle is the same length) Isn't PWM output, except for 50% duty, asymetrical? --- In , Chad Russel <chadrussel@y...> wrote: > The maximum frequency depends on the processor, clock frequency, and > the accuracy of the sine wave. > > Approximately as follows: > > If you want 1 khz and you have a 10 bit PWM and want maximum > resolution, then frequency of the PWM will have to be 1024 times the 1 > khz or 1.024 Mhz and the frequency of timer 2 will have to 1024 times > that or 1.048576 Ghz. Obviously there must be a compromise, in > resolution probably. If you could live with 8 bits of resolution, the > cycle time would be 256 * 256 * frequency or 65.536 Mhz. > > I have not checked this carefully, so if someone disagrees... the > maximum frequency would be (clock/4) / (2^resolution bits)^2. > 4 Mhz osc and 8 bits = 15.258 Hz > 20 Mhz osc and 8 bits = 76.294 Hz > > In reality, some bits will never be used, so some cycles could be > skipped to reduce the number, but not many. > > Chad > > --- edubillirambabu <edubilliramu98@y...> wrote: > > hai > > I need 1khz sine wave in PWM mode using PIC16F8xx. > > What is the maximum frequency of sine wave that can be generated in > > PWM mode using the pic?? > > please reply if any one knows it. > > Regards > > Ramu > > > > > > __________________________________ > to unsubscribe, go to http://www.yahoogroups.com and follow the instructions |
Try the "electronics" button on
...
http://homepage.ntlworld.com/moonshadow/New_Folder/index.htm
It covers square to sine conversion
with PICS.
Hope it helps .... John
|
|
Okay... its still early in the morning, but the answer below
doesn't quite look right to me. Time for me to have a look
at the PWM on the PIC (never used it before)
Regards,
Eugene
|
I'm sure I'm missing something obvious here but how do you get a
sine wave out of pulse width modulation? I assume you could feed the digital output through a cap but isn't a sine wave symetrical? (i.e. each 1/4 cycle is the same length) Isn't PWM output, except for 50% duty, asymetrical? --- In , Chad Russel <chadrussel@y...> wrote: > The maximum frequency depends on the processor, clock frequency, and > the accuracy of the sine wave. > > Approximately as follows: > > If you want 1 khz and you have a 10 bit PWM and want maximum > resolution, then frequency of the PWM will have to be 1024 times the 1 > khz or 1.024 Mhz and the frequency of timer 2 will have to 1024 times > that or 1.048576 Ghz. Obviously there must be a compromise, in > resolution probably. If you could live with 8 bits of resolution, the > cycle time would be 256 * 256 * frequency or 65.536 Mhz. > > I have not checked this carefully, so if someone disagrees... the > maximum frequency would be (clock/4) / (2^resolution bits)^2. > 4 Mhz osc and 8 bits = 15.258 Hz > 20 Mhz osc and 8 bits = 76.294 Hz > > In reality, some bits will never be used, so some cycles could be > skipped to reduce the number, but not many. > > Chad > > --- edubillirambabu <edubilliramu98@y...> wrote: > > hai > > I need 1khz sine wave in PWM mode using PIC16F8xx. > > What is the maximum frequency of sine wave that can be generated in > > PWM mode using the pic?? > > please reply if any one knows it. > > Regards > > Ramu > > > > > > __________________________________ > |
|
The maximum frequency depends on the processor, clock frequency, and the accuracy of the sine wave. Approximately as follows: If you want 1 khz and you have a 10 bit PWM and want maximum resolution, then frequency of the PWM will have to be 1024 times the 1 khz or 1.024 Mhz and the frequency of timer 2 will have to 1024 times that or 1.048576 Ghz. Obviously there must be a compromise, in resolution probably. If you could live with 8 bits of resolution, the cycle time would be 256 * 256 * frequency or 65.536 Mhz. I have not checked this carefully, so if someone disagrees... the maximum frequency would be (clock/4) / (2^resolution bits)^2. 4 Mhz osc and 8 bits = 15.258 Hz 20 Mhz osc and 8 bits = 76.294 Hz In reality, some bits will never be used, so some cycles could be skipped to reduce the number, but not many. Chad --- edubillirambabu <> wrote: > hai > I need 1khz sine wave in PWM mode using PIC16F8xx. > What is the maximum frequency of sine wave that can be generated in > PWM mode using the pic?? > please reply if any one knows it. > Regards > Ramu > __________________________________ |
|
hai I need 1khz sine wave in PWM mode using PIC16F8xx. What is the maximum frequency of sine wave that can be generated in PWM mode using the pic?? please reply if any one knows it. Regards Ramu |
|