I am trying to record the time taken between 2 sensors being activated
I am using ladder logic for my university project although struggling with code to record time taken between two events so as to store the information
I am trying to record the time taken between 2 sensors being activated
I am using ladder logic for my university project although struggling with code to record time taken between two events so as to store the information
It would be interesting if you included which PLC you are trying to use as the timer block can vary a little between some brands of PLCs, below I will put an answer that works for Codesys, Twincat, Omron, Delta and others similar, but some blocks may vary from format or in the name of the inputs and outputs, but the concept is the same.
You also didn't specify if you intend to measure between the rising or falling edges of the sensors, this could influence the measured time. Let's assume you want to measure between the rising edge of
S1
and the rising edge ofS2
.The idea is to start a TON timer (
fbTimer
) when sensorS1
is turned on and keep this timer running even ifS1
is turned off and, whenS2
is turned on, capture the elapsed time (fbTimer.ET
) on the timer and store it in a variable (using the MOVE block) before restarting the timer (when the elapsed time is reset).Some notes: