Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Inverter SPWM and Carrier generating using Arduino Mega

Status
Not open for further replies.

Mahmoud AbdElgleel

Newbie level 5
Joined
Nov 11, 2015
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
75
Hello
I wanna generate spwm signal using arduino but I can't set the frequncy of the carrier "triangle signale " and the sine wave which are compared to each other using Arduino mega
the image illustrates what i wanna do and code are attached thanks in advance

3656975600_1447259589.jpg
 

Attachments

  • carrier_version_1.rar
    496 bytes · Views: 150

The best way is to design the pwm by simulink then download it to arduino mega
 
The sawtooth wave does it automatically as an analog function. It is a geometric method to solve two simultaneous equations. Namely, where do the two graph lines intersect?

When we try to code it we must use a mathematical approach. I believe it's a calculus problem.

Start with the first time increment. Ask, what length does a pulse need to be, in order to create an area equal to the area found under the sine curve, during that time increment?

I think this works out about the same as taking the sine at that point on the curve, then set that pulse length in proportion to whatever you set as your maximum length.

Example, suppose pulses at the peak are same length as the time step.
...Then at the 20 degree mark, make that pulse 34% as long, because the sine of 20 degrees is 0.342.
...At the 40 degree mark, make that pulse 64% as long, because the sine of 40 deg is .643.
...At the 60 degree mark, make that pulse 87% as long, because the sine of 60 deg is .866.
Etc.
 

My issue is varing the frequency of the sine wave and the triangle wave not of the same frequency and get comparison between them every time of dfferrent frequncy

How can i do this ?
I have tried to code arduino using m file but using simulink i don't know if it's available

I don't know if it's available to upload to arduino using simulink I've tried before using m file
 
Last edited by a moderator:

Your diagram generates AC pulses. It illustrates the theory behind generating spwm. However you require a slightly different concept if you wish to generate DC pulses. (That is, if you plan to drive transistors/ mosfets.)

You need to shift the sawtooth into the positive region during the time the sine is in the positive. That is how to generate positive spwm.

Then if you look closely, you'll see that each sawtooth (timestep) slices off a segment of the sinewave, the width of which automatically reflects the sine value.
 
I got what you say but how to vary the frequency the issue is still
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top