How to determine the direction of a moving object with 2 sensor inputs

Melkske

Member
Join Date
Feb 2024
Location
Brussel
Posts
1
Hello, i am a beginner with a Siemens Logo 8 PLC.
I would determine the direction of an object if it passes a whole cycle of 2 input sensors.
See the pictures as attachment for the cycle in the upper right corner (loading and unloading.

Who can help me a little bit?

Regards
Geert
 
I dont see an attachment. Is the gap between the sensors smaller than the object, or can the object completely pass a Sensor before making the next sensor?
 
Hello @Melkske/Geert, I don't see any attached pictures.

I would think it would be similar to a quadrature encoding system, where detecting which sensor input has transitioned from 0 to 1 on the first scan cycle when when both sensors are 1 will be the "downstream" sensor. This assumes the object length in either direction of motion is greater than the distance between sensors.

So the key word is "transitioned." PLC programming is primarily about time: when something happens is more important than what happens. A PLC program's logic is repeatedly evaluated in a series of discrete events in time called scan cycles.

Consider all possible combinations inputs states from the two sensors (call them LEFT and RIGHT) on any singe scan cycle:
  • LEFT is 0; RIGHT is 0
    • There is no object in front of either sensor, there is nothing to detect
  • LEFT is 1; RIGHT is 0
    • There is an object in front of the left sensor, but it is not in front of the right sensor; this could be one of two cases
      • the object is moving left-to-right and will block the right sensor shortly
      • OR
      • the object is moving right-to-left and has just stopped blocking the right sensor
    • We cannot tell which case it is from the sensor states alone
  • LEFT is 0; RIGHT is 1
    • This is the mirror of the previous (LEFT=1; RIGHT=0) combination; the results are the same but mirrored
  • LEFT is 1; RIGHT is 1
    • There is an object in front of both sensor; this could also be one of two cases
      • the object is moving left-to-right and has just started blocking the right sensor, and will stop blocking the left sensor next
      • OR
      • the object is moving right-to-left and has just started blocking the left sensor, and will stop blocking the right sensor next
The point I am making is that the information on any one scan cycle alone is not enough to determine the direction of motion. What you will find in LOGO!Soft is that there is an AND-EDGE block, that detects a rising edge transition; that is, on any one current scan cycle when all of connected inputs of the AND-EDGE are 1 (even if there is only one connection), and on the previous scan cycle at least one of its connected inputs was 0, then the output of the AND-EDGE becomes 1 until the next scan cycle and it is evaluated again, when it returns to 0. Note, on the next scan cycle, even if all of the connected inputs are still 1, then the logic described will change the output back to 0 because the "previous" scan cycle for that next scan cycle is the current scan cycle when the output became 1, and in that "previous" scan cycle at least 1 of the inputs was not 0.

That function is called by many names: edge detector; one-shot.

So for example, if you connected each of the following to it's own AND-EDGE block
  • the left sensor alone
  • the right sensor alone
  • both left and right sensors
then, when (i.e. on the scan cycle that) the both-sensors' AND-EDGE output becomes 1, only one of the other two AND-EDGE outputs will also be 1 on that same scan cycle (i.e. at the same time). If the left-only AND-EDGE output is 1, then the object is moving to the left; if the right-only AND-EDGE output is 1, then the object is moving to the right.

Note that there is an assumption the scan cycle time is always short enough that both proximity sensor inputs never transition from 0 to 1 on the same scan cycle i.e. never at the same time.
 

Similar Topics

Hi all, Just looking through the CIP_AXIS_DRIVE data type in a Logix controller to look for something that can tell me whether the current...
Replies
2
Views
1,070
I'm currently working on an MES interface PLC which passes around a whole bunch of strings. A lot of these strings are really just to allow for an...
Replies
0
Views
1,118
I don't use AB much these days, and any installs I've done in years past have been setup by myself from scratch, so I've always known what...
Replies
8
Views
2,083
Hello: I wonder if there is a way to find the CPU load of a Logix processor, and if it is not possible to determine this in an absolute way, I...
Replies
6
Views
1,999
I'm using a 1769-L18ERM to control two Kinetix 5500 servo drives. I am setting up a virtual axis, which I will use the MAJ instruction to run, and...
Replies
6
Views
2,403
Back
Top Bottom