Anotherpower.com Forum

Renewable Energy Questions/Discussion => Automation, Controls, Inverters, MPPT, etc => Topic started by: noneyabussiness on January 06, 2017, 08:21:14 am

Title: diy arduino inverter
Post by: noneyabussiness on January 06, 2017, 08:21:14 am
Hey all,

been playing around with the idea of a Arduino (atmega328p) inverter driver, so here is rough draft 1..

now im trying to fully understand how SPWM works with these inverters so it may be completely wrong, but i took the same approach as i would with "standard" PWM and vary the "duty cycle" of the pulses but use a fixed frequency... AKA modulate the SPWM.... :o.... using both 8 bit timer interrupts as fixed frequency for SPWM and Feedback....

if it is incorrect could someone please explain to me how it does work, in language that us humans talk.. i have read MANY "thesis papers" etc. but im still lost... so i went with my gut and wrote the above...

it uses a fixed table for sine wave however with a little math it scales it down to the feedback line, 20khz carrier frequency, and about 90% (10 bit ADC of course) adjustable (10% - 100%). and "softstart" version 1 .. All mostly configurable...

something OZ explained to me about the EG80010 not having as good Dynamic Range as the PJ boards and i thought i wanted to give it a go coding something similar to the PJ ...

i also have a similar code for the STM32F1 as well and ill post once i know im on the right track.... i just fed both pin 9 and 10 into a poly 4.7uf cap to clean up the sine and it looks good to me (obviously only testing at mo, proper RC or LC filter later).
Title: Re: diy arduino inverter
Post by: frackers on January 06, 2017, 01:44:09 pm
I'd forget the Atmel AVR CPU and concentrate on the STM32F1 as it has MUCH more capable timers including complementary outputs with 'dead time' built into the hardware and more accurate ADC (12 bits and self calibrating).

Being clocked at up to 72MHz (from 16 for the AVR) also helps in having plenty of CPU time to calculate (or look up) the next value to go into the compare registers to adjust the PWM depending on where in the cycle and the load.

The Arduino software for the STM32 is somewhat lacking for 'real time' processing like this so experimenting with the HAL (Hardware Abstraction Level) software will lead to improved performance. STM32CubeMX is a handy tool supplied by ST Micro which will write all the initialisation code (can be quite complex!!) for you and is useful to help visualise the interface from the chip to the rest of the world.
Title: Re: diy arduino inverter
Post by: noneyabussiness on January 06, 2017, 06:49:42 pm
Thx for the feedback, the stm32 arduino is very lacking (no bad blood to Roger,  he and others have done an awsome job) , little documentation and a heap of the features are not supported. .. i really just want to make sure im barking up the right tree first...

And in all honesty the humble 8 bit would be sufficient here, its not an overly fast algorithm needed.. even at 16mhz, 20ms is a long time to do a lot... but i digress. .. also it would be awsome to have a open source avr doing the hard work, guess the nostalgia coming out ::)..
Title: Re: diy arduino inverter
Post by: noneyabussiness on January 07, 2017, 01:43:18 am
in fact the PJ board uses a 8 bit MCU (mc908mr32cfue) :o, which what i have read ,has a strikingly similar datasheet to the avr stuff... only it has two 16 bit timers instead of 1...
Title: Re: diy arduino inverter
Post by: frackers on January 07, 2017, 04:04:46 am
even at 16mhz, 20ms is a long time to do a lot..

Unfortunately you don't have 20ms - the PWM has to be updated at the PWM frequency so in fact you only have 42us to scale the next value (assuming 23.4KHz as per the EG8010) - you can't just use a lookup table directly, you have to adjust it according to load which you calculate by checking the output voltage.

Once I've finished my mesh radio moisture sensor project (that I hope to start when I finish building the new barn), I'm going to have a go myself :)

The waveform generation I think is the easy bit - the tricky one is getting the overall loop gain right to keep a stable output under varying loads and to monitor for over temperature and over current at the same time.
Title: Re: diy arduino inverter
Post by: noneyabussiness on January 07, 2017, 05:09:44 am
If you have a look at the code i have posted, to scale the SPWM is only 1 extra line of code (to percentageish), the second isr takes the actual ADC measurement (which i have sped up, i still dont think overly processor consuming). ... 20ms in a life of a avr is a long time, even if the pwm has to be updated every 50us (20Khz). Over temp and over current also depends how "accurate" and "fast" u want it.. using a interrupt it can be instant (eg.).

