0

I want to create an AC PWM pulse with arduino. The microcontoller, will be also responsible for specifying the frequency (which will be around 500 Hz).

External electronic components can also be used. Like an H-Bridge perhaps.

EDIT: This is the final waveform I want to produce: enter image description here

I know the arduino is not capable of producing 36 V output. I plan to just create this waveform, with whatever the arduino can output and then step up the voltage. But this is the final waveform that I want produced.

11
  • What exactly do you mean with "AC PWM pulse"?
    – chrisl
    Oct 17, 2022 at 7:26
  • @chrisl I edited the question. Oct 17, 2022 at 7:33
  • Ah, ok. Using a H-bridge sounds good here. Have you tried it? What is your specific problem in doing so?
    – chrisl
    Oct 17, 2022 at 8:23
  • Yes a H-bridge is what you want. But be careful with controlling it as you may need to add a "dead zone" to prevent crowbaring (aka "overshoot").
    – Majenko
    Oct 17, 2022 at 8:34
  • @chrisl My problem is lack of experience.. So I do not know the best approach to this problem. Should I create a PWM pulse, double the frequency that I want with the arduino. Then half the frequency should be reversed with the H-Bridge? If yes, how exactly do I control the H-Bridge so that it reverses the pulse where I want? There is another option of a continuous output by the digital pin, then the H-Bridge will reverse half of the time .... So you get this AC square pulse.. But timing is critical so that you get the frequency you want... Oct 17, 2022 at 8:34

1 Answer 1

2

Yes, you want a H-bridge. That is the simplest way to make that "negative*" voltage.

But you can't just create a square wave and throw it blindly at a H-bridge, you have to be much more careful, otherwise you will cause short circuits and dissipate massive amounts of power.

You will need a "discrete" H-bridge where you have proper control over each transistor, and the best way of doing that is with discrete transistors (MOSFETs are best).

The important thing to remember though is than no transistor ever turns off or on instantaneously - so you have to add a "dead zone" into your waveform. Turn one pair of MOSFETs off, then wait a moment, before turning the other pair on. Otherwise you get a brief overlap in the switching where massive currents can flow straight through everything as all the MOSFETs are turned on (or partially on) at the same time.

Some microcontrollers have programmable dead zones in their PWM outputs, but I am not sure if the AVR chips do - you'll have to check the datasheet - but it's not too hard to arrange a suitable waveform in software or using timers and interrupts (you could look at the tone() function and support code for some ideas for the latter).

The programming sequence, if you have 4 outputs H1/H2/L1/L2 for the HIGH and LOW sides of the H bridge pairs 1 and 2, would be:

  1. Turn on H1 and L2
  2. Pause
  3. Turn off H1 and L2
  4. Brief Pause
  5. Turn on H2 and L1
  6. Pause
  7. Turn off H2 and L1
  8. Brief Pause
  9. Repeat

You haven't specified what your load is, but with an H-bridge it is important to remember that the output is not referenced directly to ground but ground alternates from side to side. If you want to properly isolate it from the Arduino ground a transformer can be used as the load to the H-bridge then use the output of the transformer to drive your real load. You can also use the transformer to change the output voltage (the ratio of windings is the same as the ratio of input to output voltage - so a 1:1 winding transformer will give the same voltage out as it gets in).


  • "Negative" only that the current flows the opposite way through the load, not an actual negative voltage WRT to Arduino GND.
2
  • Thank you so much for this comment! I have some quick questions and (i plan to really read about H-Bridges today). Unfortunately, at this moment the load is not clear to me... 1. Do you know if tone() supports dead zones in its PWM? 2. Should i stay away from ready solutions (like the L298) and rebuild the H-Bridge myself? If yes, i should make sure that the MOSFETS are within operating voltage right (36V)? 3. In the H-Bridge scenario, the initial pulse is PWM or constant voltage that the H-Bridge reverses polarity, and thus it creates an AC PWM? If it's PWM, should the frequency be double Oct 17, 2022 at 22:42
  • of what i want? 4. How do i then step up the voltage to 36V (in both rails)? Does this come from the H-Bridge input? If yes, can i use a step down converter to use mains voltage to 36V that will feed the H-Bridge? Something like this perhaps? amazon.in/Electronicspices-LM2596-voltage-regulator-1-3-37V/dp/… Oct 17, 2022 at 22:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.