PID Program Example

 

 

This sample program takes measurement of the temperature inside a room using the RTD sensor and controls 4 – 20 mA output to keep the room temperature as 20 ºC. The temperature is measured using the channel 2 of the RTD module, and the output of the heater is controlled using the channel 2 of the DA card.

image-20240326-081817.png

         

 

Module Additions

The slot number ‘0’ is PLC-S (CM3-SP32MDT).

The slot number ‘1’ is CM3-SP04EAA while the slot number ‘2’ is CM3-SP04ERO.

 

image-20240326-081838.png

                                     

 

 

 

 

 Descriptions for Additional Modules

As the above PID test is processed, the following modules are used in addition to PLC-S.

Name

Description

Diagram

SP04EAA (D/A)

 

▪ CM3-SP04EAA can perform two channels of each A/D conversion and D/A conversion respectively.

 

▪ Input signals entered as 0~20mA, 4~20mA, 0~5V, -10~10V and 0~10V are converted to digital values from 0~64000 or -32000~32000.

 

▪ The digital values of 0~64000 or -32000~32000 are outputted as the signal in the range of 0~20mA, 4~20mA, 0~5V, -10~10V and 0~10V.

 

▪ The internal digital filtering is processed to obtain a precise measurement value.

 

▪ The averaging process of time and frequency can be applied. The resolution of the digital value can be selected as 1/32000 to obtain a high resolution digital value.

 

 

SP04ERO (RTD)

▪ Temperature converted by platinum RTD (Pt100 or JPt100) is displayed in Celsius and Fahrenheit (ºC,

ºF). The temperature value can be processed as a digital value to one decimal place.

 

▪ The converted temperature data is then converted to signed 14 bit binary data and is processed as a digital value from -192~16191. The temperature input (-200ºC~600 ºC or -50 ºC~160 ºC) is converted to digital output of 0~16000 (-8000~8000).

 

▪ Each channel can detect the exceeded measuring range and disconnection of RTD and cables. Four sensors in addition to Pt100 can be used to connect up to 4 points with one module.

 

▪ EXP LED lights up in normal status and blinks every 0.3 seconds in case of an error. Power LED blinks every 0.5 seconds in case of a communication error with CPU module.

 

 

 

 

 Registering the PID Special Program

PID Special Program must be registered only once for a CICON project, and it can have 32 Loops within one program.

 

 

 

 Configuring the PID Special Program

 

 

 

 

 

Number

Item

       Description        

(a)

Number of Total Loops

Because the system to be controlled is one, select ‘1.’

(b)

Number of Loops

Per Scan

Since the total number of loops is one, select ‘1’ also.

 

(c)

PIDINIT Start Address

Enter the start address in which PIDINIT setting values are stored.

By changing the start address, the device of the setting items get automatically changed.

 

(d)

PIDCAL Start Address

Enter the start address in which PIDCAL setting values are stored.

By changing the start address, the device of the setting items get automatically changed.

(e)

Operation Type

When the manipulated variable increases, so does the measurement value. Therefore, select the forward operation.

 

 

(f)

Sampling Time (Ts)

If it is a system where measurement values are changed sensitively for the change of the manipulated variable, the sampling interval should be set short. For a general HVAC system in which the measurement values are insensitive to changes, the sampling interval can be set about 1 second.

 

(g)

 

Proportional Gain (Kp)

Enter the proportional gain value of the system. If the hunting of the value is severe, reduce the proportional value. In this test, the value is set to 30,000.

 

(h)

 

Integral Gain (Ki)

Enter the integral gain value of the system. If the integral gain value is large, hunting gets reduced but the time to stabilize can be prolonged.  In this test, the value is set to 20.

 

(i)

 

Derivative Gain (Kd)

Enter the derivative gain value of the system. This value is used when there is severe disturbance or a system with a quick reaction. In this test, it is assumed that there is no serious impact of disturbance. Therefore, this value is set as ‘0 (Not Use).’

 

(j)

 

Filter Coefficient (á)

This value configures to what extent the filtering is going to be applied on the measurement values. The closer the value gets to 0, the less the filtering effect is.

(k)

MV Low Limit

Enter the lowest limit of the manipulated variable. The value is set as 0 in this test.

 

(l)

MV High Limit

Enter the highest limit of the manipulated variable. Because it is a system in which the manipulated variable value can be outputted more than a specific value, the MV High Limit is set as 16,000 in this test.

 

(m)

MV Change Rate Limit

Enter the manipulated variable variation rate limit. This value is used to prevent the change of the manipulated variable from occurring suddenly. Since this test requires no specific need to limit on the change of the manipulated variable, the value is set as 16,000.

 

(n)

MV Auto Apply

