Component: PID Control (DSP Operators)

From Flowcode Help
Jump to navigationJump to search
Author Matrix Ltd
Version 1.2
Category DSP Operators


PID Control component

Control algorythm based on Proportional, Integral and Differential error. 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. Used to accurately control things like motors, temperatures etc.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_DSP_PIDControl.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_DSP_PIDControl.fcfx

Detailed description

No detailed description exists yet for this component

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.


Proportional (P) - Provides an instantaneous kick to try and get the control variable to the setpoint as quickly as possible. P control alone will generally always end up with some form of steady state error. If this is acceptable then P control alone is very easy to perform and stable as long as the P gain is not excessive.


Integral (I) - Provides an accumulation of error over time to try and minimise any steady state error. PI control alone can be a very suitable option for controlling a lot of systems. A potential problem with I control is if the control variable goes into saturation and cannot for whatever reason reach the setpoint. This can cause the I accumulator to get larger and larger and then if the saturation is removed the system can become very unstable. Integral clamping allows the integral accumulator to be held within a certain range and avoid excessive windup.


Derivative (D) - Provides a delaying effect when the error is changing fast. This can have the effect of dampening oscillations and allowing the P and I gains to be increased further to provide faster and more stable responses. The D term can be tricky to get right and too much especially when used with a noisy feedback signal can lead to instabilities. The D filter allows for some high frequency noise to be removed from the feedback.


Here is a project file showing an PID control system for a system such as an high accuracy temperature controller e.g. a 3D printer hotend.

The setpoint is set via an analogue input which controls the desired temperature of the system.


In this first example the feedback is provided using the simulated load DSP component which simply takes a percentage of the last output and combines with a percentage of the new output.

This allows easy moddeling of systems such as devices that heat up and cool down over time which allows you to see the system in action.

You assign a setpoint and then the system will get to temperature and then maintain the temperature by automatically adjusting the output duty.

FC6 Icon.png PID Control Simulated Output Example


In this second example the feedback is provided via a temperature sensor component. This shows how you would do it with a real system using a sensor to complete the feedback loop.

FC6 Icon.png PID Control Example


As with other DSP components the raw signals and values can be seen in the data recorder and console windows.








Macro reference

ChangePID

Fc9-comp-macro.png ChangePID
Allows the P, I and D control parameters to be changed on the fly during a program. 
Fc9-f32-icon.png - FLOAT P
 
Fc9-f32-icon.png - FLOAT I
 
Fc9-f32-icon.png - FLOAT D
 
Fc9-void-icon.png - VOID Return


GetPIDPortions

Fc9-comp-macro.png GetPIDPortions
Collects a single contribution from the PID output. 
Fc9-u8-icon.png - BYTE Index
0=P, 1=I, 2=D 
Fc9-f32-icon.png - FLOAT Return


Process

Fc9-comp-macro.png Process
Processes the current value from a buffer. 
Fc9-void-icon.png - VOID Return


ProcessArray

Fc9-comp-macro.png ProcessArray
Processes an entire buffer, either by performing the control operation to every value in the buffer or just the last value. 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Setpoint Connect To
DSP component with output buffer to collect our data from. 
Fc9-type-16-icon.png Feedback Connect To
DSP component with output buffer to collect our data from. 
Fc9-type-21-icon.png Buffer Size
Number of individual elements the buffer can store, default 1. 
Fc9-type-16-icon.png Buffer Type
Sets the buffer data type. 
Fc9-conn-icon.png Control
Fc9-type-16-icon.png Method
Specifies which control method will be used to process the buffer data 
Fc9-type-15-icon.png Proportional Gain (K)
P coefficient used to perform the Proportional gain calculation. 
Fc9-type-15-icon.png Integration Time (Ti)
I coefficient used to perform the Integral calculation in relation to the sample time. 
Fc9-type-15-icon.png Derivative Time (Td)
D coefficient used to perform the Derivative calculation in relation to the sample time. 
Fc9-type-7-icon.png Invert Error
Some systems may require an inverted response. No = Error = Setpoint - Feedback Yes = Error = Feedback - Setpoint 
Fc9-type-15-icon.png Sample Time
Time in seconds between each sample 
Fc9-conn-icon.png Integral Properties
Fc9-type-7-icon.png Integral Clamping
Used to prevent the negative effects of integral windup. Clamps the integral responce between the min and max values. 
Fc9-type-14-icon.png Clamping Max
Maximum value that the integral value can go to. 
Fc9-type-14-icon.png Clamping Min
Minimum value that the integral value can go to. 
Fc9-conn-icon.png Derivative Properties
Fc9-type-7-icon.png Monitor Setpoint
Automatically monitors the setpoint allowing the derivative filter and old error to be cleared whenever the setpoint value changes. 
Fc9-type-7-icon.png Derivative Filtering
Allows the calculated derivative value to be filtered to improve the response and get rid of high frequency noise. 
Fc9-type-21-icon.png Filter Coefficient
Coefficient used to calculate the response of the filter, the higher the value the more filtering is performed