When using SFCs and SFBs in the Online mode, it might happen that different return values appear one after the other at the "RETVAL" output parameter or the return value changes only briefly, but is then no longer available for evaluation. The sample program below makes it possible to save the output return values consecutively in a data block.
Each new return value is read via the "Ret_Val_Save" parameter of the "Save_RetVal" (FC22) and stored in a variable of the global data block "Store" (DB22). The program also has the following properties.
- Up to 12 input values can be stored. The function and data block can be extended for further requirements so that more than 12 return values can be stored.
- The return value must be greater than zero.
- A new or changed return value is stored in the next DB variable.
- Each address in the data block is reserved for one return value. If an address is already occupied by a return value, the new value is entered in the next DB address.
- No DB variable is overwritten. Only the last DB variable can be overwritten.
- The DB variables retain their values until they are reset to zero with the PLC variable "Reset".
- Once reset, return values can be written to the DB variables one after the other starting at the beginning again.
The attached download contains a STEP 7 project with the blocks described above (FC22, DB22 and OB1). The "Save_RetVal" function contains the German and English comments.
STEP7_V11_SaveRetVal.zip ( 1189 KB )
Copy the "STEP7_V11_SaveRetVal.zip" file into a separate directory and then start the file with a double-click. The STEP 7 (TIA Portal) V11 project is now unpacked automatically with all the associated subdirectories. You can then use STEP 7 V11 to open and process the extracted project.
The following table lists the components that have been used to create this entry and verify the functions described.
||Intel(R) Core(TM)2 Duo CPU P8700 2.53 GHz|
|PC operating system
||MS Windows XP SP3|
|STEP 7 (TIA Portal)
||V11 + SP2|
|CPU 1214C (6ES7214-1AE30-0XB0)
Error information, Error code