How do you restart a PID controller that has been stopped because of a scan time error or switch off the scan time monitoring?
When the scan time is exceeded, the PID controller automatically switches from "active" to "inactive" mode. You can change this behavior by proceeding as described below:
- Switch off the scan time monitoring function.
- Manually restart the PID controller.
Switch off the scan time monitoring function
|No.||Switch off the scan time monitoring function|
|1.||Switch off the scan time monitoring|
Disable the "sb_EnCyclMonitoring" bit of the PID controller before calling the PID controller block for the first time:
This switches off the scan time monitoring function.
Insert the "PID_sample_mon" function block (FB)
|3.||Connect the "PID_sample_mon" function block (FB)
|Reset_counter||Boolean||Set this input to reset the counter.|
|Max_sample_time||Time||Threshold in milliseconds, which should not be exceeded. Normally this is the doubled cycle time of the cyclic interrupt.|
|Counter_1||Integer||This output shows the number of times the scan time was exceeded.|
Restart the PID controller manually
If your PID controller switches to the "Inactive" mode due to the scan being exceeded, you can restart it manually.
- In the "Inactive" mode, the control value (output value) is always zero.
- Interim values of the controller are reset in "Inactive" mode.
|No.||Manually restart the PID controller.|
|1.||Insert the "PID_restart" function block (FB)|
Insert the "PID_restart" FB from the attached library.
|2.||Connect the "PID_restart" function block (FB)|
Connect the contacts as shown in Fig. 04.
Reset the PID controller
Contacts of the "PID_restart" function block (FB)
Ensure that you use the variables, which are shown in the "Required variable" column of Table 04.
|Contact||Required variable||Data type||Description|
|Reset||("Reset" (M12.0), for example)||Boolean||Enable the contact to restart the PID controller.|
|PID_ENO||("PID_ENO" (M12.3), for example)||Boolean||Shared signal. Connect this to an output coil at the "ENO " contact of your PID block call.|
|Error||"PID_Compact_DB".Error||UDint||Error code of the PID controller.|
|InternalReset||("InternalReset" (M12.1), for example)||Boolean||Shared reset signal. Connect this to the "Reset" contact of your PID block call.|
|sRet.i_Mode||"PID_Compact_DB".sRet.i_Mode||Int||Assigned operating mode of the PID controller.|
|State||"PID_Compact_DB".State||Int||Current operating mode of the PID controller.|
The scan time (ts) is calculated once when the PID controller is launched ("Inactive" -> "Active mode") and stored as the "Current Mean Value" (ts mean). While the PID controller is in "Active mode" the scan time is monitored by the OS. In case the current scan time exceeds the value of two times the current "Mean Value", the PID controller mode changes automatically to "Inactive".
Since cyclic interrupts of the same type are executed in the order of their occurrence, other cyclic interrupts can cause the scan time limits to be exceeded.
More information about the PID controller is available in the STEP 7 Basic software help. Enter the keyword "PID".
- Ethernet cable
- STEP 7 Basic V10.5
This entry is based on the PID Compact Controller V1.0. This is available as a technology object in STEP 7 Basic V10.5 and in STEP 7 V11.
With STEP 7 V11 there is also the PID Compact Controller as from version V1.1 (for firmware versions as from V2.0 of the S7-1200 CPU) with the Reset behavior below:
"A rising edge at "Reset" resets errors and warnings and deletes the I part. A falling edge at "Reset" switches to the mode that was last active."
This means that you no longer need the FB "PID_Restart" in the download for resetting a PID Compact Controller >V1.0.
PID_sample_time.zip ( 428 KB )