
1. Re: Non linear equation
BoTa_264741 Jul 28, 2019 11:41 PM (in response to JoSi_3317786)Equation
Y = 2x  Sin(2x); // Y=1.19
NewtonRaphson iterations
X(n+1) = Xn  Y(Xn)/Y'(Xn)
Starting with approximated Xo~0.2, Yo=1.19
X(n+1) = Xn  (2Xn  Sin(2Xn)) / (2  2Cos(2Xn))
It should converge in 45 iterations, but is not fast due to Sin and Cos calculations.
Is it really necessary to use a nonlinear equations in VFD control?
/odissey1
You may try simplified equation to speedup calculus (unchecked equations):
X(n+1)=
= Xn  (2Xn  Sin(2Xn)) / (2  2Cos(2Xn))
= Xn  (1/4)(2Xn  Sin(2Xn)) / Sin^2(Xn)
Using Taylor series approximation
2x  Sin(2x) = (2x)^3/6 + ...
Sin^2(x)= (x  x^3/6+...)(x  x^3/6+...) = x^2  2(x^4)/6 + ...
= Xn  (1/4)((2Xn)^3/6) / Sin^2(Xn)
= Xn  (1/4)((2Xn)^3/6) / (x^2  2(x^4)/6)
= Xn  ((Xn^3)/3) / (Xn^2  (Xn^4)/3)
= Xn  Xn / (3  Xn^2)
Final
X(n+1) = Xn  Xn / (3  Xn^2)


3. Re: Non linear equation
BoTa_264741 Jul 29, 2019 10:46 AM (in response to JoSi_3317786)JoSi,
Calculations seem to be easy, just set a while loop until X(n+1)X(n) < small_delta.
This is feedforward type of control, it is hard to predict how well it will perform in real application. In some cases, the feedforward control is supplemented with PID feedback loop to account for small inaccuracies. Basically, first calculate new setpoint and apply it as initial value, then let PID to finetune.
Instead, I would rather implement simple PI loop with input parameter as motor frequency and setpoint at 30Hz. Though PIDtype control intended for linear systems, it might work OK if area of tuning is small (e.g. centered at 30Hz)
Check previous discussion on motor control here:
https://community.cypress.com/message/194446#194446
and here:
Re: HELP, with example of frequency measurement Error
/odissey1

4. Re: Non linear equation
BoTa_264741 Aug 5, 2019 8:44 AM (in response to BoTa_264741)1 of 1 people found this helpfulJoSi,
If limit the phase to 8090% of the operational range, the task simplifies. Starting from the equation
and introducing normalized angle X=alpha/PI, and PFC = (V_rms/V_s)^2, we get:
PFC = 1  x + sin(2*PI*x) / (2*PI);
Figure 1. Shows PFC factor as a function of X.
Introducing Q2 = 0.5PFC and X2 = X0.5, the plot becomes centered against (0,0)
Fifure_2. Centered PFC plot.
Now exchange axis to get angle from PFC.
Figure 3. Shows angle (X2) vs PFC (Q2). It is very nonlinear at the edges, but the central 80% portion of Q2 fits well by poly4 function (red line). The curve span 0 to 257, centered at 128 (X=0).
Figure 4. The range can be expanded to 90% with loss of some accuracy (V_chisq ~1E4, still good). Poly5 and Poly6 functions give better precision (chisq~1E5) in same range, but do not let to expand the range  accuracy drops due to highly nonlinear portion of the curve at the end of the range.
The extremes of the range can be processed differently (maybe later).
So, if 8090% is usable, then the recipe is simple:
1. Take desired PFC value and calculate Q2 = 0.5PFC;
2. Calculate X2 using poly4 function.
3. Calculate angle X = X2+0.5.
Calculation should be relatively fast as it needs only ~6 multiplications, about 500 CPU clocks should suffice for the whole procedure. Further speedup can be achieved by making a lookup table for poly function. Let me know if higher order poly coefficients are needed for higher accuracy.
/odissey1

5. Re: Non linear equation
JoSi_3317786 Aug 3, 2019 7:48 AM (in response to BoTa_264741)Thanks one more time, BoTa_264741, you are the man.
I've done a lookup table in excel varying alpha (0 to pi) from 0% up to 100% in increments of 0.01 (gives me 10k values), then used the VLOOKUP function to complete another table to interpolate alpha in 60 values (0 to 60Hz), then used 6th order interpolation polynomial and get a function. I think this gonna work

6. Re: Non linear equation
BoTa_264741 Aug 3, 2019 9:00 AM (in response to JoSi_3317786)JoSi,
I am finally used poly20 to fit whole range to make a lookup table. Good to know that you already passed this point. I see some oscillations on first graph, where did they come from?
I am curious if this equation works at all, since it was derived for the resistive load, not active inductive load like a motor. Please let us know how well this approach worked with a motor.
odissey1

