Help driving a H-Bridge

Hello,
I am building a regulated current psu of a sort... Arduino reeds the output current from a probe, and runs a pid program, setpoint and parameters can be modified via the lcd and buttons, and memorized in eeprom, this part already works. I am strugling with a code that would need to create a pwm sine wave on two channels (one channel per half period).

Goal is that my outputed sine wave built by the bridge will change amplitude depending on the current (sounds weird but i actually have a very good reason for it). The actual bridge is made with IGBT, and I am using a HVbridge driver (that still needs input pulses) and optocoupling because it will work on rectified mains voltage :o don't worry. I wont be needing an output filter i guess because i am driving an iron core welding transformer...

Main problem is the part where the duty cycle needs to change depending on pidout variable.
I was looking at fade example, but it is not sinusoidal...
I am looking for a 50Hz wave basically, but it would be nice to be able to change that as well...

I am new to C and Arduino, and this is probably pretty basic. Would very much appreciate if anyone could at least point me in the right direction, so i can learn faster.

thanks

You are planning to build kind of a variable ratio transformer?

Kind of, that stabilizes welding current automatically. It reeds welding current, and controls low current but HV primary winding voltage. (saves alot of money on parts, tricky to pull off)

Eventually PWM on the primary side may work, so that the sine wave is taken directly from mains and voltage is scaled down by the PWM duty cycle. No guarantee, never tried that myself.

You have a nasty problem. To change from the mains frequency you need to convert it to DC then back to AC. It gets very interesting when you want to change amplitutde. Try this link for some information: Seven Common Ways to Generate a Sine Wave | Nuts & Volts Magazine. The easiest solution for me would be to use a VFD, all the hard work is finished and guaranteed and the output is sinusoidal. If you find one you like contact the manufacturer to be sure it will do what you want. You did not state if it was single or three phase mains, the VFDs can be either. You can use phase control to control the output energy. Be sure to sync with the zero cross of the AC, there are optocouplers designed to do this.
Good Luck & Have Fun!
Gil

I tried with a triac, and it worked flawless with a 2kw toaster, when I swapped it for the welder, poped fuse immediately, the phase difference makes it very difficult because triac stays on, that's why my mentor and I went for the better, inverter option. Yes, I rectified the mains, and am feeding it to 4, 75A IGBTs just in case, in a single-phase design. I am struggling with the code part because I am still far from educated on Arduino code. Also the display takes up manny pins and I am thinking to swap UNO for MEGA, but I really don't want to do that since UNO should be more than capable, the pulse frequency doesn't need to exceed 1kHz for this prototype so I thought even the slow PWM pins should do the job. Basically what's left for me to do is to code the positive PWM sine cycle so that its duty cycle can be varied, so that I can vary the effective voltage supplied to the transformer, then replicate that for the negative half period on a separate channel. I could do it like the fade program, but then I get square wave. If I could get the full VFD action even better, but the frequency, in this case, should not change with voltage, because I am not driving a motor, the two should be able to vary separately from one another. PWM signal from Arduino is fed to the optocoupler that relays it to the gate driver so that when positive channel triggers the coupler, the driver gets signals for triggering the first pair, similar for the second pair. The gate driver IC has delay circuitry inside so I needn't worry much about dead time in the program, but it wouldn't hurt the project just in case. Another option would be to scale the simpler DC bus with fade, and then make a simple sine wave inverter, but that would mean more capacitors, and seems a bit redundant, also that would put the frequency regulation off the table... Any ideas?

DrDiettrich:
Eventually PWM on the primary side may work, so that the sine wave is taken directly from mains and voltage is scaled down by the PWM duty cycle.

Exactly, but not quite direct since I am rectifying

gilshultz:
The easiest solution for me would be to use a VFD

Making one with Arduino so I can tweak it more... VFDs have the habit to make voltage follow frequency so that motors don't burn at low rpm, might be wrong here?
This is my final college project, trying to avoid aftermarket solutions as much as I can

A transformer can draw much current when powered on. With phase control the first contact should be made at maximum voltage, or later.

I don't understand why you rectify first and form a sine wave later. With my suggestion the duty cycle can start from zero, no risk of blowing fuses.

DrDiettrich:
A transformer can draw much current when powered on. With phase control the first contact should be made at maximum voltage, or later.

I don't understand why you rectify first and form a sine wave later. With my suggestion the duty cycle can start from zero, no risk of blowing fuses.

because then i don't have to worry about synchronizing that is kind of difficult with Arduino uno interrupt, and I can use igbts that can turn off at any moment. Inverters usually drive inductive loads so I figured there would be less problems.

Synchronize what?

After rectification you have rectified sine shaped pulses, not a constant voltage. You have to synchronize to the input sine, with matching zero crossings of both the input and output sine.

DrDiettrich:
Synchronize what?

After rectification you have rectified sine shaped pulses, not a constant voltage. You have to synchronize to the input sine, with matching zero crossings of both the input and output sine.

I will look into it more, thanks, but pulses are fine too since the driven coil acts like a filter... detecting input zc to determine when to fire was the biggest problem to achieve in software when i tried with a triac because of interrupt involved while pid and other things are running