This value is used when a user wants to keep the MV value when switching from automatic to manual mode. In this test, the value is set as ‘0 (Disabled).’

(o)

SV Transition Step

This value is used to control the time taken to reach the set value. In this test, the value is set as ‘0 (Disabled).’

 

(p)

On/Off Time

This value is used to control on/off time using the MV value. If a value more than 1 is entered for operation, the MV Low Limit and the MV High Limit will be outputted in turn as the manipulated variable. Because this test does not involve On/Off control, this value is set as ‘0 (Disabled).’

(q)

SV(Set Value)

Enter the target value that you want to control. (i.e.) ‘200’ is entered.

(r)

PV(Process Value)

Enter the process value of the control unit. You can configure the ERO module and enter the appropriate values as shown in the below dialog image in order to read the data directly. The memory address is set as ‘2’ in order to detect the temperature value of the channel 2 of the ERO module by reading the value from the current directly. As mentioned above, the Module Slot is set as ‘2’ (ERO module being in the second slot) and the Module Base is set as ‘0’ since there is no expansion base.

(s)

MV(Manipulation Value)

The manipulated variable is the calculated result of the PID operation. You can either get this value by using the MOV command from the external scan program or configuring the DA card directly in order to output the MV value. Enter the value as shown below to use the DA card and to output the MV value directly in this test.

The channel 2’s digital output value (DA) of the EAA module is configured as Memory Address ‘27’ (Please check the buffer memory of CM3-SP04EAA in the HELP file for the detailed information) in order to adjust the temperature value through the current. Also as mentioned above, the Module Slot is set as ‘1’ (EAA module being in the first slot) and the Module Base is set as ‘0’ since there is no expansion base.

(t)

Pvnt(After Filter)

Only monitoring is possible.

(u)

MVman(MV Manual)

Use this value when the manipulated variable value is set to manual mode.

(v)

Auto / Manual Selection

This specifies the initial operating mode. In this test, it is ‘Auto Mode.’

 

 

Writing the Scan Program

This scan program enables channel 1 and channel 2 outputs of the EAA module to operate directly.

Refer to the table below for the input and output signals of the PLC-S (CM3)-SP04EAA-CPU.

 

Signal direction (CPU  A/D, D/A)

Signal direction (CPU A/D, D/A)

Input

Signal Name

Output

Signal Name

X20

 A/D module Ready

Y20

 

X21

 

Y21

X22

 Operating Condition Save Complete

Y22

 Operating Condition Save Command

X23

 CH.1 High Level Alarm

Y23

 DA CH.1 Output Enable

X24

 CH.2 High Level Alarm

Y24

 DA CH.2 Output Enable

X25

 CH.3 High Level Alarm

Y25

 

X26

 CH.4 High Level Alarm

Y26

X27

 

Y27

X28

Y28

X29

Y29

X2A

Y2A

X2B

Y2B

X2C

Y2C

X2D

Y2D

X2E

Y2E

X2F

 D/A Module Error flag

Y2F

 Error Clear Command

 

 

 

Download and Control

 

 

 

The fact that the blue LED of the "PID Loop Initialized"  is turned ON signifies that the program is operating normally.

 

 

Enter the number ‘350’ for the Set Value (SV).

The number ‘350’ signifies 35.0 ºC. When you want to have the value of 45.5 ºC, enter the number '455'.

 

 

 

Using Auto Tune Function

 

The temperature control is possible by using the Auto Tune function. Depending on the response capability of the system, tuning operations can often be time consuming.

Before the tuning operations, be sure to check whether the flag status of the loop is normal.

When the tuning operations are completed, the current value of the proportional, integral, and derivative gain of the loop gets modified.

 

 

 

If you want to cancel the tuning operation, click the button "Stop Tune".

When the Auto Tune function is operating normally, the blue LED of the "Auto-tune Processing" gets turned ON.

The target value should be set in a way that is in line with the operation type. In other words, it should be forward direction when the target value is greater than the current PV.

It should be reverse direction if the target value is smaller than the current PV.

The tuning operation will be automatically completed when the process value reaches about 68 percent of the error between the current PV and the target value.

 

 

Verifying results with a trend graph

 

 

Through the Trend function, it is possible to check the status of the SV (Set Value), PV (Process Value), and MV (Manipulation Value).

In the image above, the red line signifies the SV while yellow line signifies the PV and the green line signifies the MV.

In order to recognize the amount of variation with ease, the max value of the SV and PV is configured as 400. The max value of the MV is set as 17,000.

After the setting value is set as 400, the current value is getting closer to the set value as the temperature changes according to the variation in the amount of MV.

Once the PID program is fully stabilized, the current value and the set value almost remain the same without the difference between each other. When Auto Tuning is completed, you will get a message as shown below.