Again, i do understand the stm32 would be faster, better etc. But for PJ to implement what they have done with the humble 8 bit seems very doable, and we have seen how powerful they are... anyhoo getting off topic, is the code i have posted roughly what the SPWM is supposed to do??
Title: Re: diy arduino inverter
Post by: frackers on January 07, 2017, 06:15:03 am
I've only had a quick look but I've spotted one problem:

Code: [Select]
  x = sinPWM[i]; // x take the value from vector corresponding to position i(i is zero indexed)
  i = i + 1; // go to the next position
  x2 = x / 100 * feedback; // adjust total to modulate pulse according to feedback...

That third line is a killer - been there, done that!! The 1st 6 values read from the lookup table are all less than 100 and dividing by 100 will  return zero. Evaluation is done from left to right with operators of equal precedence. Putting the "* feedback" first could result in overflow of the 16 bit intermediate value depending on how large the value of 'feedback' gets. That could be overcome by either using a cast to 32 bits or by declaring 'x2' to be 32 bits but that involves a lot of putting stuff on the stack on an 8 bit AVR to free up enough registers to do 32 bit arithmetic.

Because of the potential for overflow I'd also suggest using explicit storage types such as uint16_t, int32_t etc rather than 'int' and 'long int' so it becomes clearer what the size of the operands is.

Don't you just love integer maths!!

Title: Re: diy arduino inverter
Post by: noneyabussiness on January 07, 2017, 06:47:32 am
I will be changing the sine table to a much more appropriate table to include the "lost digits" , int math is fun, except when it truncates important digits :-\

But it that what we are going for, in terms of modulation? ?
Title: Re: diy arduino inverter
Post by: peter on January 17, 2017, 05:33:56 pm
Hi noneyabussiness

I've been doing the same thing that you have, using the ATMega328 and I have got a running prototype working quite nicely.

The reasons why I built this is to explore how a pure sinewave inverter works and the influence of various factors on it's efficiency including
- 1/2 bridge dead time
- SPWM frequency
- SPWM modulation depth
- Mosfet bridge DC bus bulk capacitance
- DC bus supply voltage
- control loop design
and more

I highly recommend the use of a DSO when playing with this stuff.

The inverter uses IR21844 half bridge 2 Amp gate drivers which have variable dead time, taking 3 inputs. First is dead time (from 0.5 to 5 us, set by a trimpot), next is pwm, and the last is enable which is active HIGH.
The code has a soft start and hard stop that only occurs at zero AC voltage output thereby reducing stress on the mosfets.

See attached code and I will detail how it works.

Firstly, you will see two #defines, NPWM is the number of PWM cycles for 1/4 sinewave. I based it all on using a 1/4 wave. This saves memory and it's simple to use symmetry to obtain the other half of the 1/4 wave
PPWM is the PWM clock speed counter.
Next is a 14 bit lookup table of 1/4 sine wave values and a few globals. The table is stored in program memory so it does not chew up all the ram.

The setup() block does a few things, firstly it initialises the working pwm lookup table to zero power, programs timer2 to fire at 100Hz, programs timer1 to fire at
16Meg/NPWM Hz, in this case it will be 20kHz but this can be changed to anything you like. In testing I have run this code at 10, 20 and 40 kHz
but it could be anything (if NPWM = 123, then the SPWM freq would be 12.3kHz). Further setup code initialises a few output pins, counters and flags, disables the arduino clock interrupt (for smoother running of the 20K PWM)
and enables interrupts. These are running at all times. I control the inverter output via the enable signal sent to the mosfet drivers.

Then comes timer2 overflow interrupt code. This creates a 50hz signal by toggling the flag f50, and it outputs the enable/disable signal through pin5.
It resets the SPWM lookup table pointer to the start point and checks for a change in the enable/disable input switch.

timer1 overflow code will toggle the 50hz output pin as needed and update timer1 OCR1A counter appropriately with the first or second part of the 1/4 wave spwm lookup table.

