# Square wave generator with variable frequency and duty cycle

I am in process of converting my DC TIG welder into AC for aluminum welding. I've got H-bridge on the output of the welder and to drive it I am using 2 IR2104 Half-Bridge drivers. For testing I've been using simple NE555 timer to drive H-bridge, but when I change the frequency it also changes the duty cycle, so I have hooked it up to the oscilloscope constantly to monitor the output. I tried using schmitt trigger to generate square wave with variable frequency, then converting it to triangle wave and feeding it into comparator to get variable duty cycle. It works but when the frequency changes so does the triangle wave voltage from almost 0-3Vp-p to as low as 0,5Vp-p or even less. So I've got 2 options:

a) do something about fluctuating triangle wave voltage or

b) build another circuit.

IMO the way of generating the triangle wave and then converting it into square PWM isn't that bad. Other things I tried was using 2 NE555, one driving the other through its trigger input. And second try - generating the triangle wave using op-amps but both methods didn't work out. In summary I need a square wave generator with:

-variable duty cycle 50-95%,

-variable frequency 20-400Hz.

Any clues on how to achieve that are really appreciated.

• The NE555 is in all thinkable ways insufficient to drive a high-powered H-bridge. Adding a second one doesn't make this any better. Buy one of the many PWM controllers, and a gate driver IC for your MOSFETs. Or, instead of an analog controller, use a power-control optimized microcontroller. Jun 28, 2021 at 18:38
• Between the H-bridge and NE555 or whatever is controlling Mosfets are 2 IR2104 Half-Bridge drivers. Forgot to mention that. I just need something to control them. And the second NE555 was there to control the duty cycle, but as I said I didn't work out Jun 28, 2021 at 18:46
• really, the 555 is a shoddy square wave generator, and that by 1980's standards. I don't really think it pays for you to fix your 555 circuitry, here. Jun 28, 2021 at 18:47
• Yeah you're right. That's why I don't plan on using it anymore. I just don't know what I can use instead Jun 28, 2021 at 18:51
• I would suggest checking with your favorite china supplier. You can get a variable frequency/PWM generator starting for less then \$10.00. There is a fairly wide selection and lots of utube demos. You will have to interface the hardware to your system but it appears that would not be a problem fo ryou.
– Gil
Jun 28, 2021 at 19:28

This circuit works along the same lines as your schmitt trigger and triangle-wave generator approach except that in this design the two sections are enclosed in a feedback loop.

The feedback loop means that the Schmitt trigger changes states at the same voltage threshold levels irrespective of changes in frequency. Therefore the triangle-wave output from the integrator remains at a constant amplitude as frequency is varied.

It will probably require some effort to adjust the resistor values and time constant of the integrator to get the right frequency range, trigger levels and PWM percentage.

• Adjusting the components values shouldn't be a problem. I'm gonna test this circuit tomorrow as now it's getting kinda late. I'll post the results. Thanks a lot! Jun 28, 2021 at 20:42
• @AllwinnerA33 It'll probably make life easier if you choose an op amp with equal positive and negative saturation limits or R1 and R2 will need to have unequal values. I think I'd start by choosing a 100k pot for VR1 and then make R3=100k/19 = 5263 so 5k1 and 160R resistors in series. This then won't draw too much current out of IC1a when VR1 is wound right down. Then choose C1 which will be small enough to not be electrolytic. Then set R4 & R5. C1, R4 and R5 values will depend upon the supply voltage and the required triangle wave amplitude. Lastly select the values for VR2, R6 and R7
– user173271
Jun 29, 2021 at 5:09
• I don't have all of the components you listed. I used what I had on hand. For the op-amp I used TL082 and for the comparator LM339. I'll probably change them in the final version for something in SMD package. It'll depend on what I have. As for the resistors and potentiometer I didn't have 100k pot so I've used 500k. The rest of the values I just eyeballed. With these values: C1=44nF, R3=33k, R4=15,6, R5=33k, R1,R2=10k I get nice triangle wave with 5.2Vp-p and frequency 21-410Hz. For now I didn't use R6 and R7. Also I've added some hysteresis to comparator. it works like a charm. Thanks a lot! Jun 29, 2021 at 8:59

There are way more modern ways to make a variable pulse width wave than a 555 these days. Also invest on some serious gate drivers unless you want to burn your bridge: the 555 is limited to about 200mA source/sink. The smaller gate drivers can do 1A peak and there are some with at least 8A peak current (depending on how big your MOSFETs/IGBTs are!)

I have no idea on the criteria for choosing the PWM ratio for a welder… if it's manually chosen you could use a tiny MCU or something like the LTC6992 (in fact the whole timerblox series is suspiciously similar to the various 555 applications). If there is some current or voltage to be kept constant the market is almost overflowing with PWM controllers (some of these with integrated gate drivers)

• I forgot to mention in my post. I am using 2 IR2104 Half-Bridge drivers. Sorry about that. And I know that they aren't the best out there. But on the scope I didn't saw any problems with them. The frequency is manually chosen to make the arc more "focused" and duty cycle for better cleaning action on aluminum. I'm gonna have a look on LTC6992. Thanks for the hint. Also the welding current is not determined by the H-bridge controller. I set it on the welder itself, Jun 28, 2021 at 18:55