Author Topic: diy arduino inverter  (Read 8466 times)

0 Members and 1 Guest are viewing this topic.

Offline noneyabussiness

  • Full Member
  • ***
  • Posts: 155
  • Karma: +7/-0
  • I think it works....
Re: diy arduino inverter
« Reply #15 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  :-\)..

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #16 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.




Offline noneyabussiness

  • Full Member
  • ***
  • Posts: 155
  • Karma: +7/-0
  • I think it works....
Re: diy arduino inverter
« Reply #17 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..

Offline oztules

  • Forum Advisors
  • Hero Member
  • ****
  • Posts: 1177
  • Karma: +105/-8
  • Village idiot
Re: diy arduino inverter
« Reply #18 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
Flinders Island...... Australia

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #19 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

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #20 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.

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #21 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.


Offline oztules

  • Forum Advisors
  • Hero Member
  • ****
  • Posts: 1177
  • Karma: +105/-8
  • Village idiot
Re: diy arduino inverter
« Reply #22 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
Flinders Island...... Australia

Offline noneyabussiness

  • Full Member
  • ***
  • Posts: 155
  • Karma: +7/-0
  • I think it works....
Re: diy arduino inverter
« Reply #23 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. .

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #24 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.

Offline oztules

  • Forum Advisors
  • Hero Member
  • ****
  • Posts: 1177
  • Karma: +105/-8
  • Village idiot
Re: diy arduino inverter
« Reply #25 on: January 30, 2017, 12:46:05 am »
12t to 14t would be my first guess.
It is looking very very promising.


............oztules
Flinders Island...... Australia

Offline Madness

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-0
Re: diy arduino inverter
« Reply #26 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. 

Offline frackers

  • Full Member
  • ***
  • Posts: 239
  • Karma: +9/-0
  • If it moves - computerise it!
Re: diy arduino inverter
« Reply #27 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:
  • the 20KHz PWM is on pin PB1 (Arduino D9)
  • the 50Hz invertion is on pin PD7 (Arduino D7)
  • analog monitor of output volts PC0 (Arduino pin ADC0)
  • analog monitor of setpoint volts PC2 (Arduino pin ADC2)
  • MCP4912 chip select PD2 (Arduino D2)
  • MCP4912 MOSI PB3 (Arduino D11)
  • MCP4912 MISO PB4 (Arduino D12)
  • MCP4912 SCLK PB5 (Arduino D13)
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!

Robin Down Under (or are you Up Over!)

Offline peter

  • Newbie
  • *
  • Posts: 19
  • Karma: +6/-0
Re: diy arduino inverter
« Reply #28 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.