pwm_mod(v) is something you might find interesting. This produces the working lookup table data for SPWM.
The input value is used to scale the sin wave from 0 to maximum. All calculations are performed in 32bit integer.
step 1 calculate the location of the needed value from the sine table
step 2, fetch it from program memory
step 3 scale it, with a result that is converted to 16 bits for storage into working table. And mirror it for the other 1/2 of the 1/4 wave.
The last line tidies up a bit of crap in the middle of the data due to poor programming.

 Next comes loop() where two values are read from ADC inputs.
 ch0 is the inverter output, scaled so that 220VAC = 3.5V DC roughly
 ch2 is the setpoint where I control the output voltage. I like to run it at 220VAC but is can go to anything you want.
 The toroid used in this prototype is a 1500VA unit from an aerosharp and I find it starts saturating at about 235VAC onwards.
 The function of this code block is to update the working lookup table so that the desired AC voltage is maintained.
 I choose to update the table at zero crossing times in the AC wave, so that means it gets updated 100 times a second.
 the variable "uf" is used to flag when to run the update code, and this code only runs if the inverter is enabled.
 
 update code first clears the update flag, then pulls pin6 high to show to the human that it's running this code.
 I use a simple so called "bang-bang" control scheme with a small dead band. I could use PID or something else but first let's crawl before I walk.
 If setpoint is larger than ACV then increase the power level by a small amount. If smaller, decrease by a tad.
 It setpoint is close to ACV then just leave it alone. I found that not using a dead band creates annoying flicker in ACV output when hooked up to lights.
 I then clamp the power level to something that will never cause problems in the integer scale code (and these issues will cause blown mosfets)
 pwr is a float, I obtain my scale factor, call pwm_mod and print a few interesting numbers.
 And pull pin6 low to show the human the job is done.
 
The last code is to give a nice debounced input from a very noisy push button switch.
This gets called 100 times a second. It toggles on and off the inverter.
When changing either on or off it zeros the pwr accumulator, ready for the next soft start.
the variable odis is mapped directly to the IR21844 enable pins and the arduino LED. This is useful and saves me from applying DC bus power
when the inverter is "on". Bad things happen when this occurs.

The control loop is clearly not great. While experimenting with an aliexpress EGS002 based inverter board I found that they take a low voltage sample
of the AC output voltage, rectify it and filter it so that is has very small AC ripple, then this is fed into the EGS002 board, where more low pass filtering occurs
and this nearly DC signal is fed into Vfb pin of the controller.

So it indicates to me the EGS002 based inverters use and expect a DC feedback signal.
The control loop will need to be designed with this slowly changing feedback signal in mind.
Future work on this project will look at filtering of AC feedback, the frequency response of the control loop
and what is really needed from an inverter from a transient response point of view.

The video of oscilloscope traces when operating.
soft start with no load - soft start with test load of 114W - SS with sudden application of load (can see SPWM in lower zoomed view) - Yellow is 50Hz gate drive
Light Blue is output AC volts (100V/div)
other blue is DC bus current (0.041V/Amp)
Pink is 20kHz SPWM gate drive

The DSO screen capture shows the transient behavior when apply the test load. Notice how the voltage drops for one or two cycles then the control loop regains the upper hand.
Title: Re: diy arduino inverter
Post by: eraser3000 on January 17, 2017, 05:57:33 pm
Very cool, very skillful peter.
Title: Re: diy arduino inverter
Post by: MadScientist267 on January 17, 2017, 06:19:26 pm
Very nice indeed. Even got the bench meeting all the insanity requirements ;D

This completely variable PWM base frequency thing catches my attention... Have you guys had any issues with duty jitter on the mega328?
Title: Re: diy arduino inverter
Post by: peter on January 17, 2017, 07:35:40 pm
MadScientist267:
what do you mean by duty jitter?

I know that small changes in pwm duty will make changes in output AC volts.
These small changes in output appear as a flickering light output when fed into incandescent lights.
Even changes from say 220V to 222V and back again will be easily perceived as "annoying" by anybody.

My control loop ensures the output AC volts track closely the setpoint. But nothing is exact in the Real World (tm).
So I implemented a dead-band in the control loop. It effectively thinks "the output is close enough to the setpoint? OK, I'll leave it alone"

