Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:38 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : Various aspects of home brew inverters

     Page 20 of 47    
Author Message
renewableMark

Guru

Joined: 09/12/2017
Location: Australia
Posts: 1678
Posted: 11:08pm 17 Nov 2018
Copy link to clipboard 
Print this post

It's not a big deal, but if there was plenty of resources free then two temp sensors would be nice.
Cheers Caveman Mark
Off grid eastern Melb
 
wiseguy

Guru

Joined: 21/06/2018
Location: Australia
Posts: 1156
Posted: 11:23pm 17 Nov 2018
Copy link to clipboard 
Print this post

  nickskethisniks said   Is there a way I can contribute to this interesting development?

Maybe it's An idea to split the processor load between 2arduino's, one for the metering/interfaces and one for the main program?


That was to be my approach to the inverter software I was going to commission.

I planned to let one micro run the inverter code & do as little else as possible to support that, whilst another micro which could be a simpler & slower micro looked after all the comms, housekeeping & any other boring stuff. In the past I have seen great running code slowly get crippled & compromised as all the bells & whistles are added.

Poida with regard to the zero offset, there are a number of possibilities.
Suppose we use a LEM/Allegro type sensor, first make a decision - is there a need for reading negative or backfeed current, perhaps Mad or Clockman or Warp could offer some guidance here. That determines whether we use a bipolar or unipolar model. Handling the result of that decision determines how we might do offsets. It is a similar result if we use a shunt and whether we want a galvanically isolated current sense or direct connect using a differential amp and whether we want bipolar or unipolar sense.

Once a decision is made what sensor and whether unipolar or bipolar then we can work out an offset method to suit.

I know they are a little dearer but the Dallas DS18B20 temperature sensor allows multiple units to live & communicate on a single micro pin as they all contain unique addresses. Probably better suited to a second micro.....


Edited by wiseguy 2018-11-19
If at first you dont succeed, I suggest you avoid sky diving....
Cheers Mike
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 12:49am 18 Nov 2018
Copy link to clipboard 
Print this post

I have read all above posts and it's great to have continued interest in the project.
Time to give it name? Nanoverter?

Two micros to run the inverter is a good idea.
One running the MOSFET bridge and one dealing with humans.

I would like to divide the work into 2 Nanos. (they are cheap and easy to buy in quantity). Nano-1 and Nano-2.

Nano-1 is to run the inverter MOSFET bridge. It will need Vfb for input, the start/stop signal, via D8 and not a lot else. It will drive the two gate outputs and the gate drive IC shutdown. This output needs to be pulled down to ground via 1K resistor. We can give it AC output setpoint via a trim pot, or use a fixed value
and adjust output voltage via Vfb voltage divider trimpot. OR both.
To remain compatible with EG8010 based inverters, Vfb needs to be 2.5V DC at your
desired AC output voltage.

