Skip to content

StControl

Deyan Dobromirov edited this page May 11, 2023 · 41 revisions

What does this extension include?

State controller OOP class that creates LQ-PID controllers with static or dynamic sampling time. They are used generally for every kind of automatic control that is needed in Wiremod. Supports a bunch of general tuning methods, I studied at the university and can be initialized as a relay, linear or power controller. The error E with power P can be any real number. When zero, the output is calculated as relay, when equal to 1, we have the classic PID controller when the power is 2 the error has quadratic relation E^2, 3, for cubic E^3 and so on needed for aero-propeller systems. Negative powers will be treated as error square root E^(-2) = 1/E^2. The user can apply even fractional powers P on each term. The fractional powers can be treated as the numerator is taken as the power and the denominator as a root. However, there is no difference in which operation will be applied first as you have E^(2/5) = sqr5(E^2) = sqr5(E)^2. It has a lot of possibilities. The only limits is your imagination.

What is this thing designed for?

The StControl class consists of fast performing controller object-oriented instance that is designed to be @persistand initialized in expression first() || dupefinished(). That way you create the controller instance once and you can use it as many times as you need, without creating a new one.

What console variables can be used to setup it

wire_expression2_stcontrol_enst > Contains flag that enables status output messages
wire_expression2_stcontrol_dprn > Stores the default status output messages streaming destination

How to create an instance then?

You can create a controller object by calling one of the dedicated creators newStControl below either with an argument of sampling time to make the sampling time static or without a parameter to make it take the value dynamically as some other thing may slow down the E2. Then you must activate the instance setIsActive(1) to enable it to calculate the control signal, apply the current state values setState and retrieve the control signal afterwards by calling getControl(...).

Do you have an example by any chance?

The internal type of the class is xsc and internal expression type stcontrol, so to create an instance you can take a look at the example.

Can you show me the methods of the class?

The description of the API is provided in the table below.

  Instance creator    Out   Description 
newStControl(image) image Creates state controller object with dynamic sampling time
newStControl(image) image Creates state controller object with static sampling time
noStControl(image) image Returns state controller invalid object
           Class methods             Out   Description 
