How to implement an sPWM on arduino/atmel (sinusoidal PWM code and explanation)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024

ความคิดเห็น • 114

  • @OswaldChisala
    @OswaldChisala 8 ปีที่แล้ว +7

    I'm absolutely impressed by the clarity of your explanation of sPWM wave generation. Kudos to you, mate! :)

  • @martyno3171
    @martyno3171 9 ปีที่แล้ว +12

    Best sPWM tutorial I have seen so far! Very clear and informative. Thanks. Point to note, on Mega 2560 one
    needs to change DDR in the variable frequency sketch for PB5 and 6 - i.e. different to Uno. So
    its DDRB = 0b01100000. Cheers

    • @meanman1992
      @meanman1992  9 ปีที่แล้ว

      +martyno Cheers, I am aware of that. Did you have a look at the sketches on github or just from what you saw in the video? I'm not sure if I should try and make the sketches suit multiple boards or just leave it with one to stop it sprawling out too much.

  • @devanshuagarwal38
    @devanshuagarwal38 7 ปีที่แล้ว +1

    Thanks a lot!...I implemented the same logic of SPWM on pic16f72 and its working fine. The detailed tutorial was really helpful.

  • @94aswin
    @94aswin 8 ปีที่แล้ว +3

    I've been searching for this stuff for a few weeks now.... the best explanation that ive come across so far ! Thanks...

  • @JahanZeb1976
    @JahanZeb1976 4 ปีที่แล้ว +1

    *Amazing tutorial. You know the subject matter the best.*

  • @prasanthchigurupatii
    @prasanthchigurupatii 3 หลายเดือนก่อน +1

    Hi ,
    Thanks for the excellent explanation, similarly excepting for three phase sinePWM.

  • @sanupamu
    @sanupamu 7 ปีที่แล้ว +3

    It's best tutorial in whole TH-cam

  • @rashmiranjannayak3251
    @rashmiranjannayak3251 5 ปีที่แล้ว

    Perfect presentation with deep real world focused. Many many thanks for up loading and for noble intention.

  • @ihavecojones
    @ihavecojones ปีที่แล้ว

    At least 1 year of Electrical Engineering and half a year of master's in electrical engineering condensed into a well composed and well explained 24 minute video.
    Someone give this man a stool, a camera , a whiteboard and a decent salary as a teacher...because the old farts couldn't explain how water boils to a fucking kettle...

  • @javasyndicate713
    @javasyndicate713 4 ปีที่แล้ว

    wowww ,,,, why I just find your vid, this is best presentation- Thank You !!

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      Glad it was helpful!

  • @richardmatjeane9004
    @richardmatjeane9004 7 ปีที่แล้ว +1

    Guy!
    I love your work!

  • @kbdesignz5808
    @kbdesignz5808 8 ปีที่แล้ว

    Very cool stuff! Thanks for the well presented explanation.

  • @MsMicro2007
    @MsMicro2007 6 ปีที่แล้ว

    Thanks for such a nice demonstration of SPWM signal generation, can you please tell me what is the value of capacitor used in RC filter

  • @tonysfun
    @tonysfun 7 ปีที่แล้ว

    Very nice! I'm now a subscriber!

  • @Zerofoxthree
    @Zerofoxthree 6 ปีที่แล้ว

    very great tutorial, i learn a lot from here

  • @abdulkadirkucuk8384
    @abdulkadirkucuk8384 6 ปีที่แล้ว

    very good effort for spwm generating idea. but you should build a multi channel spwm for full bridges.

  • @muhammadbilalmemon271
    @muhammadbilalmemon271 6 ปีที่แล้ว

    sir please let us know the values of capacitor & resistor you used here.

  • @franciscoantoniomoralestap4830
    @franciscoantoniomoralestap4830 6 ปีที่แล้ว

    Very good brother, greetings from Mexico ... just one question, pin number 13 that works in the physical application.?

  • @vipinchoudhary2787
    @vipinchoudhary2787 6 ปีที่แล้ว

    please tell ,how to calculate the value for sine table....

  • @muznashiblifarooqi9977
    @muznashiblifarooqi9977 8 ปีที่แล้ว

    Is it possible to add a 90 degree phase shift in the spwm?

  • @ainsworthlynch
    @ainsworthlynch 8 ปีที่แล้ว

    If i have a sqaurewave inverter could I feed the Spwm through an Opamp and feed Fets to modify output signal?

  • @JoshuaHarbangan
    @JoshuaHarbangan 7 ปีที่แล้ว

    Very nice tutorial sir... I've tried to use your code (SPWM with variable sinusoidal frequency) on my single phase inverter project. But I have one question... Can you explain me how to add a "delay" (about 500 uS) in the transition between OCR1A and OCR1B? Thank you sir...

  • @andryxa77
    @andryxa77 4 ปีที่แล้ว

    Hi. Is there any plans to implement this on esp32? Would be much appreciated to see example of working code on esp32 to output spwm pulses.

  • @birdemetsohbet9588
    @birdemetsohbet9588 4 ปีที่แล้ว

    which output is giving pwm to inverter which we are going to implement ? are u using 13 ?

  • @wallaceobey651
    @wallaceobey651 5 ปีที่แล้ว

    Thanks for this!. Also I saw your code on github and I've been trying to add a dead band/dead time to it. Do you have any tips for this? Thanks again.

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      A few people have asked for dead-band, I should look at adding it. I don't have any specific tips, but if you wanted to put up a WIP pull request we could tackle it together from there?

  • @josepablodelgado1230
    @josepablodelgado1230 5 ปีที่แล้ว

    if i want to make a little inverter (low power and for 10 DC Volts) with that code, i only put the outputs 13 and 10 to H bridge with mosfet or IGBTS?

  • @ahmedessaffani7059
    @ahmedessaffani7059 6 ปีที่แล้ว

    very instructive tutorial. Thanks,

  • @irwandiusk4808
    @irwandiusk4808 4 ปีที่แล้ว

    Thank you for your code, I have gotten a nice sinusoidal waveform. I will use the wave to drive the speaker and I need a circuit with few transistors to amplify the signal. Could you give me information about the circuit?

  • @sanupamu
    @sanupamu 7 ปีที่แล้ว

    Dear sir could you please me one thing instead of H-bridge if I use center tap transformer for out put and used two sets of mosfet for pin 9 and 10, so what will happen?. sine wave can generate or not? or generate some distort wave?

  • @VishnuMenon67
    @VishnuMenon67 4 ปีที่แล้ว

    So if we need for a different switching frequency , we need to change the lookup table right ? Also how to write the lookup table?

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      Have you watched the second part of this video?
      th-cam.com/video/3DjKxDL_Qc0/w-d-xo.html

  • @PauloZancoski
    @PauloZancoski 5 ปีที่แล้ว

    Great video !

  • @vengug7303
    @vengug7303 4 ปีที่แล้ว

    Hi sir how to change the mosfet switching frequency please

  • @hamzaabbasi6418
    @hamzaabbasi6418 7 ปีที่แล้ว

    can you please tell me how you have determined the contents of look up matrices

    • @timm3802
      @timm3802 6 ปีที่แล้ว

      watch the video!

  • @0rchimaru
    @0rchimaru 7 ปีที่แล้ว +1

    May I know how do you calculate the lookup table?

  • @jamest.5001
    @jamest.5001 7 ปีที่แล้ว

    this is the most informative video I have found. I am curious . do you or have you made a boost stage for a inverter? or the code for arduino to drive a DC boost. it needs to be self regulating. I found a spwm driver board. to run safety functions. and drive the H bridge. my concern is boosting 12-24v yo about 170+/-, at enough current for a 2500-5000 watt inverter. from your video I think you can solve this issue. if you can. it would be a great help. I know very little a out arduino. and coding thanks

  • @kingsleyazubuikeabonyi3612
    @kingsleyazubuikeabonyi3612 2 ปีที่แล้ว

    How can I download your code, and what are the libraries needed Engr. Kurt?

  • @zainharoon4156
    @zainharoon4156 4 ปีที่แล้ว

    And sir should we make spwm for sinwave without intrupt

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      I doubt it's possible with this hardware.

    • @zainharoon4156
      @zainharoon4156 4 ปีที่แล้ว

      @@meanman1992 ahn so there is no way without intrupt?

  • @JJ.24.6
    @JJ.24.6 7 ปีที่แล้ว

    Hi...please tell me that can i check results of these program in the serial plotter???
    Please reply..

  • @yannis92preloude
    @yannis92preloude 4 ปีที่แล้ว

    Hi. Meanman from your code is possible to adjust the output voltage. I have transformer 10v 0 10v input 12 volt with no feed back my AC looks good on scope butt under load i get 207volts. can you help in anyway , thanks Yannis

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      There's a second part to this video where we change the amplitude of the wave, which would lower the voltage, have you seen it?
      th-cam.com/video/3DjKxDL_Qc0/w-d-xo.html

  • @sanupamu
    @sanupamu 7 ปีที่แล้ว

    Could you please let me one thing. In arduino IDE io.h library are available?. How can I write code in register level as well as arduino function.

  • @karolinamaria915
    @karolinamaria915 7 ปีที่แล้ว

    hello good night, I'm experimenting with a 3-phase inverter design with arduino nano, put the program that is here on the internet, but the fault that I present is that it rotates like a stepper motor, please please me you can indicate that it may be happening thank you,

  • @dantosrock43
    @dantosrock43 5 ปีที่แล้ว

    hello sir, what is the value RC filter? i tryn 100nf and 50kvr not respon thank u

  • @hassane89n
    @hassane89n 8 ปีที่แล้ว

    Thanks for useful stuff. I am wondering if the amplitude can change? I am using encoder for speed reading when the speed reduce i need to reduce the amplitude for the output pwm.
    Thanks!

    • @meanman1992
      @meanman1992  8 ปีที่แล้ว

      I think you have already found my other video where I have some code that allows for amplitude change?

    • @hassane89n
      @hassane89n 8 ปีที่แล้ว

      Thanks, I found it but my idea is to change the amplitude depends on motor speed. For instance, make the ma=0.8 instead of 1. is that possible? I am considering V/f method for single induction motor

    • @meanman1992
      @meanman1992  8 ปีที่แล้ว

      I don't know what "ma" stands for, neither do I now what "V/f" is? Variable frequency? the other video covers changing the the amplitude and frequency, not depending on motor speed but you could write a code yourself that builds on mine that does that quiet easily.

    • @kbdesignz5808
      @kbdesignz5808 8 ปีที่แล้ว

      meanman1992 v/f in motor drive world is voltage/ frequency usually

  • @thuyavansathiamurthi3592
    @thuyavansathiamurthi3592 ปีที่แล้ว

    You rock my guy

  • @harshsrivastava3066
    @harshsrivastava3066 6 ปีที่แล้ว

    How to generate the pwm of 10 kHz in ARDUINO DUE? What changes I will have to do in your code? and how will I get the header file of look up table for the sinusoidal ,triangular and pwm ? also u have used "#include
    #include "
    how will Iget the above two ?

  • @janpaul5059
    @janpaul5059 7 ปีที่แล้ว

    I think that using analogWrite command is simplest to get the same result

  • @allanharper9001
    @allanharper9001 6 ปีที่แล้ว

    Well done mate

  • @nguyenat1965
    @nguyenat1965 4 ปีที่แล้ว +1

    good job !

  • @MegaFer1994
    @MegaFer1994 5 ปีที่แล้ว

    can you help me, I want the fundamental frequency to be 60 hz thanks

  • @sumanjha1951
    @sumanjha1951 7 ปีที่แล้ว

    awesome ... thanks for great information, can you explain generic spwm code more clear

  • @Pedro19123
    @Pedro19123 8 ปีที่แล้ว

    Hello my friend. How are you doing?
    I want to know how much is the capacitance that you used for the low pass filter.
    THANK YOU SO MUCH. GREAT VIDEO!

    • @rodstartube
      @rodstartube 5 ปีที่แล้ว

      don't lose you faith, he should still answer

  • @Jm-my1rd
    @Jm-my1rd 4 ปีที่แล้ว

    can you make another video using pic18f4550 using MPlab compiler for the spwm?

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      Probably not, but you might be able to take these concepts, look at the datasheet and try and implement it yourself. 👍

  • @adammohiuddin463
    @adammohiuddin463 8 ปีที่แล้ว

    I want to program variable frequency spwm in my arduino mega 2560, but the catch is that the magnitude of the sine wave is also dependent on the frequency by the equation magnitude= (frequency*4.4 +5.4)/225.4. Is it possible to do so? If yes would you please let me know the changes that must be made in your code for variable frequency spwm? Thank you!

    • @meanman1992
      @meanman1992  8 ปีที่แล้ว

      check out the new video, the varible frequency spwm code should make it a lot easier for you.
      th-cam.com/video/3DjKxDL_Qc0/w-d-xo.html

  • @xierxu
    @xierxu 4 ปีที่แล้ว

    Where can I learn how to do all this from scratch?

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว +1

      Don't think I can answer that completely. But learning C/C++ programing, and being involved in the adruino community is a good place to start. They might be able to answer the question better.
      forum.arduino.cc/

    • @xierxu
      @xierxu 4 ปีที่แล้ว

      @@meanman1992 Could you recommend books and a proven circuit to program and utilize the Atmega chip? I think the Atmel is Atmega?

  • @lovelifeandunity1533
    @lovelifeandunity1533 4 ปีที่แล้ว

    Hello meanman, can u help me kindly with three phase spwm.. specially the confusing part is to generate 120 degree phase shift with high frequency (40-60khz) range.. I wonder how to manage that with 16bit timers including 8bit.. please guide...

  • @abhishekprasad3299
    @abhishekprasad3299 7 ปีที่แล้ว

    Very good and informative video.It helped a lot. Thanks. Do you have one for three phase?

    • @abhishekprasad3299
      @abhishekprasad3299 7 ปีที่แล้ว

      What changes should be made in the code, can you help please.

  • @parthibadnan7262
    @parthibadnan7262 7 ปีที่แล้ว

    nice video.
    i converted the ino file to hex and ran it on proteus .But the output signal seems to be less than 50 hz and the line
    period = microMHz*1e6/freq/SinDivisions does not seem to work but if i use
    period = microMHz*1e6/freq/SinDivisions /8 then i get 50 hz frequency
    can you tell me why?

  • @giridharan9038
    @giridharan9038 7 ปีที่แล้ว

    sir i need about ibgt details using this project

  • @omtandon2741
    @omtandon2741 3 ปีที่แล้ว +1

    Me: Spending weeks figuring out the best way to make a perfect SPWM output.
    Other TH-camrs: Writing this code "
    int mos_top = 3;
    int mos_bot = 5;
    double pot = 0;
    void setup() {
    //define the pins as outputs
    Serial.begin(9600);
    pinMode(mos_top,OUTPUT);
    pinMode(mos_bot,OUTPUT);
    pinMode(pot,INPUT);

    //Initial value is LOW
    digitalWrite(mos_top,LOW);
    digitalWrite(mos_bot,LOW);
    }
    void loop() {
    double pot_val = analogRead(pot)/10;
    //One is LOW and other is HIGH
    digitalWrite(mos_top,LOW);
    digitalWrite(mos_bot,HIGH);
    delay(pot_val); // 1/16ms = 62.5Hz
    //One is HIGH and other is LOW
    digitalWrite(mos_top,HIGH);
    digitalWrite(mos_bot,LOW);
    delay(pot_val);
    Serial.println(pot_val);
    } "
    and putting "PURE SINEWAVE INVERTER TUTORIAL " in the thumbnail.

  • @milanmakwana3883
    @milanmakwana3883 4 ปีที่แล้ว

    Nice away some can you make video for three phase spwm 120 apart from each other

  • @Electron6807
    @Electron6807 4 ปีที่แล้ว

    Bro how to generate 3 phase pwm supply

  • @zainharoon4156
    @zainharoon4156 4 ปีที่แล้ว

    Sir i used analogread() command in isr(timero_vect) after that my circuit is short and output is out shape sir kindly how i can use adc in isr(timer0_vect)

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      The interrupt is called very ofter, I'm not sure how long it takes for anologread() to finish, but it's possible that it's simply too slow to be called in the ISR. Why do you want to read it that often?

    • @zainharoon4156
      @zainharoon4156 4 ปีที่แล้ว

      @@meanman1992 sir i want control output of sinwave when i used analogread() in loop so my output slowly incresed because intrupt go first after it finish it will go to loop then take adc value their so thats why my output reached slowly so thats the reason thats why i want to use feedback adc in isr(timer0_vect) if you kindly guid me how its possible ?

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      @@zainharoon4156 I still don't understand why you want to read it that often? like what's the motivation. Like I said I think it's probably not possible because of how often the ISR is called. The loop that comes from ISR is very different from the arduino "loop" as the former doesn't wait for everything to finish executing. Since I don't know why you think you need to read that often it's hard for me to say, But I would use a separate loop, not the ISR. and by "slowly increase" I'm guessing you mean increasing the amplitude. So long as you modifying a scale variable that the isr uses to calculate the output, then you will not need analog read to run every time in the isr.

    • @zainharoon4156
      @zainharoon4156 4 ปีที่แล้ว

      @@meanman1992 sir i want to increase or decrease the amplitude of sinwave frequently but my amplitude of sinwave don t increase frequently so i want make frequently how can i make it frequently sorry if i can t tell you my whole thing if you kindly give me your email i will sent you my code

    • @meanman1992
      @meanman1992  4 ปีที่แล้ว

      ​@@zainharoon4156 Sorry mate, I can't review code.

  • @digitalbeauty5688
    @digitalbeauty5688 7 ปีที่แล้ว

    HELLO FRIEND CAN YOU PLEASE TELL ME THAT WHAT ARE THE VALUES OF R & C YOU USED HERE. I WILL BE GLAD IF YOU REPLY. THANKS

  • @THlCKOFlT
    @THlCKOFlT 2 หลายเดือนก่อน

    Thank you !!

  • @tiagonet8794
    @tiagonet8794 8 ปีที่แล้ว

    for 60Hz have any modification?

    • @meanman1992
      @meanman1992  8 ปีที่แล้ว

      5th line
      static int freq = 60; // Sinusoidal frequency

    • @meanman1992
      @meanman1992  8 ปีที่แล้ว

      Also this th-cam.com/video/3DjKxDL_Qc0/w-d-xo.html

  • @asitbiswas6039
    @asitbiswas6039 5 ปีที่แล้ว

    how can i increase two signal's gap and how can i add feedback loop Please help me sir!!!!

  • @alexwv8871
    @alexwv8871 8 ปีที่แล้ว

    Can you help me with my custom game pad? I have some pics of what I'm using if you would like to help. I'd really appreciate it. I don't know how I can wire the button board to my computer

  • @omergonulal2572
    @omergonulal2572 7 ปีที่แล้ว

    Thank you for this video.this video very perfect 🖒🖒🖒🖒🖒🖒

  • @SudiptaMandalsuri
    @SudiptaMandalsuri 6 ปีที่แล้ว

    amazing.. learnt a lot form this video.. I really appreciate your work

  • @pacocable
    @pacocable 7 ปีที่แล้ว

    please can you say me the value capacitor, resistor and trimmer? thank you very much.i don´t speak english very well

  • @fernandoyose6680
    @fernandoyose6680 8 ปีที่แล้ว

    thx alot dude

  • @erenyeage1995
    @erenyeage1995 8 ปีที่แล้ว

    hey can some body help me here.
    I'm new in arduino. So i want to ask that why the ground pins of arduino were not used ?

    • @RNA0ROGER
      @RNA0ROGER 8 ปีที่แล้ว

      They share the same ground.

  • @har2191
    @har2191 6 ปีที่แล้ว

    Hi sr. Nice video,mmmmm.... please, can you tell me how make it for 60Hz?

    • @timm3802
      @timm3802 6 ปีที่แล้ว

      watch the video!

  • @mangeshdoifode1470
    @mangeshdoifode1470 7 ปีที่แล้ว

    hiiii.nice explaination.can i get ur email id please.as their is some important issues that i want to share with you related to my project.

  • @noslidemais
    @noslidemais ปีที่แล้ว