×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 42321471, Entry date: 12/04/2012
(0)
Rate

How do you restart a PID controller that has been stopped because of a scan time error or switch off the scan time monitoring?

  • Entry
  • Associated product(s)

Description
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:
  • In the first network of the OB "Cyclic interrupt PID", from which your PID controller is called, you insert a "Reset" output.
  • Assign the "sb_EnCyclMonitoring" bit of the PID controller to the "Reset" output.
    Make sure that the name of your controller is different from the name of the data block in Fig. 01 ("PID_Compact_DB")!

This switches off the scan time monitoring function.


Fig. 01

Note
Disable this function before you call the "PID_sample_mon" function block (see Line 2 of this table).

2.

Insert the "PID_sample_mon" function block (FB)
To prevent the PID controller from stopping you switch off the scan time monitoring function as described in Line 1. However, it is practical to monitor the number of times the scan time is exceeded when a defined limit is exceeded. The "PID_sample_mon" function block from the the attached "PID_sample_time" library is used for this.

  • Download, unpack, and open the attached "PID_sample_time" global library file.
  • Mark the FB "PID_sample_mon" in the "Global library" directory.
  • Drag this FB from the library and drop it in the organization block "Cyclic interrupt PID" (OB200, for example). Make sure that the FB "PID_sample_mon" is called before the FB "PID_compact".


Fig. 02

 3. Connect the "PID_sample_mon" function block (FB)
  • Enter a limit value in milliseconds for the "Max_sample_time" contact.
  • For "Counter_1" add an integer variable that shows how often the scan time has been exceeded.
  • Enable the "Reset_counter" contact to reset the counter.

Note
See the description of the contacts in Table 02.

Table 01
 
Contact Data type Description
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.
Table 02

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.

Notes

  • 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.
  • Download, unpack, and open the attached "PID_sample_time" global library file.
  • Mark the FB "PID_restart" in the "Global libraries" directory.
  • Drag this FB from the library and drop it in the organization block "Cyclic interrupt PID" (OB200, for example). Make sure that the FB "PID_restart" is called before the FB "PID_compact".


Fig. 03

2. Connect the "PID_restart" function block (FB)
Connect the contacts as shown in Fig. 04.
  • Connect a "Pulse" block with the "Reset" contact.
  • Connect the "ENO" contact of the "PID_restart" FB with the "EN" contact of the "PID_Compact" FB.
  • Add an output coil to the "ENO" contact of the "PID_Compact" FB.
  • Connect the "PIDinternalENO" contact of the "PID_restart" FB and the output coil at the "ENO" contact of the "PID_Compact" FB with the same variable (for example "PID_ENO" (M12.3)).
  • Connect the "InternalReset" contact of the "PID_restart" FB and the "Reset" contact of the "PID_Compact" FB with the same variable (for example "InternalReset" (M12.1)).
  • Enable the "Reset" contact of the "PID_restart" FB to set the counter back to zero.
  • Connect the "Error" variable of your PID controller to the "Error" contact of the "PID_restart" FB.
  • Connect the "sRet.i_Mode" tag of your PID controller to the "sRet.i_Mode" contact of the "PID_restart" FB. 
  • Connect the "State" variable of your PID controller to the "State" contact of the "PID_restart" FB.

 
Fig. 04 

Note
See the description of the contacts in Table 04.

3.

Reset the PID controller
Enable the pulse block at the "Reset" input of the "PID_restart" FB to restart the PID controller.

Table 03
 

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.
Table 04

Technological background
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.


Fig. 05

Note
More information about the PID controller is available in the STEP 7 Basic software help. Enter the keyword "PID".

Requirements

  • S7-1200
  • Ethernet cable
  • STEP 7 Basic V10.5

Validity
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 )

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.