Continue to Site

PID control using frequency domain Autosar routine

prairiedog

Full Member level 2
Full Member level 2
Joined
May 16, 2017
Messages
121
Helped
41
Reputation
82
Reaction score
54
Trophy points
1,308
Location
Canada
Activity points
2,329
I'm struggling to code PI control using the frequency domain formula specified by Autosar (AUTomotive Open System ARchitecture).
Taken from Specification of Floating Point Math Routines AUTOSAR CP R21-11 (pg. 48/100)

8.5.4.7.2 ‘PI’ Controller – Type1 with limitation (Implicit type)" [SWS_Mfl_00326].
Yn = Yn-1 + (K * Xn) - (K * (1 - dT/Tn) * Xn-1)

I'm lost with the equation's dT/Tn term. Y is the output, X is the input, K is gain.
Digging as best I can "Structure definitions for controller routines" between many docs gives:
----------------------------
Tn : Follow-up time. Physical unit [sec] describes the Follow-up time.
Tn is expressed in us and have a resolution of 1/10ˆ6
Tn is given by a reciprocal value (Tnrec) to avoid a division in the implementation

The time and time equivalent parameters in the equation / implementation are given
by:
dT : Time step = sampling interval. dT is expressed in us (micro seconds) and shall
have a resolution of 1/10ˆ6.

Tnrec _<size>, Tnrec_C : Reciprocal follow-up time = 1/ Tn. The result shall be Rounded towards Zero.
dT_<size> : Time step = sampling interval [10-6 seconds per increment of 1 data representation unit]
-----------------------------

If my (PI) sample rate is 3Hz or 333msec, then dT is 333,333 [usec].
Tn = "Follow up time" or I've seen it called "follow up time state variable". I don't know what this means.

I keep getting the (1-dT/Tn) term as massive negative value which does not work. Or dT=Tn gives a zero value.

Can anyone offer insight.
 
I'm struggling to code PI control using the frequency domain formula specified by Autosar (AUTomotive Open System ARchitecture).
Taken from Specification of Floating Point Math Routines AUTOSAR CP R21-11 (pg. 48/100)

8.5.4.7.2 ‘PI’ Controller – Type1 with limitation (Implicit type)" [SWS_Mfl_00326].
Yn = Yn-1 + (K * Xn) - (K * (1 - dT/Tn) * Xn-1)

I'm lost with the equation's dT/Tn term. Y is the output, X is the input, K is gain.
Digging as best I can "Structure definitions for controller routines" between many docs gives:
----------------------------
Tn : Follow-up time. Physical unit [sec] describes the Follow-up time.
Tn is expressed in us and have a resolution of 1/10ˆ6
Tn is given by a reciprocal value (Tnrec) to avoid a division in the implementation

The time and time equivalent parameters in the equation / implementation are given
by:
dT : Time step = sampling interval. dT is expressed in us (micro seconds) and shall
have a resolution of 1/10ˆ6.

Tnrec _<size>, Tnrec_C : Reciprocal follow-up time = 1/ Tn. The result shall be Rounded towards Zero.
dT_<size> : Time step = sampling interval [10-6 seconds per increment of 1 data representation unit]
-----------------------------

If my (PI) sample rate is 3Hz or 333msec, then dT is 333,333 [usec].
Tn = "Follow up time" or I've seen it called "follow up time state variable". I don't know what this means.

I keep getting the (1-dT/Tn) term as massive negative value which does not work. Or dT=Tn gives a zero value.

Can anyone offer insight.
If I understood your equation:
Tn is given as reciprocal. Hence the expression dT/Tn becomes dT * Tnrec
 
Last edited:
I recommend for a starting point choose Tn= 10*dT to 3*dT
The reason this is required is because if your sample rate is too slow, an analog integrator would have reached the limit which is just as fatal as you large digital value. It is also a requirement for Nyquist sampling criteria to have 2 samples per sinewave to detect it's presence.

thus dT/Tn <<1 is required. This also transforms into an analog bandwidth with a proportional gain and integrator bandwidth.


I would expect phase lead/lag compensation or Kd gain factors, but I haven't read the spec yet.
 
Tn is simply integration time constant in PI standard form, usually designated Ti. "Follow-up time" sounds strange, no commonly understood term. "Follow-up controller" is however a usual term describing the specific controller form that uses manipulated value Yn as integrator state variable.

I keep getting the (1-dT/Tn) term as massive negative value which does not work. Or dT=Tn gives a zero value.
Means nothing, it's just the specific math how P- and I-term are combined in this controller form, but they can be analyzed separately. I-term must not necessarily derived from Xn-1, more often it uses Xn, see other PI examples in quoted manual.
 
Thanks all for the suggestions. I tried a few values. Then I realized the setpoint is not an input to this differential equation.... So I am now putting the error PV-SP into X.
If dT/Tn is 0.33 and K = 2.0 it appears to behave, that is it doesn't skyrocket over small error. Smaller or larger dT/Tn, order of magnitude then any tiny error causes output values to be crazy high.

But it's so poorly defined I don't think I can use it.
A peer implements Autosar routines for ECU's and tells me how great they are, but won't dig into his (=employer's) code to see how he did it. He uses them for throttle and cruise control, and tells me the integrator windup is better dealt with using freq. domain math and the equations/algorithms are safe, the consortium includes over a dozen car makers. Simpler routines look really good, like the "safe" math routines (no division by zero, no variable overflow/wraparound etc.).
But the documents are unbearable. I'll look if I am missing a definition doc with units etc. but I'm out of time to get this going.

Autosar Structure definitions for controller routines.PNG


Autosar PI controller.PNG
 
I read post #6 so, that a PI controller isn't suited for your control application, or you have at least no idea how to choose Kp and Ti. May be the case but has nothing to do with PI implementation presented in post #1.
 


Write your reply...

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top