Nano-2 (or anything else you chose..It's not a design writ on stone)
will drive the Nano-1 start-stop pin, holding it down to ground for about 0.25sec then back to 5V to change states.

It will have the LV cut off, over temp, over current, fan on/off and other functions
and drive the LCD.
Inputs will be Fvb (twinned to both Nano-1 and Nano-2. This removes the need for Nano-1 to communicate anything), DC V, DC I (current), temperature sensors (heat sink and transformer), emulated serial port via USB and others which we will dream up.

I think I prefer the LCD to be driven via digital pins directly, not I2C or SPI
There is something spooky going on with my current code as it talks via I2C to the LCD display e.g. I send "220" but I display "210". WTF? You might have seen this in the last video.

Adding WIFI to nano-2 is possible but we might need a uC (microcontroller) with more resources for that. The protocol I prefer is UDP because I like stateless protocols.

With my system I will build, the USB serial port will be all I need, it will be connected to a raspberry Pi which as present handles all executive decisions of my solar power system.

I envisage 2 Nano uCs, placed side by side.
I expect Nano-1 code to become mature very quickly and remain loaded and running without modification within a few development cycles.

Nano-2 on the other hand will be at the mercy of every man and his dog.
I would like to provide a basic code for Nano-2 that will give menu setup,
use a 20 x 4 line LCD if present, provide running information when queried via the serial port. It will receive inverter on/off control from the host system via USB serial port.
We will need the human controllable on/off switch going into Nano-2 now.

I will start work on the two firmwares immediately, initially they will be completely based on the current code. We then extend functionality from there as desired.
I can test this with the two Arduino Uno boards I have here at home.


wronger than a phone book full of wrong phone numbers
 
Mulver
Senior Member

Joined: 27/02/2017
Location: Australia
Posts: 160
Posted: 02:01am 18 Nov 2018
Copy link to clipboard 
Print this post

Loving the progression! Is there enough provision for 3phase on Nano 1 in the future now tasks have been separated?
 
tinyt
Guru

Joined: 12/11/2017
Location: United States
Posts: 438
Posted: 02:48am 18 Nov 2018
Copy link to clipboard 
Print this post

And so the Nanoverter is born.

Attached is a schematic for Nano-1 for review/comments/etc.
2018-11-18_124700_NANOVERTERdraft1.pdf
What I did is just delete unwanted components in the earlier schematic.
 
wiseguy

Guru

Joined: 21/06/2018
Location: Australia
Posts: 1156
Posted: 04:23am 18 Nov 2018
Copy link to clipboard 
Print this post

Thinking about turn on turn off from 1 pin & where we are heading.

Some have suggested a ramp down to turn off the inverter.

I see no advantage compared to just stopping the code at the next zero crossing ?

I would like to see an instantaneous shutdown (EEK? emergency electronic kill) that stops the output dead in its tracks in the shortest possible time. Perhaps that would also require a recycle of the on off button to restore operation.

A separate input for pause (stop at the next zero-cross and restart with a soft start when pause is removed). Note this will not restart in the case of EEK. Possible usage is for over temperature pause and auto resume.

I dont see that these bells and whistles would compromise the code but Im not a programmer....

It also might allow the PWM Nanoverter to still retrofit (with some extra bits) into existing inverters ?

PS TinyT - can I suggest 470n for the mains zero cross as a starting point. The absolute max current for the opto is 60mA & capacitors are often greater than their stated value so ~ 50mA with 680n might be a bit high.Edited by wiseguy 2018-11-19
If at first you dont succeed, I suggest you avoid sky diving....
Cheers Mike
 
Solar Mike
Guru

Joined: 08/02/2015
Location: New Zealand
Posts: 1138
Posted: 04:58am 18 Nov 2018
Copy link to clipboard 
Print this post

Hey its looking very good, suggestion, the 8 pin IR2184 would perhaps be better replaced by the 14pin IR21844 variant as this allows better grounding and variable dead time control, otherwise you are stuck with a fixed 500ns.

I would also change C11 & 6 to 47uf to give approx 100uf total for the supply of the driver chips


Cheers
Mike
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 06:15am 18 Nov 2018
Copy link to clipboard 
Print this post

  Mulver said   Loving the progression! Is there enough provision for 3phase on Nano 1 in the future now tasks have been separated?


3 phase is possible but with a uC that has more 16 bit timers than Nano/Uno boards.
I did 3 phase using an Arduino Mega board. This uses the Atmel ATMega 1280-16AU
microcontroller.

Easy as.

I made a 3 phase AC driver for some small Mitsubishi AC servo motors.
Low power proof of concept of course.
But it worked fine. I had to hack up something to use the built in position encoder
but once that was done, I put in closed loop control and could move the motor
to any position, just like a stepper motor.

AC 3 phase output is very do-able.
But someone will have to dev up the board to suit, not me alas.

wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 06:19am 18 Nov 2018
Copy link to clipboard 
Print this post

  Solar Mike said   Hey its looking very good, suggestion, the 8 pin IR2184 would perhaps be better replaced by the 14pin IR21844 variant as this allows better grounding and variable dead time control, otherwise you are stuck with a fixed 500ns.

I would also change C11 & 6 to 47uf to give approx 100uf total for the supply of the driver chips


I agree with the above. The IR21844 are $4 - $6 each from RS. Not too bad. I would use the DIP version and use sockets on the board.

wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 06:29am 18 Nov 2018
Copy link to clipboard 
Print this post

  wiseguy said   Thinking about turn on turn off from 1 pin & where we are heading.

Some have suggested a ramp down to turn off the inverter.

I see no advantage compared to just stopping the code at the next zero crossing ?

I would like to see an instantaneous shutdown (EEK? emergency electronic kill) that stops the output dead in its tracks in the shortest possible time. Perhaps that would also require a recycle of the on off button to restore operation.

A separate input for pause (stop at the next zero-cross and restart with a soft start when pause is removed). Note this will not restart in the case of EEK. Possible usage is for over temperature pause and auto resume.


Soft stop was something I liked to see after plenty of bench top experiments that go wrong. The soft stop de-gausses the transformer, in my view.

I do not want to stop the inverter midway into a 1/2 cycle.
This would leave it magnetised to some degree and inductive kick is not to be ignored either.

We need to explore the common emergency situations that require the EEK first before we include it in the code.

1 - over current due to short term high load. Examples might include powering ON large inverter air conditioners, large fridges, and the like.

2 - over current due to continued increase in loading, adding more room lights, the kettle on. Then the toaster. Then a fridge kicks in. This is a gradual rise in current.

I can easily revert the code back to turn OFF at next zero crossing.
There is nothing wrong with that.

I think this subject might remain open for a while as we have a collective think.


wronger than a phone book full of wrong phone numbers
 
tinyt
Guru

Joined: 12/11/2017
Location: United States
Posts: 438
Posted: 08:23am 18 Nov 2018
Copy link to clipboard 
Print this post

Draft 2 for review/comments/etc.2018-11-18_182337_NANOVERTERdraft2.pdf
 
renewableMark

Guru

Joined: 09/12/2017
Location: Australia
Posts: 1678
Posted: 10:21am 18 Nov 2018
Copy link to clipboard 
Print this post

What actually would be protected by an instant stop? (that's a question, not a smart ass comment)

If you have a short/fault somewhere the fets will go pop and the machine is shut down instantly anyway yeah?

Double stacked torroid and Mad power board can handle enormous loads so a over current issue could still be soft powered down safely as could under volt or over temp.

I'm probably missing something, what parts would be saved from an instant stop, if an instant stop wont save the fets, then it's probably pointless, as when the fets go the machine is at an instant stop anyway.
Cheers Caveman Mark
Off grid eastern Melb
 
Mulver
Senior Member

Joined: 27/02/2017
Location: Australia
Posts: 160
Posted: 10:38am 18 Nov 2018
Copy link to clipboard 
Print this post

  poida said  
3 phase is possible but with a uC that has more 16 bit timers than Nano/Uno boards.

Thanks Poida! Edited by Mulver 2018-11-19
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 11:06am 18 Nov 2018
Copy link to clipboard 
Print this post

  renewableMark said   What actually would be protected by an instant stop? (that's a question, not a smart ass comment)

If you have a short/fault somewhere the fets will go pop and the machine is shut down instantly anyway yeah?

Double stacked torroid and Mad power board can handle enormous loads so a over current issue could still be soft powered down safely as could under volt or over temp.

I'm probably missing something, what parts would be saved from an instant stop, if an instant stop wont save the fets, then it's probably pointless, as when the fets go the machine is at an instant stop anyway.


I wonder that too.
my home inverters (the ones that last) do not have over current protection
on the EGS002 boards.
My view is similar to Mark's, the MOSFET bridge if correctly driven will just
take all you can give it, with reason. I limit things with a 63 DC A contact breaker
that is between the battery and the inverter DC bulk caps.

I don't want to force any point of view on this question, it's the question
I want to examine the most: the different failure modes.

wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 11:32am 18 Nov 2018
Copy link to clipboard 
Print this post

Mulver:

I could do a 3 phase version of nano_1 code, which will be compatible with nano_2
if you like. You will have to make a 3 phase driver board, taking one Fvb and outputing
3 of the 1/2 bridge connections (ground, low side gate, V1 and high side gate)

A board for 3 phase will need 6 IR21844, ATMEGA 2560 uC.
How to do Vfb...I suppose just take one phase and sample that.

setup code for 3 timers is
pinMode(46,OUTPUT);
pinMode(5,OUTPUT);
pinMode(11,OUTPUT);
TCCR1A = TCCR3A = TCCR5A = _BV(COM5A1) | _BV(COM5B1) | _BV(WGM51);
TCCR1B = TCCR3B = TCCR5B = _BV(WGM53) | _BV(WGM52) | _BV(CS50);
OCR1A = OCR3A = OCR5A = 1;
ICR1 = ICR3 = ICR5 = PPWM;
TIMSK1 |= (1 << TOIE5);
TIMSK3 |= (1 << TOIE5);
TIMSK5 |= (1 << TOIE5);

not a lot, really. It creates 3 timers, firing at 20 kHz, with outputs
of each individual duty cycle appearing on pins 46, 5 and 11

The gate drive part of the code is ridiculously simple

when any timer fires, update duty % with new duty %
the array l[] contains 360 duty cycle % values, following a sine wave

ISR(TIMER3_OVF_vect)
{
OCR3A = l[p2count];
}

ISR(TIMER1_OVF_vect)
{
OCR1A = l[p1count];
}

ISR(TIMER5_OVF_vect)
{
OCR5A = l[p3count];
}

here I create the 3 sine waves, each 120 deg separate

pc = phase count for timer 1, I used as a reference.
pc would be incremented at a rate to give 50Hz.

void do_phase(int pc)
{
p1count = pc;

p2count = pc + 120;
if (p2count >= 360) // getting the wave value 1/3 ahead. need to care
p2count = p2count - 360; // about correct overflow, to wrap the wave form

p3count = pc + 240;
if (p3count >= 360)
p3count = p3count - 360;
}

Stupid easy and fast execution.

wronger than a phone book full of wrong phone numbers
 
Mulver
Senior Member

Joined: 27/02/2017
Location: Australia
Posts: 160
Posted: 11:44am 18 Nov 2018
Copy link to clipboard 
Print this post

Awesome I’ll be saving that info for later use.
Please don’t let me side track the awesome progress any further!
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 11:45am 18 Nov 2018
Copy link to clipboard 
Print this post

  nickskethisniks said   Is there a way I can contribute to this interesting development?
Maybe it's An idea to split the processor load between 2arduino's, one for the metering/interfaces and one for the main program?


It seems you already have, by suggesting a 2 uC system!
Contributions most welcome.
What do yo think you could do?

One thing I would like, if it falls within your skill set, is some
rigorous review of my code, from time to time.

But please if you want, play along at home, running various code, seeing what it does
and hacking some improvements.
wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1418
Posted: 11:53am 18 Nov 2018
Copy link to clipboard 
Print this post

Tinyt:

I thank you again for the design work.
One thing that puzzles me is the mains sync pulse.
It seems to me I will get a low level input at AC zero crossing.
I can't determine which 1/2 of the waveform it is.
I think we get a low level pulse each 1/2 cycle.
This is not enough information to phase lock.

I hope the mains sync feature will only be used in totally isolated
systems. It must never be connected to street power.
Would I be right in thinking mains sync will be used to coexist with
an isolated grid tie inverter system?

wronger than a phone book full of wrong phone numbers
 
tinyt
Guru

Joined: 12/11/2017
Location: United States
Posts: 438
Posted: 06:17pm 18 Nov 2018
Copy link to clipboard 
Print this post

  poida said   Tinyt:

I thank you again for the design work.
One thing that puzzles me is the mains sync pulse.
It seems to me I will get a low level input at AC zero crossing.
I can't determine which 1/2 of the waveform it is.
I think we get a low level pulse each 1/2 cycle.
This is not enough information to phase lock.

I hope the mains sync feature will only be used in totally isolated
systems. It must never be connected to street power.
Would I be right in thinking mains sync will be used to coexist with
an isolated grid tie inverter system?


Attached is revised schematic for review/comments/etc. 2018-11-19_040352_NANOVERTERdraft3.pdf
I have removed the opto sync circuit and retained the isolated transformer circuit with changes. There are no more references to mains. What I was thinking is several slave Nanoinveters or maybe just one sync'ed to a master Nanoinverter.

Here is scope waveform of the EXT_SYNC with the isolated transformer driven at 60Hz. (sorry for the dirty 'scope, I need to clean it). This was taken from my experimental inverter. Note the clamping of the Atmega328 on chip clamp diodes. Based on Atmega328 datasheet I/O pin threshold, it is around 2.6V at VCC of 5V. So I set the cursor to it.


Next picture is with the cursors changed from voltage to time showing delta of about 1.8 (should be around 2.0) milliseconds at the falling and rising voltage thresholds.


Based on Atmega328 datasheet, if you set IECRA bits:
ISC01 = 1
ISC00 = 0
then interrupt will happen at the falling edge. For 60 Hz, if the code wants to know the actual zero crossing, it will happen about 1.0 millisecond after interrupt.

Here are my experimental zero crossing code snippets when I was attempting to do dead time in code un-successfully, and also trying to learn C and the code you earlier shared.

cbi (DDRD,2);sbi (PORTD,2); // setup INTO port for zero crossing sync
sbi (DDRD,3);sbi (PORTD,3); // setup INT1 port for software interrupt



// INT0: rising edge input, INT1: low level (needs DDRD3 configured as output for software generated interrupt)
EICRA |= _BV(ISC01) | _BV(ISC00);
EIMSK |= (1<<INT1) | (1<<INT0);



ISR(INT0_vect) // for optional external sync
{
if (pcount < 10) // arbitrary window
{
if (FundHz == 60)
{TCNT0=FundFx2 + Fudge60Hz;} // add fudge factor
else
{TCNT0=FundFx2;}
pcount = 0; TCNT1 = 0; // reset
}
}

ISR(INT1_vect) // triggered by code in TIMER1_OVF_vect
{
sbi (PORTD,3); // prevent multiple interrupts, turn off trigger
c = (l[pcount] *vpwr ) >> 14; // vpwr scale sin wave by vpwr 32 bit integer calcs.
c2 = c + 1; // dead time for 2LO trailing edge.
if (c2 > PPWM){c2 = PPWM;} // just in case.
OCR1A = c; OCR1B = c2; // update
pcount++;
}


The following is assembler code snippet.

#include "C_ASM_Reg.h"

; Adjust the following Port Pin assignment to match your schematic. Assigned pins must have pull-down resistors (1k to 4.7k)
; Nano D5 (PD5) = SPWMOUT1 (1HI) LF (unipolar paired with SPWMOUT4)
; Nano D6 (PD6) = SPWMOUT2 (1LO) LF (unipolar paired with SPWMOUT3) (shorter hi level duration for dead time)
; Nano D9 (PB1) = SPWMOUT3 (2HI) HF (fixed to OC1A pin) (unipolar paired with SPWMOUT2)
; Nano D10 (PB2) = SPWMOUT4 (2LO) HF (fixed to OC1B pin) (unipolar paired with SPWMOUT1)
;--------------------------------------------------------
.global TIMER1_OVF_vect
TIMER1_OVF_vect:
nop
nop
sbi _SFR_IO_ADDR(DDRB),PB1 // sequence adds 2 cycles
; sbi _SFR_IO_ADDR(DDRB),PB2 // dead time for 2LO
in sreg_save, _SFR_IO_ADDR(SREG)
tst FundFF ; flip-flops at fundamental*2 rate
breq OVF2
; FundFF ne 0, lower PD6, raise PD5
cbi _SFR_IO_ADDR(PORTD),PD6 ; 2 cycles, Fundamental
;; rcall DTDLYO ; 3 cycles. If commented, dead time is system clock(62.5 nSec.) x 2
sbi _SFR_IO_ADDR(PORTD),PD5 ; 2 cycles, Fundamental
jmp FundFFdone
OVF2:
; FundFF eq 0, lower PD5, raise PD6
cbi _SFR_IO_ADDR(PORTD),PD5 ; 2 cycles, fundamental
;; rcall DTDLYO ; 3 cycles. If commented, dead time is system clock(62.5 nSec.) x 2
sbi _SFR_IO_ADDR(PORTD),PD6 ; 2 cycles, fundamental
FundFFdone:
clr FundZeroX
cbi _SFR_IO_ADDR(PORTD),PD3 ; signal mainline's INT1 handler
out _SFR_IO_ADDR(SREG), sreg_save
reti ; done
;---------------------------------------------------------


I wanted to save the few hairs I have left, so I stopped doing dead time in code, also, I realized it is impossible with Atmega328.
Edited by tinyt 2018-11-20
 
renewableMark

Guru

Joined: 09/12/2017
Location: Australia
Posts: 1678
Posted: 08:23pm 18 Nov 2018
Copy link to clipboard 
Print this post

Double stacked torroid with the Mad power board has so much grunt I really couldn't see any need for more power, perhaps some might......... dunno.

What would be handy to use it for would be sync with a 240v generator to back charge the batteries if cloudy conditions are there.
Would that bog down a gen and make it stall though?
That might be a separate project for later.


Cheers Caveman Mark
Off grid eastern Melb
 
     Page 20 of 47    
Print this page
© JAQ Software 2024