Shop OBEX P1 Docs P2 Docs Learn Events
PULSIN timing of 2 seperate pulses for speed trap — Parallax Forums

PULSIN timing of 2 seperate pulses for speed trap

LloydsLloyds Posts: 75
edited 2010-07-29 17:53 in BASIC Stamp
Hi,
I need help with a logic circuit to measure the time (PULSIN counts) betweeen the leading edge of a start pulse and the leading edge of a stop pulse. Basically a counter for a speed trap.

Here is what I think I need to do:
1) Stamp pin one is input, pulled Low.
2)·give the ·PULSIN command for input pin 1.
3) External Start pulse occurs (~5 Vdc)
4)·Via the logic circuit, this drives pin 1 high.
5) PULSIN starts counting
6) External Stop pulse occurs (~5 Vdc) (this comes from a different source than the start pulse).
7)·Via the·logic circuit, this drives pin 1 Low.
8)·PULSIN stops counting (less than 1 mSec total count time) and writes number of counts to "count" variable.


It sounds simple enough and I know that I probably need to use one of the logic circuits from this page, but I am overwhelmed by the selection.
http://www.play-hookey.com/digital/derived_gates.html

I am assuming that I can't directly use the inputs to 2 seperate stamp pins with PULSIN.

There are a couple of other things I want to do:
9) Reset the logic circuit immediately before giving the PULSIN command to make sure pin 1 is low.
10) Make sure the counter works correctly whether or not the start input is still high when the stop pulse goes high.

Can anyony offer some suggestions on how to accomplish this?· I will study the logic circuits some more ·to see if they become logical!
Thanks very much.
Lloyd

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-28 16:32
    You've got the right idea. A CD4043 Quad NOR Latch would be a good choice to use. You'd need just one section of it. It's like the "Basic RS NOR Latch" shown on the "play-hookey" website. There's a 3-State Enable pin that you'd tie to Vcc. There are a variety of ways to reset the latches that depend on how you produce the start and stop pulses.

    Post Edited (Mike Green) : 7/28/2010 4:37:23 PM GMT
  • Larry~Larry~ Posts: 242
    edited 2010-07-28 16:42
    couple of things you need to know

    1. will the direction always be the same ( same sensor is always 1st )
    2. will the sensors be pulsing on then off or pulsing on and staying on for any length of time ( staying on while the object is moving through)
    3. are all the objects moving through the same size

    Ok three I can't count
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2010-07-28 16:42
    You probably need the simple RS flip flop:
    img111.gif

    first pulse to set it, second pulse to reset, the Q output to your Stamp input. A refinement would be a second reset input, so that both the Stamp and the external pulse could put it in the ready state. You make this out of two cross coupled OR gates that are contained in one chip.

    You said the total time will be less than one millisecond. The Stamp BS2 measures PULSIN in units of 2 microseconds.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-28 16:45
    You can also use a "Clocked RS NAND Latch" as shown on the play-hookey website and just tie the clock signal to Vcc so it's always true. You'd use a Quad NAND gate like the 74HC00. Again, the reset circuit would depend on the kind of input signals you have.
  • LloydsLloyds Posts: 75
    edited 2010-07-28 17:18
    Thanks for the help everyone.
    I had a mental block about learning the logic principles, but I think the time has arrived to just do it.

    Mike, I studied the two possibilities you mentioned and hadn't realized that you could click on the inputs in the Play Hookey site to change the states and see how the gates responded. Very cool, and its starting to make sense! This is good!

    Thanks again,
    Lloyd
  • LloydsLloyds Posts: 75
    edited 2010-07-29 17:53
    Hello everyone,
    I've attached a pdf of a circuit I think will work, but I'm a total novice and like to ask about my "good ideas."
    I'm pretty sure the logic will work and that the reset sequence will work, but I'm wondering if I am not making it too complicated.

    Again, timing starts when trap·1 goes high, and stops when trap 2 goes high.· But the complication is that trap·2 might go·high before OR after trap·1 goes low.· Both traps will always go low within about 20 milliseconds.

    Do I need all 4 diodes, and what about the resistors and their values?

    Thanks for any suggestions.
    Lloyd
Sign In or Register to comment.