I found that having the inverter achieve 222 or 218 when the setpoint is set to 220 is good enough, with the dead band being maybe +/- 2 Volts. In this example, when switching in and out the test load, the resulting output volts might be 218, then 220, 218,220, 222 etc. Just so long as it stays put once within the dead band.
Title: Re: diy arduino inverter
Post by: MadScientist267 on January 18, 2017, 03:43:09 am
My issue is in a slightly different direction, and I won't pollute this thread with all of the nitty gritty details since it's a different class of equipment (but I'll be posting a thread on it specifically soon, so possibly deal with it then)... but it sounds like you've come to the same conclusion I have...

Basically, I'm steering a TL494 based switcher's Vfb (primarily fed the traditional way, via pure analog divider), with filtered PWM -> 0-5V filter/converter... and I notice that output wags around a little and was able to nail it down to the PWM as the root cause (I can set the PWM hard in code and still observe the behavior, so it's not PID oscillation etc etc). If I sub out the PWM 0-5 for a 5k pot, the issue completely goes away. So just wondered if this is also noticed on the mega328, I'm currently using an uno R3.

My answer so far has been basically the same as yours... only translated to how it applies to my situation of course... Using hysteresis keeps the uno from going into oscillation.

I'll leave it there for this thread - definitely want to see how this ultimately comes out because I've got so many things in mind for these cute little controllers it's not even funny, and you guys speak of magic I haven't yet explored (like the arbitrary base PWM frequency etc)... Love this stuff! ;)

Title: Re: diy arduino inverter
Post by: peter on January 20, 2017, 07:33:45 pm
So I have jumped into PID control of the inverter.

The two attached images show transient response when the test load is switched in.
The X axis is time, each tick is 1/100 of a second which corresponds to each control loop cycle.
Red is the setpoint, blue is output AC volts (ch0 and ch2 as seen in the code)
purple is pwm power setting.
green is PID control output, to be added to the pwm power each control cycle.

The first graph shows the bang-bang code response and it takes about 20 100Hz control loops to get back to the setpoint.
Note that is overshoots and rings a little. Ignore the green line, it's junk.

The second graph shows PID control and note the far less overshoot and ringing. The green curve does now show the pwm power setting changes applied to the device. PID seems to be about 5x faster.

I also attach the current version of the code. I now calculate the SPWM values within the 20Khz interrupt service block.
No temporary arrays.
The single statement requires 10us to complete. This means there is now a much lower upper limit on PWM frequency

I welcome any discussion on this. Control theory is beyond my ken.
Title: Re: diy arduino inverter
Post by: frackers on January 21, 2017, 04:43:46 am
Wow - made me realise its nearly 45 years since I studied closed loop systems - Bode plots, Nyquist are just names now. I'lll have to see if any of the brain cells from those days have survived (I doubt it, during the 70s was when I discovered beer, motorcycles and girls!!)

Who would have thought that a 4 year computer engineering course then could be taught without a computer in sight!! (although it did include electrical power, electronic and solid state physics modules)

Title: Re: diy arduino inverter
Post by: noneyabussiness on January 21, 2017, 08:24:20 am
Wow Peter,  just wow. ... im just in the middle of moving at the moment  :'(.. but as soon as i get my workshop back  ( new one yay), i will do some study of the awsome work u have done... i started up the PID road but thought it was "overkill" but you have shown me that very wrong. ... do you get much noise on the input of the adc channel? ?  I had to use a R/C to clean it up a little,  but it still wasnt "fine" .. not sure what that equated to as i haven't had a chance to test with any significant voltage.. ( bought a house and had to start packing  :-\)..
Title: Re: diy arduino inverter
Post by: peter on January 22, 2017, 05:21:58 pm
Hi noneyabussiness

there is a lot of noise on the ADC input from the AC output. I think I could not have made the feedback wiring more prone to picking up noise if I tried. I have about 2 feet of twisted pair wires coiled up and passing by the mosfet bridge board which convey the DC low voltage sample of the AC output to the ADC input pin. I want a bit of noise in fact so it will force me to deal with it in a competent manner.

First I put the DC volts through a voltage divider to give me about 3.5V, then straight into a LP filter (RC). Then the 2 feet of antenna (or cable if you like), then another RC LP filter only 1 inch before the arduino ADC input pin.
This presents a relatively low noise signal ready for sampling.
Initially I only used the first LP filter near the divider, so as to see how much noise I could deal with via digital filtering.
It seems it could handle a lot and remain stable.
The second filter was included because I wanted to see how clean I could get it if I placed it as close as possible to the ADC input.
This has not changed the PID stability much if at all.

The current version of the code without debug printing samples this signal at about 2.8kHz and then applies a moving average filter to the result.
eg
ch0 = tc * (float)analogRead(0)/1024.0   +   (1.0 - tc) * ch0;
where tc is the time constant of the filter and is set to 0.01 in my code and ch0 is the filtered result of sampling ADC channel 0

(After removing the debug print code, the PID became unstable immediately! This didn't break any mosfets - yet. A little
less proportional gain and the PID came good.)

All of these filters have a relatively poor stop band attenuation slope, but since this is a prototype device designed for my education I can live with it's many naive design limitations since these give me so much to deal with and learn from.

There are better digital filters, where "better" means sharper attenuation slopes, more attenuation etc.
My current favorite is the bi-quad Butterworth.
see
http://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/
and
http://www.earlevel.com/main/2012/11/26/biquad-c-source-code/
for some well written explanations and an online toy to play filter designer.



Title: Re: diy arduino inverter
Post by: noneyabussiness on January 23, 2017, 07:30:49 pm
Thank you for your reply, i especially like the calculators (looks like a fun challenge)...

Im looking forward to having a play when we finally finish the grueling task of moving, cleaning etc. I have 6 kids so we have a LOT of stuff...

Glen..
Title: Re: diy arduino inverter
Post by: oztules on January 24, 2017, 03:02:01 pm
Yes that is a huge WOW!..... now when I get time I will have to have a go at this..... just not enough hours in the day at the moment.

Will follow with great interest.


...........oztules
Title: Re: diy arduino inverter
Post by: peter on January 24, 2017, 10:01:45 pm
thanks Oztules

Maybe you are interested in the results of varying the dead time and PWM frequency.
I had a look at idle current and output wave form quality for each combination of
10kHz, 20kHz and 40kHz PWM and 0.5us, 1us and 4us dead time
When changing dead time, I only changed the high frequency part of the H bridge gate driver's setting.
The low frequency half must have an insignificant effect so I left it alone.

The executive summary was for this prototype 0.5us DT and 20kHz was optimal.
Longer DT introduced distortions in the output waveform. 2us DT made for ugly waveforms and a bit of noise from the toroid and choke. I did not want to run it at 4us and 40kHz (or 10kHz) because things were not very happy at all.

The attached photo is my notes from testing. Ignore the "119W load" bit. I only tested idle current.
I recorded output voltage, input DC voltage and DC current.
All tests were with the setpoint potentiometer left at the position that gives 220V AC at 20kHz/0.5us DT
Title: Re: diy arduino inverter
Post by: peter on January 25, 2017, 06:02:44 am
By distorted waveforms I mean this:
first is 0.5us DT @ 20kHz
next is 4us at 10kHz
last is 4us at 40kHz

all at idle current.
Title: Re: diy arduino inverter
Post by: peter on January 26, 2017, 05:34:02 pm
Hi all
I have done some testing with the 3000VA toroid (out of an Areosharp), to see the idle power and if the PID loop control will handle it or not.
As it happens, it can drive this transformer as easily as the smaller one.
Idle current at 30.3V DC is 0.48A, or 14.5W
When I add the small test load of 128W, the DC power IN becomes 150W.
128/150 = 85% efficient, including the idle power. Not bad. (excluding idle power, marginal efficiency is 95% !)

Instead of writing interesting data out the arduino serial port I now write this data out to a DAC, via the arduino SPI bus.
Much quicker. And the bonus is this analog signal can be correlated with other things on the DSO screen.
I used a MCP4912 2 channel DAC for those who may want to know.

See the attached DSO capture showing when I switch in the test load.
4 traces are
dark blue - AC volts output
yellow - DC supply current (again 0.5v/div where 0.5v = 12.2 Amps from the sensor)
pink - PWM duty cycle width
light blue - output voltage measured, after RC low pass and digital filtering of the AC output volts

Notice how the PWM duty remains constant over 1/2 an AC cycle. This is to be expected.
I like how quickly the PID brings the output voltage back to the set point.
one 50Hz cycle of undervolatge, 1 and 1/2 of over voltage and then things settle down.
You can also see the time lag of the output voltage as measured by the arduino compared with the AC volts
(the 4 measured values duy, rms, avg do not mean anything so ignore)

I like this a lot.

Title: Re: diy arduino inverter
Post by: oztules on January 27, 2017, 01:11:25 am
Very impressive recovery... will be on the edge of the seat when the high current stuff is tested.

......oztules
Title: Re: diy arduino inverter
Post by: noneyabussiness on January 27, 2017, 02:30:14 am
Im with u OZ, by memory the eg8010 recovery is 1-3 cycles so at the moment its as good if not better.... very impressed. .
Title: Re: diy arduino inverter
Post by: peter on January 28, 2017, 06:28:34 pm
I tested this contraption with a higher load.
623W (500W halogen work lamp plus the 2 incandescent lights)

The DC supply is two well used Fiamm 100AH ex telecom backup SLA batteries.
I charge these via an unregulated 40V supply using a 35kg 1500VA IE transformer, then into a
Morningstar 60A PWM solar controller. The "charger" works really quite well.

The transformer is the 3000VA Aerosharp with 14 turns for the primary. 6mm2 cable.
I doubled that to 2x 6mm2 and things get a lot better. See image #3, this is the same as #2 but with double the primary cable area.
There was a large voltage drop with only 1 x 6mm2 primary. I wonder if I should try something much bigger....
DC supply voltage at the input leads is 24V-25V
I wonder if this is too many turns for the effective DC supply voltage. What's your thoughts Oztules?

I attach 3 DSO traces.
Pink is pwm power, max power = 4.7V on DSO scale.
light blue is AC output volts as seen by the PID loop after filtering.
Blue is AC output volts.
Yellow is DC current, 2.5V = 60A

The first image is with the charger off. Note how long the pwm stays at maximum. Not enough DC volts.
The DC supply current saturates the current sensor at about 60 Amps.

The next is with the charger on. This reduces the DC voltage sag under load.
Less 100% pwm during the switch-on transient and it has enough room to even overshoot a little (as it should in my opinion)

Last is with charger and 2x primary cable area. Much better. less pwm needed to sustain load and transient response looks nicer too.
Title: Re: diy arduino inverter
Post by: oztules on January 30, 2017, 12:46:05 am
12t to 14t would be my first guess.
It is looking very very promising.


............oztules
Title: Re: diy arduino inverter
Post by: Madness on March 02, 2017, 03:54:03 pm
Nice work, something that would be a very useful addition that the EG8010 can't do is to synchronise to a generator. I have a Trace inverter (built late last century) that does this very well. When the generator starts (which the Inverter can initiate automatically also) the Inverter senses this and has a warm up period set so after say 60 seconds it will then adjust the inverters frequency to exactly match the generator, that is providing it is within 3hz of 50hz. Once the Inverter is completely in sync it closes a 30 amp relay that connects the generator directly to the Inverter output. There is also current sensing of the generator input, this is used to limit the amount of power that can be drawn from the generator to a preset level up to the 30A relay limit. If the generator frequency changes to outside the 3hz limit it disconnects the generator until it is back in that range.  The Inverter then can use the generators full power to charge the batteries and power loads, if the load becomes greater than the generators capability it can draw power from the battery to supplement the generator. There is also battery charging voltage set points etc to manage. Perhaps this is a big task but it would then allow building DIY Inverters that could do everything that the commercials ones can. This would also allow those with grid connection to back feed into the grid if allowed where you live. 
Title: Re: diy arduino inverter
Post by: frackers on March 04, 2017, 11:13:40 pm
Do you have a schematic or at least some documentation of what pins go where?

From the s/w I've determined (I think!) that:
From this I assume you are not driving a full bridge (which requires 4 outputs) or have you got the diagonally opposed sides of the bridge tied together?

If the builders turn up as promised I should have the frame for the new barn finished by the end of the week (the poles have been up a week!!). Next expense will be the concrete floor and the roller doors for 2 of the bays.

New barn = new workshop = somewhere to get a new project going!

Title: Re: diy arduino inverter
Post by: peter on March 07, 2017, 07:25:45 pm
I do not at this time have any drawing or schematic. The best I have is a pencil sketch done on A4 paper and I am embarrassed enough to have admitted that already.
You have worked out nearly all of it. This shows outstanding skills in reading my poorly documented code and I'm sorry to have had to put you through that.
I will try to fill in the details and this is based on a recent version of the code that has DAC output of debugging variables (see attached code)

I use Arduino pin numbers in this discussion.

I use IR21844 gate drive ICs, that take one input and make the high/low gate drive accordingly with zero cross conduction possible.
Arduino pin D9 is fed into pin1 of IR21488 no.1
D7 is fed into pin1 of no.2 driver IC

D7 is driven by software and D9 is driven by Arduino PWM hardware.
I could drive both by hardware but I found no way to have the 50Hz output and 20Khz transition nicely enough.
Software for D7 minimises the time both 1/2 bridges are putting full DC bus power through the primary winding.
The hows and whys are very boring on this, trust me.

Pin2 of IR21488 is shutdown and is active LOW, so I pull this down with a 1KR resistor. Both driver ICs SD pins are connected to D5 on the Arduino.
During Arduino boot up, all output pins are high Z so thay can neither pull UP, nor DOWN.
IR21844 SD pins have an internal PULL UP !! so thay need to be pulled DOWN by default, hence the 1KR resistor.
 
I have one IC for the 50Hz, and the other for the 20KHz. I socketed these ICs and this allows swapping after destruction.

SO far
D7 - 50Hz drive
D9 - 20KHz
D5 - drive output enable, HIGH = enable, LOW = disable

SPI is used only for debugging. I output interesting values via SPI to a DAC so I can easily closely correlate events and program operation.
I drive the SPI pins CS and DAC data LATCH manually but use Arduino SPI library for TX.

A0 is Vfb. I have a lowpass filter attached right at the pin of A0, using 0.1uF Ceramic cap and 100R resistor. This makes the LP filtered Vfb DC lag a bit but it's no problem for the PID control loop using the supplied values.

A2 is AC output voltage set point. No external filtering of that is needed.
Digital filtering occurs within the code.

See the datasheet for the IR21844 to determine the external components needed. I used 4.7u Tantalums and stupidly oversized fast diodes. I supply the ICs with 12V from a cheap ebay dc/dc converter altered to use a 60V capable buck switch IC.

The inverter on/off switch is a momentary closed push button with one end to ground and the other to D8.
Code sets up D8 to be input and internally PULLUP.

I have an LED with current limit resistor connected to D13, this will light up when the inverter is running.
It's important to have this since bad things happen when I apply DC power to an already running inverter.
Code for this function is omitted in the attached.

I am driving 2 half bridges - correct.
Trimpots are used to set dead time. I wanted to have the capability to change DT. I have them set to 0R to give 500uS DT for the majority of testing.

D6 is a debugging signal that I drive to show the time spent doing work inside the loop() function.
This is not important for the running of the inverter.

There is a comment about Arduino boot behavior and output ports. I found that you must not use the hardware serial port (eg "Begin.Serial(115200);") since it alters the boot up pull up/down on some pins one of which is the gate drive enable pin.

I connect the outputs of the driver ICs to a standard low frequency inverter mosfet board.
IR21844 pins:
COM goes to DC battery ground
LO goes to low side mosfet gate
Vs goes to low side mosfet drain (which is one of the primary winding terminals)
HO goes to high side gate
Vcc = 12V chip supply
Vss to DC battery ground too. This might be a problem, so far no problem for me but YMMV.
DT to trimpot if want to vary DT, else to Vss for 500nS DT
3 x 4.7 Tantalum caps, 1 x fast diode good for at least 100V

2 ICs means two x connections to mosfet board
In the IR21844 docs, it shows two wires "TO LOAD", this is only used in DC/DC converter applications. We have these two wires joined on the mosfet board.