Greetings to all PLC experts! I am currently in the process of measuring the signal propagation time within an S7-1500 PLC. To provide a concrete example, imagine a scenario where a specific condition within the PLC program triggers a boolean signal that is then transmitted to an output (e.g. Q0.1). This signal activates a relay, and the relay's contacts relay this information (ResponseSig) back to the PLC through a designated input (such as I0.1). After conducting thorough research across various online forums, I was able to find a solution that effectively fulfills my objective. It is not imperative for me to obtain an exact time measurement; rather, I am interested in obtaining an approximate estimation. In essence, my goal is to assess the duration required for a signal to travel from the PLC's logic to its output, and subsequently return to the PLC. The current function block implemented for this task is quite intricate, leading me to ponder whether a simpler solution could be devised, perhaps utilizing SCL programming. I welcome any recommendations or insights you may have on streamlining this process. Your assistance is truly valued. Thank you!
Utilize the TIME_TCK block to read the system time and trigger, saving times from both input and output rising edges. By calculating the time difference, you can optimize PLC scan cycle (OBx) execution. In Siemens, scan first inputs, update the process image, execute PLC code, and update outputs accordingly. Select the OB controlling card process image from the IO-card. Assuming a relay delay of approximately 10-20ms. Opt for peripheral IO syntax (IO address: P) for faster IO reads/writes during PLC scan. The process image is not necessary. Consider the following pseudo code: // save system time on pulse IF Input_pulse = TRUE AND Input_pulseOld = FALSE Then input_trig_time := TIME_TCK(); End if // save edge detection bit Input_pulseOld := Input_pulse; // save system time on pulse IF Output_pulse = TRUE AND Output_pulseOld = FALSE Then Output_trig_time := TIME_TCK(); End if // save edge detection bit Output_pulseOld := Output_pulse; // calculate time difference Time_diff := Output_trig_time - input_trig_time ;
I appreciate it, Lare. Your assistance was just what I was looking for. I have attached the SCL implementation as requested.
Pandiani expressed his gratitude to Lare, stating that it was exactly what he needed. The SCL implementation is attached for reference. Consider changing TIME_TCK to read on every scan for potential time savings. This adjustment would involve reading systime once in the code, but whether it is more efficient than reading TIME_TCK directly only at triggers is uncertain. The code snippet below illustrates this concept: IF Input_pulse = TRUE AND Input_pulseOld = FALSE Then input_trig_time :=Systime now;
Hey Lare, initially it may seem like a less efficient implementation to call the system function on each scan and include the extra variable SysTimeNow. However, in my test example, I didn't notice any impact on performance, such as longer scan times.
In a recent conversation, Pandiani discussed the implementation of the system function and the use of the variable SysTimeNow during scans. While this may initially seem like a performance drawback, there was no noticeable impact on scan times in testing. This approach is partially inspired by Siemens' Sitop power supply diagnostic block code (LPSU6200_SignalevaluationS71500 block), which offers a straightforward solution. Despite potential concerns raised by Siemens regarding time accesses on Hot standby CPU systems due to syncronize loads from instructions like RD_SYS_T, WR_SYS_T, and RD_LOC_T, no issues have been experienced with the LPSU6200 and TIME_TCK() executing at 10ms intervals. Therefore, this implementation should work fine for both single CPU and R/H systems.
It's great that you're exploring this, and your approach seems well thought-out. Since you're comfortable with not getting the exact time and only need an approximation, consider introducing a timestamp at both the source and target points. With this, at the source point, acquire the system time and attach it with the triggering signal. In the target point, acquire the system time again once the response is received. You may want to use the "GET_SYSTIME" function which provides time in milliseconds. The difference between the two timestamps will give you the propagation time. This approach, while not delivering an exact measurement, will still be relatively accurate and could simplify the existing function block. Of course, bear in mind that it also depends on how your program is scheduled in the PLC runtime.
Hi there, I appreciate your detailed question. The task you are trying to achieve is indeed relatively complex. If a high degree of accuracy isn't needed, you could simplify the process by continuously checking the status of your output (Q0.1) and input (I0.1) within a cyclic interrupt OB. This way, you could initiate a timer when the output goes high. When the corresponding input is later activated by your relay, you could then save and reset the timer. Remember that this method isn't precise due to the cyclic nature of your PLC program - you may have a slight delay, but for a rough estimation, it should be sufficient. This can all be done using ladder logic programming, which might be easier to implement and troubleshoot than SCL.
✅ Work Order Management
✅ Asset Tracking
✅ Preventive Maintenance
✅ Inspection Report
We have received your information. We will share Schedule Demo details on your Mail Id.
Answer: - To estimate signal propagation time, you can create a scenario where a signal is triggered within the PLC program, transmitted to an output, and relayed back to the PLC through a designated input. By measuring the duration of this process, you can obtain an approximate estimation of the signal propagation time.
Answer: - It is not imperative to obtain an exact time measurement; an approximate estimation suffices for assessing the duration required for a signal to travel from the PLC's logic to its output and back to the PLC.
Answer: - Yes, SCL programming can be utilized to simplify the function block implemented for estimating signal propagation time in the S7-1500 PLC. By exploring simpler solutions through SCL programming, you may streamline the process and achieve your objective more efficiently.
Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.