Cycle time measurement with IEC-programmable target systems

Question:
How can due to a simple program extension in case of IEC-programmable target systems the time between two events (e. g. binary flag signals) be measured?

Answer:
Extend your DDS project as follows:
  • Generate a new POU (e. g. POU MeasuringCycleTime in FUP).
  • In network 1 insert a function block L_PHINTK (e. g. the first instance L_PHINT3) and assign the function block as presented below. The input L_PHINT3.bLoad_b is to be connected with the starting event (starting signal for the cycle to be measured). Assign a fixed number of 1[incr./ms] to the input L_PHINT3.nIn_v.
  • Attach a network 2 and use it for leading the variable for stopping time measurement via a positive edge evaluation (FB R_TRIG1) and controlling a selector (function SEL). Due to the feedback of the output signal the selector acts on the second input as a a Sample&Hold element. With each positive edge at the stop signal it takes the time information generated via L_PHINT3.
  • In the parameter instance manager save the internal variable L_PHINT3.byMode as a first instance code and initialize the code to value 1 (mode 1: edge-controlled reset of the integrator L_PHINT3).
  • Create an interval task, which is called in the time intervals of the desired measurement resolution (example: If you want to measure an interval at least in 5 ms resolution, the interval task is to be set with a cycle time of 5 ms). If availabe, you can use an already existing interval task with the desired cycle interval.
  • Attach your POU to the newly generated interval task or call your POU in an existing interval task.

In the example program presented below the time measurement is started via a positive edge at the variable bStartTrigger_b. The measurement is finished as soon as a positive edge is detected on the variable bStopTrigger_b. The measured cycle time between the positive edges on the variables bStartTrigger_b and bStopTrigger_b is shown in [ms] on the variable dnCycleTime.

URL for linking this AKB article: https://www.lenze.com/en-de/go/akb/200606698/1/
Kontaktformular