image:dmpInfo(image) image Dumps state controller to the chat area by number identifier
image:dmpInfo(image) image Dumps state controller to the chat area by string identifier
image:dmpInfo(image,image) image Dumps state controller by number identifier in the specified area by first argument
image:dmpInfo(image,image) image Dumps state controller by string identifier in the specified area by first argument
image:dumpItem(image) image Dumps state controller to the chat area by number identifier
image:dumpItem(image) image Dumps state controller to the chat area by string identifier
image:dumpItem(image,image) image Dumps state controller by number identifier in the specified area by first argument
image:dumpItem(image,image) image Dumps state controller by string identifier in the specified area by first argument
image:getBias(image) image Returns state controller output signal bias
image:getControl(image) image Returns state controller automated control output signal value
image:getControlTerm(image) image Returns state controller automated control term signals as vector or array
image:getControlTerm(image) image Returns state controller automated control term signals as vector or array
image:getControlTermD(image) image Returns state controller derivative automated control term signal
image:getControlTermI(image) image Returns state controller integral automated control term signal
image:getControlTermP(image) image Returns state controller proportional automated control term signal
image:getCopy(image) image Returns state controller object copy instance
image:getCopy(image) image Returns state controller object copy instance with static sampling time
image:getErrorDelta(image) image Returns state controller process error delta
image:getErrorNow(image) image Returns state controller process current error
image:getErrorPast(image) image Returns state controller process passed error
image:getGain(image) image Returns state controller proportional, integral and derivative term gains
image:getGain(image) image Returns state controller proportional, integral and derivative term gains
image:getGainD(image) image Returns state controller derivative term gain
image:getGainI(image) image Returns state controller integral term gain
image:getGainID(image) image Returns state controller integral and derivative term gain
image:getGainID(image) image Returns state controller integral and derivative term gain
image:getGainP(image) image Returns state controller proportional term gain
image:getGainPD(image) image Returns state controller proportional and derivative term gain
image:getGainPD(image) image Returns state controller proportional and derivative term gain
image:getGainPI(image) image Returns state controller proportional and integral term gain
image:getGainPI(image) image Returns state controller proportional and integral term gain
image:getManual(image) image Returns state controller manual control signal value
image:getPower(image) image Returns state controller proportional, integral and derivative term power
image:getPower(image) image Returns state controller proportional, integral and derivative term power
image:getPowerD(image) image Returns state controller derivative term power
image:getPowerI(image) image Returns state controller integral term power
image:getPowerID(image) image Returns state controller integral and derivative term power
image:getPowerID(image) image Returns state controller integral and derivative term power
image:getPowerP(image) image Returns state controller proportional term power
image:getPowerPD(image) image Returns state controller proportional and derivative term power
image:getPowerPD(image) image Returns state controller proportional and derivative term power
image:getPowerPI(image) image Returns state controller proportional and integral term power
image:getPowerPI(image) image Returns state controller proportional and integral term power
image:getTimeBench(image) image Returns state controller dynamic process benchmark time
image:getTimeDelta(image) image Returns state controller dynamic process time delta
image:getTimeNow(image) image Returns state controller dynamic process current time
image:getTimePast(image) image Returns state controller dynamic process passed time
image:getTimeRatio(image) image Returns state controller dynamic process time ratio
image:getTimeSample(image) image Returns state controller static process time delta
image:getType(image) image Returns state controller control type
image:getWindup(image) image Returns state controller windup lower and upper bound
image:getWindup(image) image Returns state controller windup lower and upper bound
image:getWindupMax(image) image Returns state controller windup upper bound
image:getWindupMin(image) image Returns state controller windup lower bound
image:getZeroCross(image) image Checks state controller integral zero crossing margin
image:isActive(image) image Checks state controller activated working flag
image:isCombined(image) image Checks state controller combined flag spreading proportional term gain across others
image:isDerivative(image) image Checks state controller derivative enabled flag
image:isIntegral(image) image Checks state controller integral enabled flag
image:isInverted(image) image Checks state controller inverted feedback flag of the reference and set-point
image:isManual(image) image Checks state controller manual control signal flag
image:isZeroCross(image) image Checks state controller integral zero crossing flag
image:remGain(image) image Removes state controller proportional, integral and derivative term gains
image:remGainD(image) image Removes state controller derivative term gain
image:remGainI(image) image Removes state controller integral term gain
image:remGainID(image) image Removes state controller integral and derivative term gains
image:remGainP(image) image Removes state controller proportional term gain
image:remGainPD(image) image Removes state controller proportional and derivative term gains
image:remGainPI(image) image Removes state controller proportional and integral term gains
image:remTimeSample(image) image Removes state controller static process time delta
image:remWindup(image) image Removes state controller windup lower and upper bound
image:remWindupMax(image) image Removes state controller windup upper bound
image:remWindupMin(image) image Removes state controller windup lower bound
image:resState(image) image Resets state controller automated internal parameters
image:setBias(image) image Updates state controller output signal bias
image:setGain(image,image,image) image Updates state controller proportional, integral and derivative term gains
image:setGain(image) image Updates state controller proportional, integral and derivative term gains
image:setGain(image) image Updates state controller proportional, integral and derivative term gains
image:setGainD(image) image Updates state controller derivative term gain
image:setGainI(image) image Updates state controller integral term gain
image:setGainID(image,image) image Updates state controller integral and derivative term gains
image:setGainID(image) image Updates state controller integral and derivative term gains
image:setGainID(image) image Updates state controller integral and derivative term gains
image:setGainP(image) image Updates state controller proportional term gain
image:setGainPD(image,image) image Updates state controller proportional and derivative term gains
image:setGainPD(image) image Updates state controller proportional and derivative term gains
image:setGainPD(image) image Updates state controller proportional and derivative term gains
image:setGainPI(image,image) image Updates state controller proportional and integral term gains
image:setGainPI(image) image Updates state controller proportional and integral term gains
image:setGainPI(image) image Updates state controller proportional and integral term gains
image:setIsActive(image) image Updates state controller activated working flag
image:setIsCombined(image) image Updates state controller combined flag spreading proportional term gain across others
image:setIsDerivative(image) image Updates state controller derivative enabled flag
image:setIsIntegral(image) image Updates state controller integral enabled flag
image:setIsInverted(image) image Updates state controller inverted feedback flag of the reference and set-point
image:setIsManual(image) image Updates state controller manual control signal flag
image:setIsZeroCross(image) image Updates state controller integral zero crossing flag
image:setManual(image) image Updates state controller manual control signal value
image:setPower(image,image,image) image Updates state controller proportional, integral and derivative term powers
image:setPower(image) image Updates state controller proportional, integral and derivative term powers
image:setPower(image) image Updates state controller proportional, integral and derivative term powers
image:setPowerD(image) image Updates state controller derivative term power
image:setPowerI(image) image Updates state controller integral term power
image:setPowerID(image,image) image Updates state controller integral and derivative term powers
image:setPowerID(image) image Updates state controller integral and derivative term powers
image:setPowerID(image) image Updates state controller integral and derivative term powers
image:setPowerP(image) image Updates state controller proportional term power
image:setPowerPD(image,image) image Updates state controller proportional and derivative term powers
image:setPowerPD(image) image Updates state controller proportional and derivative term powers
image:setPowerPD(image) image Updates state controller proportional and derivative term powers
image:setPowerPI(image,image) image Updates state controller proportional and integral term powers
image:setPowerPI(image) image Updates state controller proportional and integral term powers
image:setPowerPI(image) image Updates state controller proportional and integral term powers
image:setState(image,image) image Updates state controller automated internal parameters
image:setTimeSample(image) image Updates state controller static process time delta
image:setWindup(image,image) image Updates state controller windup lower and upper bound
image:setWindup(image) image Updates state controller windup lower and upper bound
image:setWindup(image) image Updates state controller windup lower and upper bound
image:setWindupMax(image) image Updates state controller windup upper bound
image:setWindupMin(image) image Updates state controller windup lower bound
image:setZeroCross(image) image Updates state controller integral zero crossing margin
image:tuneAutoTL(image,image) image Tunes state controller using the method (TL) Tyreus-Luyben auto oscillation
image:tuneAutoZN(image,image) image Tunes state controller using the method (ZN) Ziegler-Nichols auto oscillation
image:tuneAutoZN(image,image,image) image Tunes state controller using the method (ZN) Ziegler-Nichols auto oscillation extended by type: classic, pessen, sovers, novers
image:tuneOverCHRLR(image,image,image) image Tunes state controller using the method (CHR) Chien-Hrones-Reswick load rejection 20% overshot
image:tuneOverCHRSP(image,image,image) image Tunes state controller using the method (CHR) Chien-Hrones-Reswick set point track 20% overshot
image:tuneProcAH(image,image,image) image Tunes state controller using the method (AH) Astrom-Hagglund
image:tuneProcCC(image,image,image) image Tunes state controller using the method (CC) Choen-Coon
image:tuneProcCHRLR(image,image,image) image Tunes state controller using the method (CHR) Chien-Hrones-Reswick load rejection
image:tuneProcCHRSP(image,image,image) image Tunes state controller using the method (CHR) Chien-Hrones-Reswick set point track
image:tuneProcIAE(image,image,image) image Tunes state controller using the method (IAE) Integral absolute error
image:tuneProcISE(image,image,image) image Tunes state controller using the method (ISE) Integral square error
image:tuneProcITAE(image,image,image) image Tunes state controller using the method (ITAE) Integral of time-weighted absolute error
image:tuneProcZN(image,image,image,image) image Tunes state controller using the method (ZNM) Ziegler-Nichols plant process