A PID (Proportional, Integral, and Derivative) control is possible with the Click PLC. The Click Programming Software version 2.50 now includes PID. This features 8 full-featured control loops with an easy graphical user interface (GUI). PID will run on all of the Ethernet-enabled Click PLCs.
We will be using this PID along with a Factory IO scene to demonstrate PID control and Autotuning using our Click PLC.
Here are some references on PID control:
PID without a Ph.D. By Tim Wescott
Understanding PID in 4 minutes
PID Control – A brief introduction
PID Controllers Explained
Who Else Wants to Learn about On-Off and PID Control?
Our Factory IO scene will be controlling the level of water in a tank. PID will be used to maintain the level based on a dial pot knob on the control panel. Let’s get started!
Previously in this series, we have discussed:
System Hardware – Video
Installing the Software – Video
Establish Communication – Video
Numbering System and Addressing – Video
Timers and Counters
– Counter Video
– Timer Video
Compare and Math Instructions – Video
Program Control Instructions – Video
Shift Register – Video
Drum Instruction – Video
Send and Receive Instructions – Video
AdvancedHMI Communication – Video
Firmware Update – Video
HMI Rotary Encoder Dial Input – Video
High Speed Counters Part 1
– High-Speed Count Mode Video
– Interval Measurement Mode Video
– Duration Measurement Mode Video
– Frequency Measurement Mode Video
High Speed Counters Part 2
– External Interrupt Mode Video
– Pulse Catch Mode Video
– Filter Pulse Mode Video
– Frequency Measurement and High-Speed Count Mode Video
Wiring Stack Light to Click PLC – Video
Wiring Push Buttons and Selector Switch to Click PLC – Video
– Test and Assembly of Push Buttons and a Selector Switch – Video
Wiring an Inductive Proximity NPN PNP Sensor to the Click PLC – Video
Wiring a Capacitive Proximity NPN PNP Sensor to the Click PLC – Video
Wiring an Ultrasonic Proximity Sensor to the Click PLC – Video
– Unboxing our UK1F Ultrasonic Proximity Sensor – Video
Analog Dusk to Dawn Program – Video
PID using Factory IO – Video
The programming software and manuals can be downloaded from the Automation Direct website free of charge.
Watch the video below to see the PID program on our Click PLC controlling the Factory IO tank level scene.
Factory IO is a 3D training software for PLC programming. You can Practice real-world control tasks with more than 20 scenes inspired by common industrial applications. Creating your own training scenarios is also possible by using a palette of industrial parts.
Start Factory IO and select Scenes.
Scroll down to Level Control and double click on this scene. This will now display the level control scene on your software.
Select File | Drivers from the main menu. Alternatively, you could also select F4 to get to the drivers.
Select Modbus TCP/IP Client next to the Driver. This will set up the IO required for the scene that we have just selected. Select configuration from the top-right main menu.
We will use the following parameters for our application. Remember that the Client (Master) will send information and the Server (Slave) will respond to the information sent.
Host – 192.168.1.130
Port – 502 – This is the default port for Modbus TCP
Slave ID – 1
Read Digital – Coils – The Click cannot set an input area as an output. Example: X10 cannot be used as an output. All discrete input/outputs will be in the Y area.
Read Register – Holding Registers – All values used will be in the DS area.
Scale – 100 – Default
Digital Inputs – Offset 8201 – Count 4
Digital Outputs – Offset 8205 – Count 3
Register Inputs – Offset 0 – Count 3
Register Outputs – Offset 3 – Count 4
If we call up the address picker in the Click programming software and select display Modbus address, it will show how we obtained the offset values.
Note: The values are also offset by a value of 1 between the Click PLC and Factory IO.
Here is the DS area of the Click PLC showing the Modbus addresses.
In general here is how the addressing works on standard Modbus.
Discrete Output Coils – 00001 – 09999
Discrete Input Coils – 10001 – 19999
Analog Input Registers – 30001 – 39999
Analog Output Holding Registers – 40001 – 49999
Inputs / Outputs – Factory IO
The Click PLC has fixed Modbus addresses. Modbus addresses are offset by 1 in Factory IO for the Click PLC. The following is a summary of our inputs and outputs to the Click PLC.
Start – Coil 8201 – Click Y10 – Modbus 008202
Reset – Coil 8202 – Click Y11 – Modbus 008203
Stop – Coil 8203 – Click Y12 – Modbus 008204
Factory I/O Running – Coil 8204 – Click Y13 – Modbus 008205
Level Meter – Holding Reg 0 – Click DS1 – Modbus 400001
Flow Meter – Holding Reg 1- Click DS2 – Modbus 400002
Setpoint – Holding Reg 2- Click DS3 – Modbus 400003
Start Light – Coil 8205 – Click Y13 – Modbus 008206
Reset Light – Coil 8206 – Click Y14 – Modbus 008207
Stop Light – Coil 8207 – Click Y15 – Modbus 008208
Fill Valve – Holding Reg 3- Click DS4 – Modbus 400004
Discharge Valve – Holding Reg 4- Click DS5 – Modbus 400005
SP Setpoint – Holding Reg 5- Click DS6 – Modbus 400006
PV Present Valve – Holding Reg 6- Click DS7 – Modbus 400007
Select the Connect button to connect to the Server. You will see the IO light up as the input/outputs are energized. Also, note that the checkmark beside the driver means that we are connected.
Start Factory IO
Our driver has been now selected and configured. We now know the addresses of our application.
Select the play button (right arrow) from the main menu to enable the scene to operate.
We can now operate the panel based on the IO interaction between Factory IO and the Click PLC. Watch the video below to see the level control program in action on our Click PLC.
Click PLC Hardware
Our hardware includes the following:
C0-11DRE-D – Click CPU with Ethernet
Note: Click Ethernet CPU with analog is also available.
C0-4AD2DA-2 – Click Analog Card 4 inputs / 2 outputs
C0-01AC – Click 24VDC power supply
Click PID Setup
Using version 2.50 or higher of the Click programming software, you will now notice the PID (Monitor / Configuration) option under the Navigation window.
If you have a previous version of the programming software you must update the software and firmware.
To start the PID configuration, double click on the PID Setup. You can also use the main menu Setup | PID Setup…
The PID Configuration Mode window will now appear. The PID Loop: PID001 will now be displayed. This is the default name. The block diagram will graphically show you the PID loop that you are programming. Tabs have visual checkmark indications that will be either red, green or yellow. Red means that something is missing or needs to be set in order for the PID to function correctly. Green means that the tab is correctly programmed. Yellow means that this is an optional item.
If you are connected to the PLC then the read and write buttons will then be available.
Read Register Values From PLC – This will read the PID values for the loop from the Click PLC.
Write Register Values to PLC – This will write the PID values for the loop into the Click PLC.
We will leave the PID Loop Name as the default of PID001. The Software will default to automatically assign nicknames to all of the parameters.
We will use the following areas for our PID loop:
C Memory Area (40 consecutive addresses) – C100 to C139
DS Memory Area (15 consecutive addresses) – DS100 to DS114
DF Memory Area (25 consecutive addresses) – DF100 to DF124
Select the Setpoint tab.
Setpoint (SP) Tab
Our Setpoint (SP) will use DF100. We will put upper and lower limits of 1000 and 0 into the loop parameters.
Notice that the actual memory area is displayed for you so these will also be available to you in your ladder logic.
Note: It helps if you review each of the tabs in order for your PID loop.
Select the Error Term tab.
Error Term Tab
Bit C102 will determine if the error squared is on. We will turn this on to lessen the response to smaller error values, but increases the response to larger errors.
We will leave the Deadband off. No control action is taken if the PV is within the specified Error Deadband (DF103) around the SP.
Select the Loop Algorithm tab.
Loop Algorithm Tab
This tab will allow us to set our proportional gain, reset time, derivative gain and sample rate for our PID loop. The Freeze Bias (Anti-Windup) and Derivative Gain Limit can also be set.
Bumpless Transfer will allow us to determine what happens with the loop switches from automatic to manual mode. We will use Mode 2 Forces Bias = Control Output.
The action in our example will be direct-acting. A Reverse acting control loop is one where an increase in the control output results in a decrease in the PV.
Select the Output tab.
This tab will set how our output will respond. In our case, we will limit the output signal from 0 to 35% of the full output. You will also see that we can select the PWM (Pulse Width Modulated) control and then determine the time period.
Select the Process Variable tab.
Process Variable (PV) Tab
A PV Filter can be used to stabilize the signal going back into the PID loop. In our case, we have turned this on and have used 100%. This means that we do not have an active filer for our loop.
Select the Alarm tab.
Process Variable (PV) alarms can be set for High, Low and Hysteresis, Rate of change and Deviation. This tab is optional and alarms can be then programmed in your ladder program or displayed on an HMI.
Our PID loop has all of the information that is required. We will now look at the ladder logic program. We can write the register values to the PLC directly if we are connected or click OK and save the parameters with the program.
The ladder logic and Factory IO scene can be downloaded below.
The main program will start and stop the process. This will control the Factory IO scene based on the IO addressing determined above.
Start and stop the PID loop from the buttons on the Factory IO Level Scene.
C1 is used to start/stop the output of the PID to the fill valve of the Factory IO scene.
Indication lights on the Factory IO panel.
Move the Factory IO panel setpoint dial position into the setpoint display on the factory IO panel.
Move the Factory IO level meter position into the present value (PV) display on the factory IO panel.
Move the setpoint value (SV) and present value (PV) values into the PID loop parameters.
DF108 is the percent output from our PID loop. The range will be 0 to 100. We multiply this by 10 to get our fill valve output range of 0 to 1000 on our Factory IO scene.
When C1 turns on and we are not in auto mode then turn on auto mode.
When C1 turns off and we are not in manual mode then turn on manual mode.
Autotuning PID Loop
To perform the Autotuning of the PID loop you must be connected online to the Click PLC. Then double click on your loop under the PID Monitor. This is located under PID (Monitor / Configuration) in the navigation window.
Tuning Parameters (P, I, D and Sample Time) are calculated according to the Zeigler-Nichols equations. The output will cycle a couple of times as indicated above as the tuning takes place.
Place the PID loop in Manual. Set the PID Parameters to the following.
P – 0.1
I – 1000
D – 0
Sample Rate – 300
Place the loop in Auto mode and hit the Start Tuning button. The loop will return to the auto mode once the auto tuning has completed.
The PID loop will now run with the new tuned parameters. Performing the Autotuning procedure will get the Tuning Parameters close to their optimal values, but additional manual tuning may be required to get the Tuning Parameters to their optimal values.
Watch the video below to see the PID using Factory IO program in action on our Click PLC.
Download the Click PLC and Factory IO Scene programs here.
Click PLC Support Links
The Click PLC can be programmed using free Click programming software from Automation Direct. Here is a link to the software.
The following links will help you to install the software and establish communication.
The entire Click PLC series can be found at the following URL:
Watch on YouTube: Click PLC PID Instruction and Autotuning using Factory IO
If you have any questions or need further information please contact me.
If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII and Floating Point.
To get this free article, subscribe to my free email newsletter.
Use the information to inform other people how numbering systems work. Sign up now.
The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.