Your SICK ID gives you access to our extensive range of services. This includes direct online orders, price and availability checks, and access to our digital services.
*Attention: PS30 is discontinued and not available anymore. There is no direct replacement product. Please contact us if you need further support*
You are familiar to the format length and Q output diagram of PS30 from the webserver (SOPAS air).
Each Q and each length information after a Q have a time stamp in ms.
Method "getFormatLength"
This information is retrieved from the method "getFormatLength". It delivers you the state of the switching output and the detected format length at a certain time stamp. The method should be called cyclically. It will then always transfer as many data sets as switching events happened since the last call (maximum 100).
Unfortunately this sensor method is not in the scope of operation of the provided function block. But the function block has the "FreeCommand" option. Using this we can retrieve the needed information. More information about the "FreeCommand" can be found here: Integration of PS30 - Part3: Function block and usage of FreeCommand
In this Blog I use Siemens TiA Portal to read the format length:
1. First step is the creation of the needed data structure (FormatLengthStruct)
2. Create the data field where the data will be copied to
3. To get the result of the method "getFormatLength" we need to send the command "sMI 31" via the FreeCommand of the PS30 function block.
The answer from the device is then found in the "ResultData" array of the PS30 data structure of the function block.
In the attached excel file you can find some more details on the coding of the answer from the device: PS30_FormatlengthData.xlsx
4. Unfortunately there is a restriction of maximum 299Bytes for the receive array built in into the function block. This is not enough for the "getFormatLenth" method since the result of the method call could deliver up to 101 Q / format length / timestamp data sets. This is more than 900 Bytes. Because of this we need to increase the size of the receive array inside the PS30 function block to 920Bytes:
There is also a test against the size of the array size in step 23 of the function block which needs to be increased:
5. After this the size of the FreeCommand array in the data structure of "ST_SICK_PS30" provided from the function block needs to be increased as well.
6. Now everything should be fine to read the format length data. In my case I had to restart the PLC to establish a new TCP connection. Maybe you have this effect as well...
7. My code to read the format length data cyclically is attached. Roughly what is done:
Function block "PS30_Comm" is called in OB1 (in OB1 additionally the cycle time of the PS30_Comm function block is measured)
Inside "PS30_Comm" the program is controlled with the variable "istep".
Step 1: Starts the program by opening the TCP connection
Step 2: Write the necessary command for the free command of the PS30 function block
Step 3: Start the request. The request to the sensor is triggered by a 1Hz clock.
Step 4: Read values are copied into the new data structure.
Step 99: Is called in case of error.
One question may be left: How often do I need to call the method "getFormatLength" to get all the information?
Here is how to calculate the number of events per second: