poida
Guru
Joined: 02/02/2017 Location: AustraliaPosts: 1421 |
Posted: 01:25pm 10 Jul 2022 |
|
|
|
So I changed SST value from SST = 0 to SST = 100 in the 5th line below headed by ** note: I thought most //comments of 250/251 should have been changed to 1000/1001 ??
that should be fine. sst is the SlowStartTimer counter in the code.
You chose wisely to make the change in the init_vars() block since that block of code also zeros the power factor that modulates the SPWM train of pulses. So when you have changed sst = 100 during init_vars() you will now have a count UP from 100 to 1000 before PID will take over. And when you stop the inverter, it will count down from 1001 to ZERO then disable the gate drive output (D5) and sst will remain at zero and the power factor (a variable named "pwr") will remain at zero.
Changing sst = 200 within init_vars() would be that same as far as I can tell. Only this time it runs up from 200 to 1001, then PID takes over.
Notice that the increments added to "pwr" remain the same, being 1.0/1000.0 This means no matter what value to give sst to start with, we will still see the output PWM duty width AKA "pwr" increase at the same rate.
Now this is where it might become interesting: Should you have a DC supply and toroid wound such that you need more than 0.8 of max PWM modulation then the step change from bang/bang to PID will be abrupt. The steady increment of "pwr" from 0.0 to your AC setpoint will not get there in time before sst = 1001 and PID takes over. Let's say your transformer is wound so that with a 55V DC supply you need "pwr" to be 0.9 to achieve the AC setpoint voltage.
with sst = 100 "pwr" will get to very close to the needed value of 0.9 just before PID takes over. If you start with sst = 200 then at the end, "pwr" = 0.8 and we need it to be 0.9 for the required AC output so the PID code will start with a large error term and so calculate a large correction value and this is what causes large step changes in the primary winding current.
I always want the bang/band control to deliver a close enough value of "pwr" for the transition to PID.
Anyway, what is your DC supply voltage, design primary voltage (AC V RMS please) and AC setpoint voltage? It could be that "pwr" variable does indeed need to be close to 0.9 at steady state..
My inverters are designed for 55V DC supply, 27V AC RMS primary (that is 38V peak to peak) and so gives me a nominal value for "pwr" of 0.69 when at approx 230V AC output.
Also making SST = 200 appeared to make D5 high the second I set D8 to go - from the code I couldn't see why. D5 is pulled high when sst > 0 when sst = 0, D5 is pulled low. You can see this in the loop() code block.
The aim of this is to only have D5 high during soft start, PID control and soft stop. Once the stop is completed, D5 is pulled low
I do not think there is any difference in D5 behavior with different initialisation values of sst.
Obviously it seems my setting to 100 changed something for the better - but what ?
No idea but maybe the bang/bang phase during soft start is the cause of the grunt sound. Maybe you have far less sound once PID is in control. Maybe the least time spent in the bang/bang (i.e. steady, always increasing of "pwr" and therefore PWM duty width) soft start phase the better.
Starting sst = 100 and a steady state "pwr" of 0.9 for your system would mean the soft start would only increase pwr from 0.0 to 0.9, then hover around 0.9 for a very small amount of time the PID switches in to control.
The PID control is initialised to zero values within init_vars() so it will not perform smoothly if given a large error value at the first time it runs. The output of the PID with a large error will be a large correction which will be applied immediately to the SPWM pulse train (i.e. pwr will have a large change in value between control loop runs, which is 10 ms) and I do not want that to happen. Edited 2022-07-10 23:28 by poida |