reACTION: count a PNP sensor signal on the falling edge instead of the rising edge

Hello,

I have a reACTION program that counts objects detected by a PNP sensor. It works, but right now it counts when the object arrives (rising edge). I want it to count when the object leaves the sensor (falling edge). Could you please advise on the recommended way to do this?

Environment

  • Automation Studio: 6.7.0.187
  • reACTION module: X20RT8001
  • Library: ASIORTI
  • Sensor: PNP, wired to input Channel 1 of the X20RT8001

Current structure (screenshot attached; the number in each block is its execution order)

# Block Wiring Purpose
1 rtiDin_0 Channel = 1, Out → rtiTP_0.IN and rtiRes_1.Data Reads the sensor input
3 rtiRes_1 DpNr = 2 Sends the raw sensor state to the application
5 rtiTP_0 IN ← rtiDin_0.Out, PT = 1, Q → rtiCount_0.Up_Clk Turns the input into a fixed-width pulse
7 rtiPar_0 DpNr = 1, Data → rtiCount_0.Clear Lets the application clear the counter
9 rtiCount_0 Mode = 0, Up_Clk ← rtiTP_0.Q, Down_Dir not connected Counter
12 rtiRes_0 DpNr = 1, Data ← rtiCount_0.Out Sends the count value to the application

Current behavior
When the sensor turns ON (the object arrives), rtiDin_0.Out goes TRUE. rtiTP_0 then produces a pulse, and rtiCount_0 increments on that pulse. So the count happens on the rising edge of the sensor signal.

What I want
Increment the counter only on the falling edge of the sensor signal, i.e. when the object has passed and the sensor turns OFF.

Questions

  1. What is the recommended way to count on the falling edge with the ASIORTI blocks?
    • Should I insert an inverter (for example rtiNOT) between rtiDin_0.Out and rtiTP_0.IN?
    • Or can the Mode input of rtiDin or rtiCount select falling-edge detection directly?
    • Or should OutTsEdgeNeg of rtiDin be used for this?
  2. Is rtiTP needed in front of rtiCount.Up_Clk at all, or can the input signal be connected to Up_Clk directly? What unit is PT in?
  3. If I invert the signal, is there anything to watch out for at startup? For example, could the counter increment once when the input is initially FALSE?

Any advice would be greatly appreciated. Thank you in advance.

Could the rtiRF_TRIG be of use to you?
rtiRF_TRIG

You should be able to detect the edges you want with rtiRF_TRIG as mentioned by Jan.

OutTsEdgeNeg and OutTsEdgePos output the timestamps of the edges, not the actual edges.
Automation Help: rtiDin

If you use the rtiRF_TRIG in between there is no need to use rtiTP. If you only connect the Out directly to rtiCount you would count up every cycle the input would be high.

PT is in reaction cycles. For more information check this link Automation Help: rtiTP

If you only invert the signal, you are still counting only the rising edges, the value is just inverted.

So for a rising edge on the input, when the input goes 0–>1 your output would just be 1–>0

And on a falling edge on the input, when the input goes 1–>0 your output would just be 0–>1.

Thanks, Tommi. That clears it up.

Here is what I have now (screenshot attached):

rtiDin_0.Out → rtiRF_TRIG_0.CLK, OutEdgeNeg → rtiTP_0.IN (PT = 1) → rtiCount_0.Up_Clk.

Since rtiCount counts every cycle Up_Clk is high, I understand that rtiTP with PT = 1

just passes the one-cycle pulse through, so this should give exactly one count per

falling edge. As you said, rtiTP is redundant here, so I may remove it and connect

OutEdgeNeg directly to Up_Clk.

Could you confirm that my understanding is correct?