Shop OBEX P1 Docs P2 Docs Learn Events
Single Pulse Output with varying input pulse length - My Solution — Parallax Forums

Single Pulse Output with varying input pulse length - My Solution

DChapDChap Posts: 7
edited 2005-02-03 23:17 in BASIC Stamp
Hi all, great forum.

I have a need to generate a single pulse output of say 10 microseconds upon the receipt of an input.

I have tried several methods and because I am monitoring an input pin whose signal can be up to 50 milliseconds, my output is a series of 10 microsecond pulses for the duration of the input pulse length.

Basically what I need here is a One Shot.

For example, (BS2P-24)

DO

MAIN:
If IN0 = 0 THEN
PULSOUT 1, 85
DO
LOOP UNTIL IN0 = 1
ENDIF
LOOP


Shouldn't this generate 1 output pulse for each input regardless of how long the input pulse is?

Thanks

Don

Here is the code snipit that I have working the way I wanted:

DO
MAIN:

IF Set = 0 THEN MAIN
IF IN0 = 0 THEN
Set = 0
GOSUB FIRE
ENDIF


FIRE:
IF Set = 1 THEN Main
PULSOUT 4, 7000
DO UNTIL IN0 = 1
LOOP
Set = 1
GOTO MAIN

LOOP

I get my output upon receipt of an input LOW and I can control the output pulse width..

Thanks

Post Edited (DChap) : 2/3/2005 8:05:23 PM GMT

Comments

  • GadgetmanGadgetman Posts: 2,436
    edited 2005-02-03 12:24
    Why bother reinventing the wheel?
    Or in this case a 'monostable mulitvibrator'...

    http://focus.ti.com/docs/prod/folders/print/sn74121.html

    smile.gif
  • BeanBean Posts: 8,129
    edited 2005-02-03 12:48
    Sound like your getting switch bounce. Try adding a PAUSE 20 after the PULSOUT command.
    Bean.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-02-03 14:23
    Yes, you're probably getting switch bounce. The solution to switch bounce is multiple reads.

    So:
    InState VAR NIB


    MAIN:
    InState = 0
    CheckClosed:
    IF IN0 = 0 THEN
    InState = InState + 1
    ELSE
    InState = 0
    END IF
    IF InState = 4 THEN IsClosed 'ie read switch until you get 4 reads of 'closed'
    PAUSE 1
    GOTO CheckClosed

    IsClosed: ' Got 4 reads of closed. It really is closed.
    PULSOUT 1, 85

    InState = 0

    CheckOpen:
    IF IN0 = 1 THEN
    InState = InState + 1
    ELSE
    InState = 0
    END IF
    IF InState = 4 THEN Main 'ie read switch until you get 4 reads of 'open'
    PAUSE 1
    GOTO CheckOpen
  • DChapDChap Posts: 7
    edited 2005-02-03 17:06
    Thanks for all the replies. Good ideas but does not address my situation. Let me try to clarify:

    I will be looking at a train of cars on a track using a Banner world Beam NPN sensor. (No Switch Bounce)

    The low going signal from this sensor will go to Pin0 as an input. When each car breaks the beam I will get an input.

    I need to pass this signal out to an external device immediately on the falling edge of the signal, then ignore it for the remainder of the time it is low.

    This total LOW time from the sensor is going to be all over the place as no two trains I will be looking at have the same physical dimensions or are traveling at the same speed.

    Thanks much

    Don
  • Jim McCorisonJim McCorison Posts: 359
    edited 2005-02-03 17:17
    Don,

    How important will a missed high be? You could just:

    main:
    if IN0=0 then train
    pause 1
    go to main

    train:
    PULSOUT whatever

    trainwait:
    if IN0=1 then main
    pause 1
    go to trainwait


    Jim
  • nick bernardnick bernard Posts: 329
    edited 2005-02-03 17:30
    i'm with Gadgetman, a 555 timer configured as a monostable mulitvibrator should serve the purpose. or am i missing something?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    League Bowling.... it's not a sport, it's a way of life
  • DChapDChap Posts: 7
    edited 2005-02-03 18:24
    No, your not missign anything - A 555 mono would do, I was trying to keep circuitry to a minimum.

    A missed high is no big deal - I cannot miss any of the lows.


    Still playing..

    Don
  • nick bernardnick bernard Posts: 329
    edited 2005-02-03 22:23
    well the thing that concerns me the most is that if your stamp is busy doing something in the background it could miss a low. will you have a single stamp dedicated to this process?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    League Bowling.... it's not a sport, it's a way of life
  • DChapDChap Posts: 7
    edited 2005-02-03 23:17
    Very good point. It is hard to describe my application. Actually, yes - I will more than likely have to process a different input/output.

    I'll have to give this some more thought. I cannot tie up the stamp in a loop.

    I may have to use two stamps to do what I want.

    More thought...

    Thanks

    Don
Sign In or Register to comment.