View previous topic :: View next topic |
Author |
Message |
sa6565
Joined: 09 Apr 2016 Posts: 7
|
Posted: Thu Sep 01, 2016 9:35 pm Post subject: Pure sine wave output |
|
|
HI
I want to creat pure sine wave with microcontroller but I'm having trouble writing code in Bascom, please help me with an example.
thanks alot for your help
bye
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
rredding
Joined: 25 Mar 2005 Posts: 63 Location: Tacoma WA
|
Posted: Thu Sep 01, 2016 11:19 pm Post subject: |
|
|
What kind of frequency range are you looking for? Does it need to be very low distortion? Do you have a digital to analog converter on the chip? What kind of processor? MEGA? TINY? XMEGA?
If the frequency is low enough and you have a DAC on an XMEGA chip, have a look at CONFIG DACA in the help. There's an example or two. You simply write a proper series of numbers to the DAC to form the sine wave, then repeat. You can build a data table that has numbers corresponding to the sine function.
If not, you can add an external DAC or if you can stand some distortion, you could make a lower quality DAC from a GPIO output port. Google "DAC USING R-2R Resistor ladder". There's a video.
Or, if your chip has PWM output, you can use an R-C filter on the pin and the output can be a fairly decent sinewave. Google "avr pwm sine wave generator". On the firmware side, it is similar to the DAC.
It is also possible, with a good enough analog filter to make a square wave into a fairly decent sine wave.
It depends on answers to the questions above. |
|
Back to top |
|
|
sa6565
Joined: 09 Apr 2016 Posts: 7
|
Posted: Fri Sep 02, 2016 8:22 am Post subject: |
|
|
hi
thank u for this help
i want to creat 50 hz in pwm output (mega32)
I have a few application examples found but they are codevision source.i can not understand them
thanks alote
bye |
|
Back to top |
|
|
Paulvk
Joined: 28 Jul 2006 Posts: 1257 Location: SYDNEY
|
Posted: Fri Sep 02, 2016 8:32 am Post subject: |
|
|
search the forum for "50hz sine wave" there are a number of examples
Regards Paul |
|
Back to top |
|
|
sasha_1973
Joined: 30 Jul 2013 Posts: 58
|
Posted: Fri Sep 02, 2016 7:38 pm Post subject: Re: Pure sine wave output |
|
|
|
|
Back to top |
|
|
Ross_ValuSoft
Joined: 20 Nov 2005 Posts: 275 Location: Melbourne, Australia
|
Posted: Sat Sep 17, 2016 4:16 am Post subject: |
|
|
Sasha,
I am sure that your code is excellent, but... for those of us who cannot read/understand your Russian(?) language, it is impossible to evaluate/use.
Sorry.
Ross _________________ Ross McKenzie
Melbourne Australia |
|
Back to top |
|
|
sasha_1973
Joined: 30 Jul 2013 Posts: 58
|
Posted: Sun Sep 18, 2016 1:50 pm Post subject: |
|
|
Ross_ValuSoft wrote: | cannot read/understand your Russian(?) language, it is impossible to evaluate/use. |
English version |
|
Back to top |
|
|
Ross_ValuSoft
Joined: 20 Nov 2005 Posts: 275 Location: Melbourne, Australia
|
Posted: Tue Sep 20, 2016 2:02 pm Post subject: |
|
|
Very much appreciated Sasha. _________________ Ross McKenzie
Melbourne Australia |
|
Back to top |
|
|
sasha_1973
Joined: 30 Jul 2013 Posts: 58
|
Posted: Thu Sep 22, 2016 2:06 pm Post subject: |
|
|
Ross_ValuSoft wrote: | Very much appreciated Sasha. |
Glad you liked it. |
|
Back to top |
|
|
|