detect sequence of 2 pulses

Discussion in 'The Projects Forum' started by davidhoff, Nov 8, 2013.

  1. davidhoff

    Thread Starter Active Member

    Sep 19, 2008
    66
    0
    I have a project that needs to detect when 2 hall effect sensors are triggered in a specific sequence (left sensor, then right sensor) by a magnet, and activate some kind of output (5v pulse would be nice). I'm sure this type of circuit has been done before, but I don't know what to call it (or search for). Anybody have suggestions for what to look up or research? I could just use a microcontroller, but it seems silly as this is all it would need to do. It also seems like a good excuse to learn about something new.
     
  2. davidhoff

    Thread Starter Active Member

    Sep 19, 2008
    66
    0
    I'm thinking a concept like this would work (see picture). There is only one magnet to detect, and it has to reverse direction to go by the sensor. So it can't do something like go in a loop the wrong way and trigger sensor 1 on the first trip around and sensor 2 on the second trip around in the wrong direction. I've mostly just worked with microcontrollers before, so I'm not exactly sure how I'd build something like what I've diagrammed here with individual ic's or components. Any input?
     
  3. antonv

    Member

    Nov 27, 2012
    149
    27
    Cheap six- or 8-pin 8-bit micro controllers are good for this kind of thing.

    However, your idea will work if you add a one-shot to produce the output pulse. You can use the one-shot's trailing edge to resets the latch. I hope I understand what you want to accomplish.
     
  4. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,070
    3,841
    Assuming the first hall effect sensor stays high while the second is turning on, then a D-type flipflop will work fine. 7474 is one option.
     
  5. davidhoff

    Thread Starter Active Member

    Sep 19, 2008
    66
    0
    The first sensor will turn off before the second sensor goes high.

    I don't understand what the one shot would do. Also, what kind of latch would I use? I only know what I want it to do, not how to make it.

    It seems to me like the picture below should work, but I'm not sure. Would it? Can you connect the output of an and gate to it's own input to keep it on? Is the transistor a good way to "unlatch" the upper and gate? Am I making this more difficult than it needs to be?
     
  6. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    H1 triggers a one-shot. If one-shot is triggered AND H2 happens, then output=TRUE.

    If H2 happens first, or too late, nothing happens...

    The duration of the one-shot spans the time during which H2 can follow H1.
     
  7. MikeML

    AAC Fanatic!

    Oct 2, 2009
    5,450
    1,066
    Another suggestion. Look up "quadrature direction encoding", such as is used in an incremental shaft angle position encoder. You would have to move one of the Hall effect sensors so that there is a position of the magnet where both of the Hall sensor are TRUE. The encoding if the magnet approaches from left would look like this:
    H1 H2
    0 0
    1 0
    1 1
    0 1
    0 0

    With this encoding of the magnet position it is possible to tell which direction the magnet moves past the two sensors without using the element of time (one-shot).
     
  8. davidhoff

    Thread Starter Active Member

    Sep 19, 2008
    66
    0
    Ok. I think I understand the one shot idea, but it sounds like that would make it speed dependent. If it went too slowly, it would not trigger. I also understand how encoders work, but I'm not sure that helps me here. The D-flip-flop sounds promising (if the signals overlapped like an encoder), but it seems to me that if the magnet reversed direction while the second sensor was active, the circuit would fail to reset itself.

    Maybe more detail would help. The magnet travels along an inclined track. It gets pushed up the ramp by a user. It's part of a game. Sometimes, it doesn't make it all the way up. I need to count how many times it passes a certain point while going in one direction only. So, it is possible for the magnet to reverse direction while a sensor is active, or to go by the sensors very slowly.
     
  9. crutschow

    Expert

    Mar 14, 2008
    13,055
    3,245
    Here's a circuit that should do what you want. This assumes the two Hall Effect signals do not overlap. It uses a Dual-D CD4013 FF to detect the sequence independent of speed.

    Assume both the top and bottom FF's are reset. The top FF D input is thus set to 1.

    The signal from the first Hall Effect sensor then toggles the top FF which sets the D input on the bottom FF to 1.

    The signal from the second Hall Effect sensor then toggles the bottom flip-flop to generate the output signal and sets the D input of the top FF to 0.

    When the first Hall Effect signal is again triggered by the magnet on the way back down it toggles the top FF back to the reset state and resets the bottom FF, terminating the output signal.

    When the first Hall Effect signal again occurs from the magnet on the way up, the sequence is restarted.

    If the magnet does not go far enough to trigger the second Hall Effect, then no output signal is generated.

    Only the sequence of the first Hall Effect, the second Hall Effect, and then the first Hall Effect generates an output pulse.

    Multiple signals from the second Hall Effect (such as going up and then back down) also has no effect.

    Note: All unused inputs must be grounded (not shown). Also the power and ground connections are not shown.

    Sequence Detector.gif
     
    Last edited: Nov 9, 2013
  10. davidhoff

    Thread Starter Active Member

    Sep 19, 2008
    66
    0
    That sounds like exactly what I'm looking for. Thanks.
     
Loading...