If two light beams are oriented parallel to each other, closer than the width of the narrowest object passing along the conveyor belt, we will have enough information to determine direction of object travel:
One solution to this problem is to use an up/down counter, capable of both incrementing (counting up) and decrementing (counting down), and equip this counter with two light-beam sensors capable of determining direction of travel. This would be a problem because the system would “think” more objects had passed along the belt (indicating greater production) than actually did. If, for instance, the conveyor belt were ever reversed in direction, the sensor would continue to count objects that had already passed by before (in the forward direction) as those objects retreated on the belt. When it reaches zero, the Q output activates.Ī potential problem in either version of this object-counting system is that the PLC cannot discriminate between forward and reverse motion on the conveyor belt. With each sensor pulse received, the counter instruction decrements. Here, a “load” input causes the counter’s current value to equal the preset value (25) when activated. This is the status of the same program after thirty objects have passed by the sensor on the conveyor belt.Īs you can see, the current value of the counter has increased to 30, exceeding the preset value and activating the discrete output: The preset value is something programmed into the counter instruction before the system put into service, and it serves as a threshold for activating the counter’s output (Q), which in this case turns on the count indicator lamp (the OUT counts reached coil).Īccording to the IEC 61131-3 programming standard, this counter output should activate whenever the current value is equal to or greater than the preset value (Q is active if CV ≥ PV). Status indication is shown in this Ladder Diagram program, with the counter’s preset value (PV) of 25 and the counter’s current value (CV) of 0 shown highlighted in blue. If this input is activated, the counter immediately resets its current value (CV) to zero. The second input of the counter instruction box (“R”) is the reset input, receiving virtual power from the contact IN switch reset whenever the reset pushbutton is pressed. This increments the counter just as the leading edge of the object breaks the beam. When the beam is broken by a passing object on the conveyor belt, the input channel de-energizes, causing the virtual contact IN sensor object to “close” and send virtual power to the “CU” input of the counter instruction. The normally-closed virtual contact (IN sensor object) is typically held in the “open” state when the light beam is continuous, by virtue of the fact the sensor holds that discrete input channel energized while the beam is continuous. This particular counter instruction (CTU) is an incrementing counter, which means it counts “up” with each off-to-on transition input to its “CU” input.