7. Re: Non linear equation
JoSi_3317786 Aug 3, 2019 9:43 AM (in response to BoTa_264741)BoTa_264741, dotted line is from 6th order polynomial interpolation 'fitting' the curve
One more question:
The signals PWM_0 and PWM_180 are going to a H bridge and it's working like a charm, I'm able to vary the frequency output of the WaveDAC_Sine through the DDS32.
If I could change the WaveDAC_Sine amplitude (from 1.020 to 0.2, i.e) my voltage at H bridge will change too, right?

8. Re: Non linear equation
BoTa_264741 Aug 3, 2019 8:58 PM (in response to JoSi_3317786)JoSi,
>If I could change the WaveDAC_Sine amplitude (from 1.020 to 0.2, i.e) my voltage at H bridge will change too, right?
Yes. This is "traditional" way of bridge control using a triangle wave and Comparator. You can find a demo project showing Sine wave amplitude control here:
Audio signal generator: strange noise with headphones, no noise when connected to PC
It uses a custom component WaveGen to feed VDAC with data from RAM buffer using DMA. In essence, it is same as WaveDAC with less overhead.
But...
The output to the HBridge is a digital PWM waveform. It quite wasteful to produce simple PWM output using two analog generators.
/odissey1

9. Re: Non linear equation
JoSi_3317786 Aug 4, 2019 2:09 PM (in response to BoTa_264741)After my H bridge there's an LC filter (fc=800Hz)
"The output to the HBridge is a digital PWM waveform. It quite wasteful to produce simple PWM output using two analog generators."
So, what's the best way to produce SPWM without using two analog generators?

10. Re: Non linear equation
BoTa_264741 Aug 4, 2019 11:13 PM (in response to JoSi_3317786)JoSi,
Attached is example of producing PWM output to Hbridge by directly feeding 60Hz Sine wave from the RAM buffer to the PWM compare1. It uses a custom component (WaveGen), which is nothing but a simple DMA configurator. Attached project has two pages, one is configured for 256 sine points/period and another one is 32 sine points/period (this one is only to clarify signals on the scope). Please enable only one page at a time.
Project uses a cheap rotary encoder to update sine amplitude, phase and frequency. You can disable this functionality and use some fixed values. The WaveGen component is included into the project. Custom libraries (DDS32, QuadDecoder_SW and PSoC Annotation Library) can be downloaded here:
Re: DDS24: 24bit DDS arbitrary frequency generator component
Re: Quad Decoder with Button Switch component for rotary shaft encoders
/odissey1
P.S. Attached is some Phase Controlled Converters educational materials. It has all bunch of equations for PFC control of Resistive, Inductive and Capacitive loads, which may be useful.
Figure 1. Project schematics. Markers (Yellow, Cyan and Fuchsia squares) indicate scope trace color. Notice phase outputs from the PWM (ph1, ph2), which can drive Hbridge directly with deadtime insertion.
Figure 2. Yellow trace  PWM output to the bridge (effective sine wave amplitude +127 with 32 points/period). Cyan trace  WaveGen reference output (60Hz).
Figure 3. KIT059 pins output (uses PSoC Annotation Library)

3 EEE PE.pdf 2.8 MB


11. Re: Non linear equation
BoTa_264741 Aug 5, 2019 8:52 AM (in response to BoTa_264741)JoSi,
I figured out that PWM output waveform may depend on Hbridge driver type. Can you please post the part number for the Hbridge driver used? Also, one should be careful not to exceed Hbridge specs limitations, typically PWM max frequency and turnON, turnOFF time.
/odissey1

12. Re: Non linear equation
JoSi_3317786 Aug 5, 2019 9:26 AM (in response to BoTa_264741)My setup is:
4x MOSFET IRF840
Driver: IR2110
Load: Water pump 220V/200W

13. Re: Non linear equation
BoTa_264741 Aug 5, 2019 11:19 AM (in response to JoSi_3317786)1 of 1 people found this helpfulJoSi,
There is Wiki article re: VFD AC motor control: Variablefrequency drive  Wikipedia
And the PWM output from the project above (yellow trace) looks similar to the Wiki page (pink line).
But...
In the project posted above I used 8bit sine wave centered at 128.
WaveGen_1_CreateSineWave_C(ampl, phase); // Sine wave centered at 128, A(t)=128 + ampl * sine(2*PI* t/T); ampl=[127, +127]
I think that to correctly vary the torque using full Hbridge, the sine wave should be bottomaligned instead, like this:
WaveGen_1_CreateSineWave_B(ampl, phase); // bottomaligned Sine wave, A(t)= 0.5 * ampl * (1 + sine(2*PI* t/T)); ampl=[0, 255]
/odissey1

14. Re: Non linear equation
BoTa_264741 Aug 21, 2019 3:42 PM (in response to BoTa_264741)JoSi,
I found a useful blog about Hbridge controls, which goes into fine details of the subject, discussing various modes of the operation
HBridge Secrets  Modular Circuits
I am also attaching one of the articles discussed there.
/odissey1