How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Hi all,
I habe telemetry to get the RPM of the motor of a ship-model. My idea ist to implement a pid-controller for the RPM of the motor. The Input gives the setpoint and the telemetrie measured RPM the process value. With a mixer it is easy to implement the proportional part, but how to differentiate and integrate the feedback error?
Any ideas.
Yes, and I know that there is a substantial dead time in the control-loop.
I habe telemetry to get the RPM of the motor of a ship-model. My idea ist to implement a pid-controller for the RPM of the motor. The Input gives the setpoint and the telemetrie measured RPM the process value. With a mixer it is easy to implement the proportional part, but how to differentiate and integrate the feedback error?
Any ideas.
Yes, and I know that there is a substantial dead time in the control-loop.
Re: RE: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Radio type?wilopaan wrote:Hi all,
I habe telemetry to get the RPM of the motor of a ship-model. My idea ist to implement a pid-controller for the RPM of the motor. The Input gives the setpoint and the telemetrie measured RPM the process value. With a mixer it is easy to implement the proportional part, but how to differentiate and integrate the feedback error?
Any ideas.
Yes, and I know that there is a substantial dead time in the control-loop.
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Ok, thanks! But you don't have to do that: a lua telemetry script for the PID-controller ist not the problem for me
I just want to ask if the is something built-in to openty that I could use.
I just want to ask if the is something built-in to openty that I could use.
Re: RE: Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Well, no. Dont think so.wilopaan wrote:Ok, thanks! But you don't have to do that: a lua telemetry script for the PID-controller ist not the problem for me
I just want to ask if the is something built-in to openty that I could use.
Would be fun to see if it could be done by only mixers.
Did a swash ring with only mixers once. Had to use a curve to get a sqrt function in opentx. But doable.
Lol.
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
With mixers only I think it would be impossible because you have to use a time delay to realize the differential or integral part.
I you have further ideas, don't hesitate to post them
I you have further ideas, don't hesitate to post them
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Between the slow and multiply in mixer it should be possible to do something...
Re: RE: Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Been busy with it.Kilrah wrote:Between the slow and multiply in mixer it should be possible to do something...
Seems possible. Got already a nice dampened oscillator.
Figuring out if I can check if it's working correctly.
Fun project.
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Oh, very cool! Would be glad to hear more ... this week I'am busy at bussiness.
Thanks!
Thanks!
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
How about this
used a throttle as output parameter, with weight, offset (simulated load) and delay on this throttle as resulting RPM to match the set RPM.
Don't get any effect from the D parameter, but I might have made a mistake.
SA down to trigger.
Use the output monitor to check the effect of the SB switch setpoint step changes for desired RPM. The outputs are all named.
I had to trick some stuff to get a diff measurement set up.
LS, S1 and S2 to adjust P, I, D
RS for load
OTX attached. Taranis XD9+ 2.2.4
- Attachments
-
- PID.zip
- (868 Bytes) Downloaded 212 times
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Well, just had a quick look at your solution.
One question, because I could not get it on the first glance: how do you compute the integration, that is the sum of the error over time?
One question, because I could not get it on the first glance: how do you compute the integration, that is the sum of the error over time?
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Ah yes!
So the value of an input/mixer for t(n) is always based on another value for t(n-1)?
So the value of an input/mixer for t(n) is always based on another value for t(n-1)?
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Well, that is tricky to say.
But to not even bother about that, I just put every mixer Inthe order if calculation.
So first the current error.
That's simple.
But then, I need the current error minus the last error. In order to force this without your assumption, because I tried some and it didn't work, I created a ls that flips between calculation cycles. It will switch where the current error is stored, error1 or error2. This means that the diff between error1 and error2 is always the diff between the old and the new error, just with the sign flipped. Happens that this ls is also flipping sign so use that to get the diff properly.
The diff and the prop are multiplied by their P and D factor directly.
The int cannot use that, since it needs the 'raw' int in the next cycle. It is done in the output on line 1 instead, and then has the prop and diff added there.
You can test diff and int behaviour by making the setpoint fixed and have the rpm either be 0 weight and offset 1% (int testing) or make the rpm be itself with addition of 1%.
Hope this helps.
P, I, D values are not properly time scaled off course!
But factors are factors. Tune them.
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Next question: using the companion, how to simulate 2 or more RPM sensors.
When I start the simulation, there is only one RPM Sensor, but I need of course a second. How can I add a second one?
Thanks.
When I start the simulation, there is only one RPM Sensor, but I need of course a second. How can I add a second one?
Thanks.
Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Not possible at this point.
Re: RE: Re: How to make a PID-Controller: control the throttle (ESC) for a given RPM (governor)
Don't get your point?wilopaan wrote:Next question: using the companion, how to simulate 2 or more RPM sensors.
When I start the simulation, there is only one RPM Sensor, but I need of course a second. How can I add a second one?
Thanks.