Shop OBEX P1 Docs P2 Docs Learn Events
Newbie question - sequencing outputs — Parallax Forums

Newbie question - sequencing outputs

ArchiverArchiver Posts: 46,084
edited 2004-03-12 20:09 in General Discussion
Hi all,

I am new to basic stamps and have an application I would like to get
running.

I have a signal source that generates a square wave of up to 14
pulses 50ms apart at it's fastest. Pulse duration is ~ 1ms active LOW.

What I am trying to do is have this pulsed input on PIN 0 of the
stamp, and for each pulse of the input generate a LOW out on
sequential pins.

For instance, an input of 6 pulses would generate:

LOW 1
LOW 2
LOW 3
LOW 4
LOW 5
LOW 6

I will never know how many pulses I will be receiving but it will
never be more than 14 at a time. I then need the stamp to reset
automatically so the next series of pulses will start back at
generating the same LOW out sequence.

Any suggestions? I have been looking into PulsIN and Pulsout
statements...

Thanks

Don

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-03-11 19:32
    Don-

    For starters, I'd try a PULSIN to simply detect pulses (as opposed to
    timing them), using the timeout condition to determine when the end
    of the pulse stream has occurred. First non-zero value indicates new
    series has begun.

    At initialization set DIRS to $FFFE. Following each sequence of
    pulses, set OUTS to $FFFE. When each pulse within sequence arrives,
    OUTS = OUTS << 1 + 1 will cause P1 through P15 to go successively
    and individually low.

    Regards,

    Steve

    On 11 Mar 04 at 17:56, donaldscott_18 wrote:

    > ...I have a signal source that generates a square wave of up to 14
    > pulses 50ms apart at it's fastest. Pulse duration is ~ 1ms active
    > LOW.
    >
    > What I am trying to do is have this pulsed input on PIN 0 of the
    > stamp, and for each pulse of the input generate a LOW out on
    > sequential pins.
    >
    > For instance, an input of 6 pulses would generate:
    >
    > LOW 1
    > LOW 2
    > LOW 3
    > LOW 4
    > LOW 5
    > LOW 6...
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-11 20:20
    There are a couple of approaches.
    If you don't care how long the input pulse is low,
    then you can use PULSIN to find out how long the
    time between pulses is -- up to 131 mSec, anyway.

    If you want the best characterizations of the pulses,
    you can also use RCTIME. RCTIME MyPin, 0, MyValue
    will measure how long it takes for MyPin to leave
    the '0' state. RCTIME MyPin, 1, MyValue will
    measure the time it takes to leave the '1' state.

    By the way, a 'Square' wave typically does not
    have 'LOW Pulses' -- if it has pulses, it's not
    'square', which implies equal time high and low.

    You'll have to know something about your signal to
    know when it's safe for the BS2 to assume the
    signal is over. What you are doing sounds like
    reading IR Remote data. Typically there is some
    max delay between repetitions of pulses there --
    when you see that delay, you assume one 'message'
    is done. You then wait for the next 'descent'
    of the input line to start another pulse capture.

    I 'wait' by:
    Waiting:
    IF IN1 = 1 THEN Waiting
    ' Now, when here, first pulse just dropped...




    --- In basicstamps@yahoogroups.com, "donaldscott_18"
    <donaldscott_18@y...> wrote:
    > Hi all,
    >
    > I am new to basic stamps and have an application I would like to
    get
    > running.
    >
    > I have a signal source that generates a square wave of up to 14
    > pulses 50ms apart at it's fastest. Pulse duration is ~ 1ms active
    LOW.
    >
    > What I am trying to do is have this pulsed input on PIN 0 of the
    > stamp, and for each pulse of the input generate a LOW out on
    > sequential pins.
    >
    > For instance, an input of 6 pulses would generate:
    >
    > LOW 1
    > LOW 2
    > LOW 3
    > LOW 4
    > LOW 5
    > LOW 6
    >
    > I will never know how many pulses I will be receiving but it will
    > never be more than 14 at a time. I then need the stamp to reset
    > automatically so the next series of pulses will start back at
    > generating the same LOW out sequence.
    >
    > Any suggestions? I have been looking into PulsIN and Pulsout
    > statements...
    >
    > Thanks
    >
    > Don
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-11 20:58
    Thanks all for the fast replies.

    For reference, here is my application:

    I have a high speed camera that is able to burst images at a rate of 20 images
    per second. So an image capture happens at maximum speed of every 50ms.

    Becuase this camera is so fast, I need to trigger a bank of strobes so that a
    different strobe fires for each picture taken, up to a maximum of 14 pictures.

    The strobe trigger is an active low, that remains low for approximately 1 - 2
    ms, so no, this is not a square wave, but an active low pulse chain, each low
    going pulse can happen as fast as 50ms, or sometimes as slow as every 150ms -
    depends on what is being photographed.

    The photographic sequence can take place every 20 seconds or longer, hence the
    need to reset the whole thing.

    I currently have two stamps,Stamp1 is acting as the camera and Stamp2 is acting
    as the strobe controller being triggered by stamp1.

    Regards,

    Don

    Allan Lane <allan.lane@h...> wrote:
    There are a couple of approaches.
    If you don't care how long the input pulse is low,
    then you can use PULSIN to find out how long the
    time between pulses is -- up to 131 mSec, anyway.

    If you want the best characterizations of the pulses,
    you can also use RCTIME. RCTIME MyPin, 0, MyValue
    will measure how long it takes for MyPin to leave
    the '0' state. RCTIME MyPin, 1, MyValue will
    measure the time it takes to leave the '1' state.

    By the way, a 'Square' wave typically does not
    have 'LOW Pulses' -- if it has pulses, it's not
    'square', which implies equal time high and low.

    You'll have to know something about your signal to
    know when it's safe for the BS2 to assume the
    signal is over. What you are doing sounds like
    reading IR Remote data. Typically there is some
    max delay between repetitions of pulses there --
    when you see that delay, you assume one 'message'
    is done. You then wait for the next 'descent'
    of the input line to start another pulse capture.

    I 'wait' by:
    Waiting:
    IF IN1 = 1 THEN Waiting
    ' Now, when here, first pulse just dropped...




    --- In basicstamps@yahoogroups.com, "donaldscott_18"
    wrote:
    > Hi all,
    >
    > I am new to basic stamps and have an application I would like to
    get
    > running.
    >
    > I have a signal source that generates a square wave of up to 14
    > pulses 50ms apart at it's fastest. Pulse duration is ~ 1ms active
    LOW.
    >
    > What I am trying to do is have this pulsed input on PIN 0 of the
    > stamp, and for each pulse of the input generate a LOW out on
    > sequential pins.
    >
    > For instance, an input of 6 pulses would generate:
    >
    > LOW 1
    > LOW 2
    > LOW 3
    > LOW 4
    > LOW 5
    > LOW 6
    >
    > I will never know how many pulses I will be receiving but it will
    > never be more than 14 at a time. I then need the stamp to reset
    > automatically so the next series of pulses will start back at
    > generating the same LOW out sequence.
    >
    > Any suggestions? I have been looking into PulsIN and Pulsout
    > statements...
    >
    > Thanks
    >
    > Don



    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and Body of
    the message will be ignored.

    Yahoo! Groups Links






    Do you Yahoo!?
    Yahoo! Search - Find what you’re looking for faster.

    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-12 20:09
    So, my understanding is your BS2 is 'watching'
    the 'pulse' line to go low. As soon as it does,
    the BS2 should 'trigger' the next strobe flash
    in its sequence.

    The time between the 'pulse' line dropping is
    very variable -- 50 mSec to 150 mSec.

    If the 'pulse' line hasn't dropped in 150 mSec,
    then that sequence is over -- something must
    now be done to insure the 'recharging' strobes
    aren't used until they're ready.

    So:
    FirstStrobe CON 1 ' First pin to use for Strobe flash
    LastStrobe CON 14 ' Last pin to use for Strobe Flash

    OldStrobe VAR BYTE ' 0..14 -- Allows longer 'Strobe' pulse
    StrobeNum VAR BYTE ' 0..14

    MAIN:
    OldStrobe = FirstStrobe
    StrobeNum = FirstStrobe

    WaitFlash:
    IF IN0 = 1 THEN WaitFlash ' Wait for drop
    ' Okay, if here we've seen drop...
    LOW StrobeNum ' Pulse to trigger strobe
    StrobeNum = StrobeNum + 1
    HIGH OldStrobe ' Release strobe.
    IF StrobeNum <= LastStrobe THEN Continue1
    'ELSE
    StrobeNum = FirstStrobe
    Continue1:
    OldStrobe = StrobeNum
    WaitRise:
    IF IN1 = 0 THEN WaitRise ' Wait for line to go high
    GOTO WaitFlash

    ' What you still need is some way to detect
    ' the > 150 mSec 'space' between IN0 drops.
    ' You can do that with a counter, with some
    ' experimentation.
    '***********************************************
    ' Try #2:
    '
    MaxDelay CON 65530 ' Or something. Experiment...
    TimeCount VAR WORD
    TimeCount = 0
    WaitFlash:
    IF IN0 = 0 THEN StrobeIt
    TimeCount = TimeCount + 1
    IF TimeCount > MaxDelay THEN ...
    'THEN goto someplace to wait for the
    ' next sequence to begin again...
    '
    StrobeIt:
    TimeCount = 0 ' Reset timecount for next delay
    ' HERE, do 'flash' stuff from above...
    '








    --- In basicstamps@yahoogroups.com, Chapman Donald
    <donaldscott_18@y...> wrote:
    > Thanks all for the fast replies.
    >
    > For reference, here is my application:
    >
    > I have a high speed camera that is able to burst images at a rate
    of 20 images per second. So an image capture happens at maximum
    speed of every 50ms.
    >
    > Becuase this camera is so fast, I need to trigger a bank of strobes
    so that a different strobe fires for each picture taken, up to a
    maximum of 14 pictures.
    >
    > The strobe trigger is an active low, that remains low for
    approximately 1 - 2 ms, so no, this is not a square wave, but an
    active low pulse chain, each low going pulse can happen as fast as
    50ms, or sometimes as slow as every 150ms - depends on what is being
    photographed.
    >
    > The photographic sequence can take place every 20 seconds or
    longer, hence the need to reset the whole thing.
    >
    > I currently have two stamps,Stamp1 is acting as the camera and
    Stamp2 is acting as the strobe controller being triggered by stamp1.
    >
    > Regards,
    >
    > Don
    >
    > Allan Lane <allan.lane@h...> wrote:
    > There are a couple of approaches.
    > If you don't care how long the input pulse is low,
    > then you can use PULSIN to find out how long the
    > time between pulses is -- up to 131 mSec, anyway.
    >
    > If you want the best characterizations of the pulses,
    > you can also use RCTIME. RCTIME MyPin, 0, MyValue
    > will measure how long it takes for MyPin to leave
    > the '0' state. RCTIME MyPin, 1, MyValue will
    > measure the time it takes to leave the '1' state.
    >
    > By the way, a 'Square' wave typically does not
    > have 'LOW Pulses' -- if it has pulses, it's not
    > 'square', which implies equal time high and low.
    >
    > You'll have to know something about your signal to
    > know when it's safe for the BS2 to assume the
    > signal is over. What you are doing sounds like
    > reading IR Remote data. Typically there is some
    > max delay between repetitions of pulses there --
    > when you see that delay, you assume one 'message'
    > is done. You then wait for the next 'descent'
    > of the input line to start another pulse capture.
    >
    > I 'wait' by:
    > Waiting:
    > IF IN1 = 1 THEN Waiting
    > ' Now, when here, first pulse just dropped...
    >
    >
    >
    >
    > --- In basicstamps@yahoogroups.com, "donaldscott_18"
    > wrote:
    > > Hi all,
    > >
    > > I am new to basic stamps and have an application I would like to
    > get
    > > running.
    > >
    > > I have a signal source that generates a square wave of up to 14
    > > pulses 50ms apart at it's fastest. Pulse duration is ~ 1ms active
    > LOW.
    > >
    > > What I am trying to do is have this pulsed input on PIN 0 of the
    > > stamp, and for each pulse of the input generate a LOW out on
    > > sequential pins.
    > >
    > > For instance, an input of 6 pulses would generate:
    > >
    > > LOW 1
    > > LOW 2
    > > LOW 3
    > > LOW 4
    > > LOW 5
    > > LOW 6
    > >
    > > I will never know how many pulses I will be receiving but it will
    > > never be more than 14 at a time. I then need the stamp to reset
    > > automatically so the next series of pulses will start back at
    > > generating the same LOW out sequence.
    > >
    > > Any suggestions? I have been looking into PulsIN and Pulsout
    > > statements...
    > >
    > > Thanks
    > >
    > > Don
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the
    Subject and Body of the message will be ignored.
    >
    > Yahoo! Groups Links
    >
    >
    >
    >
    >
    >
    >
    > Do you Yahoo!?
    > Yahoo! Search - Find what you're looking for faster.
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.