Component: Control (DSP)

From Flowcode Help
Jump to navigationJump to search


Author Matrix Ltd
Version 1.2 (Release)
Category DSP


Image Control component

Allows for several types of control operations to be performed on a buffer. On/Off - Standard on off control as used on most overs, toasters, irons. P/PI/PID - Mathematical control process to get to the setpoint as fast as possible, similar to the process in the human brain when steering a car.

Examples

Setpoint = Value that the user wishes the system to be running at. e.g. the temperature control knob for an oven.

Feedback = Measurement to monitor the value we are controlling. e.g. the temperature reading inside the oven.

Control Signal = The value we want to output to the device. e.g. the signal sent to the heat element inside the oven.


On/Off Control

Here is a basic example demonstrating on/off control. FC6 Icon.png On-Off Control If the Setpoint ADC is higher then the Feedback ADC plus the hysteresis value then the output will switch on.

If the Setpoint ADC is lower then the Feedback ADC then the output will switch off.

OnOffControl.jpg


Simulation Models

We have created demo 2nd and 3rd order macros to try and simulate the response of a 2nd and 3rd order system. These macros basically take the value of the feedback potentiometer and then try and adjust this based on how a real world system would perform with the control signal being received. These calculations are necessary for the simulation but the real hardware would do this for you based on the physical response to the control signal.


A second order system is a very basic real world system that can exhibit oscillations and overshoot such as a heat element.

Feedback = ((1 - SndOrd) * Feedback) + (SndOrd * ControlValue)


A third order system is a more complex real world system that is slightly less responsive to the control signal alone such as a motor.

SecondOrderCalc = ((1 - SndOrd) * SecondOrderCalc) + (SndOrd * ControlValue)

Feedback = ((1 - TrdOrd) * Feedback) + (TrdOrd * SecondOrderCalc)


SndOrd and TrdOrd are the coefficients used to tune the response of the system and should be values between 0 and 1.


Proportional Control

Here is a basic example demonstrating proportional control. FC6 Icon.png P Control P control is a very basic form of control which is often used as the calculations are fairly simple.

Error = (Setpoint - Feedback) Control Signal = P * Error


One major drawback of P control is that you will often get an offset between the Setpoint and the Feedback which cannot be removed due to the nature of the second or third order system.


As the setpoint potentiometer is altered the control signal tries to move the feedback to the correct position as fast as possible by creating a spike in the control signal which is equal to the amount of difference between the setpoint and the feedback readings multiplied by the P coefficient.


Here is an example of the 2nd order P control system with a P value of 4.5.

PControl.jpg


Here is an example of the 3nd order P control system with a P value of 4.5.

PControl2.jpg


Proportional & Integral Control

Here is a basic example demonstrating proportional and integral control. FC6 Icon.png PI Control PI control is a slightly more advanced form of control which is often used to improve on the response of the standard P controller.

Error = (Setpoint - Feedback)

Control Signal = P * (Error - Prev Error + (Error / I))


One major upside of PI control is that it will work to reduce the offset between the setpoint and the actual value. One drawback of this is that a badly tuned PI controller will be very unstable due to an effect called integral wind up.


Here is an example of the 2nd order PI control system with a P value of 4.5 and an I value of 2.5.

PIControlT.jpg


Here is an example of the 3nd order PI control system with a P value of 4.5 and an I value of 5.0.

PIControlT2.jpg


Here is an example of the 2nd order PI control system with badly tuned P and I coefficients, notice that the control signal is permanently oscillating.

PIControlU.jpg


Proportional, Integral & Derivative Control

Here is a basic example demonstrating proportional, integral and derivative control. FC6 Icon.png PID Control PID control is again a more advanced form of control which is often used to improve on the response of the standard PI controller.

Error = (Setpoint - Feedback)

Control Signal = P * (Error - Prev_Error + (Error / I) + D * (Error - (2 * Prev_Error) + Prev_Prev_Error))


One major upside of PID control is that it will work to try and predict the system response and therefore provide the optimal control signal to allow the output to reach the setpoint as quickly as possible. One drawback of this is that a badly tuned PID controller will be very unstable due to integral wind up and derivative misguidance.


Here is an example of the 2nd order PID control system with a P value of 2.5, an I value of 1.5 and a D value of 0.2.

PIDControl.jpg


Here is an example of the 3nd order PID control system with a P value of 4.5, an I value of 2.5 and a D value of 0.4.

PIDControl2.jpg


Here is an example of the 2nd order PID control system with badly tuned P, I and D coefficients, notice that the control signal is permanently oscillating and at the point where oscillations can be seen on the feedback signal.

PIDControlU.jpg

Downloadable macro reference

Process

Processes an entire buffer, either by performing the control operation to every value in the buffer or just the last value.

Parameters

INT Setpoint
Value to specify the required control setpoint


Return value

This call does not return a value


ProcessTick

Processes the current value from a buffer.

Parameters

INT Setpoint
Value to specify the required control setpoint


Return value

This call does not return a value


ChangePID

Allows the P, I and D control parameters to be changed on the fly during a program.

Parameters

BYTE Parameter
0 = P, 1 = I, 2 = D
FLOAT Value
New value to assign to the P, I or D parameter


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

Buffer Manager

This property is of type Fixed list of ints and can be referenced with the variable name buffer_manager.

DSP buffer manager to get the buffers from

Feedback

This property is of type Fixed list of ints and can be referenced with the variable name input_a.

Feedback buffer - used to pass the feedback reading into the control algorythm.

Output

This property is of type Fixed list of ints and can be referenced with the variable name output_c.

Output buffer - used to pass the control output values from the control algorythm.

Process

This property is of type Fixed list of ints and can be referenced with the variable name style.

Selects whether to process the entire buffer or just a single value when calling the Process macro

Method

This property is of type Fixed list of ints and can be referenced with the variable name method.

Specifies which control method will be used to process the buffer data

Hysteresis

This property is of type Signed integer and can be referenced with the variable name Hysteresis.

Minimum variation before the output will be allowed to switch state.

Used to avoid high frequency oscillation on the control output.

On Value

This property is of type Signed integer and can be referenced with the variable name on_val.

Value passed to the output buffer when the control output is active or on.

Off Value

This property is of type Signed integer and can be referenced with the variable name off_val.

Value passed to the output buffer when the control output is not active or off.