how to vary the voltage of spwm signal

Status
Not open for further replies.

mobinmk

Full Member level 2
Joined
May 27, 2010
Messages
140
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Location
Kollam (Quilon),kerala, India
Activity points
2,484
hi frnds

i succesfully generated spwm signal by arduino using dds technique, sine look up table, timer, interupt,

then i fed into low pass filter.

now i got sine wave.

i can vary the fequency of sine wave from 1 hz to 1024 hz.

i wana to vary the voltage of sine wave ,in program .

any idea ??

which code will add to my program.
 

To change the output voltage you have to divide the numbers in your look up table by a suitable factor, i.e. 2, to half the output voltage.
I see you are storing the whole of the sinewave, you could store half of it, then phase invert the second half, or store 1/4 of it and , first read the table forward, then back ward, then repeat with the invert. This would give you a better sinewave, though it does depend on your micro being fast enough compared to the wanted output frequency.
Frank
 

I would consider to multiply the table entries with a magnitude factor. Presently the number representation is offset binary (0 = lowest value, 255 highest). To scale symmetrical to zero output voltage, you would e.g. use 2's complement format. Or have a single quadrant table with unsigned numbers only (following chuckey's suggestion) and generate the negative halfwave when calculating the four-quadrant value.

Asking how to write the spwm code is another word for how do I write non-trivial C programs. You need to become familiar with the language and also with number crunching. There are of course "tons" of spwm example codes on the internet. But I believe that it's not really fruitful to use a code that you don't fully understand.
 

pls optimize this program,

serial monitor is not working,

i wana to add code for interface lcd with arduino
 

Attachments

  • finaloptimize.zip
    2.3 KB · Views: 75

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…