Shop OBEX P1 Docs P2 Docs Learn Events
edge detection — Parallax Forums

edge detection

ArchiverArchiver Posts: 46,084
edited 2000-12-02 16:22 in General Discussion
I need to monitor an input and detect a rising or falling edge. Upon
detection run a serial input routine. The pulse is one input and the
serial stream is another.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-12-02 08:13
    Then this is very simple:
    loop:
    if INx = 1 then goto yourroutine (use = 0 if want to detect falling
    edge) (x is your pin number)
    goto loop

    ACJacques

    djarmis@p... wrote:
    >
    > While it's looking for the edge it won't be doing anything else. The
    > program will just wait for the edge to occur. When it detects it I
    > will need to go to a routine that will read some serial bytes in. I
    > looked at the button command but not sure what it does. Thanks,
    >
    > --- In basicstamps@egroups.com, LarryGaminde <lgaminde@t...> wrote:
    > > Is this all the chip needs to do, or will it be reading or doing
    > other
    > > things while looking for a rising or falling edge.
    > >
    > > djarmis@p... wrote:
    > > >
    > > > I need to monitor an input and detect a rising or falling edge.
    > Upon
    > > > detection run a serial input routine. The pulse is one input and
    > the
    > > > serial stream is another.
  • ArchiverArchiver Posts: 46,084
    edited 2000-12-02 15:28
    Is this all the chip needs to do, or will it be reading or doing other
    things while looking for a rising or falling edge.

    djarmis@p... wrote:
    >
    > I need to monitor an input and detect a rising or falling edge. Upon
    > detection run a serial input routine. The pulse is one input and the
    > serial stream is another.
  • ArchiverArchiver Posts: 46,084
    edited 2000-12-02 15:37
    While it's looking for the edge it won't be doing anything else. The
    program will just wait for the edge to occur. When it detects it I
    will need to go to a routine that will read some serial bytes in. I
    looked at the button command but not sure what it does. Thanks,

    --- In basicstamps@egroups.com, LarryGaminde <lgaminde@t...> wrote:
    > Is this all the chip needs to do, or will it be reading or doing
    other
    > things while looking for a rising or falling edge.
    >
    > djarmis@p... wrote:
    > >
    > > I need to monitor an input and detect a rising or falling edge.
    Upon
    > > detection run a serial input routine. The pulse is one input and
    the
    > > serial stream is another.
  • ArchiverArchiver Posts: 46,084
    edited 2000-12-02 16:04
    The signal I'm detecting the edge on is a repetitive square wave. It's
    possible that at the time the if INx=1 statement occurs the level
    could be high. Would this satisfy the if statement or does INx only
    look for a transition from a 0 to a 1? I'm new to Stamps and no little
    about the language so I may be asking a dump question. Thanks,



    --- In basicstamps@egroups.com, "A.C.Jacques" <acjacques@i...> wrote:
    > Then this is very simple:
    > loop:
    > if INx = 1 then goto yourroutine (use = 0 if want to detect falling
    > edge) (x is your pin number)
    > goto loop
    >
    > ACJacques
    >
    > djarmis@p... wrote:
    > >
    > > While it's looking for the edge it won't be doing anything else.
    The
    > > program will just wait for the edge to occur. When it detects it I
    > > will need to go to a routine that will read some serial bytes in.
    I
    > > looked at the button command but not sure what it does. Thanks,
    > >
    > > --- In basicstamps@egroups.com, LarryGaminde <lgaminde@t...>
    wrote:
    > > > Is this all the chip needs to do, or will it be reading or doing
    > > other
    > > > things while looking for a rising or falling edge.
    > > >
    > > > djarmis@p... wrote:
    > > > >
    > > > > I need to monitor an input and detect a rising or falling
    edge.
    > > Upon
    > > > > detection run a serial input routine. The pulse is one input
    and
    > > the
    > > > > serial stream is another.
  • ArchiverArchiver Posts: 46,084
    edited 2000-12-02 16:22
    The statment if INx= 1 looks only for a high state no the transition
    itself but if your square wave have a lower frequency than the loop then
    it will go to routine very close with the rising edge. But there are no
    garantee that the first entrance in the loop the statement will be close
    to the edge. To do this you may look for two transitions:

    loop:
    if inx = 1 then loop: (only wiil goto next line if state is low)
    if inx = 1 then your routine
    goto loop:

    ACJacques



    djarmis@p... wrote:
    >
    > The signal I'm detecting the edge on is a repetitive square wave. It's
    > possible that at the time the if INx=1 statement occurs the level
    > could be high. Would this satisfy the if statement or does INx only
    > look for a transition from a 0 to a 1? I'm new to Stamps and no little
    > about the language so I may be asking a dump question. Thanks,
    >
    > --- In basicstamps@egroups.com, "A.C.Jacques" <acjacques@i...> wrote:
    > > Then this is very simple:
    > > loop:
    > > if INx = 1 then goto yourroutine (use = 0 if want to detect falling
    > > edge) (x is your pin number)
    > > goto loop
    > >
    > > ACJacques
    > >
    > > djarmis@p... wrote:
    > > >
    > > > While it's looking for the edge it won't be doing anything else.
    > The
    > > > program will just wait for the edge to occur. When it detects it I
    > > > will need to go to a routine that will read some serial bytes in.
    > I
    > > > looked at the button command but not sure what it does. Thanks,
    > > >
    > > > --- In basicstamps@egroups.com, LarryGaminde <lgaminde@t...>
    > wrote:
    > > > > Is this all the chip needs to do, or will it be reading or doing
    > > > other
    > > > > things while looking for a rising or falling edge.
    > > > >
    > > > > djarmis@p... wrote:
    > > > > >
    > > > > > I need to monitor an input and detect a rising or falling
    > edge.
    > > > Upon
    > > > > > detection run a serial input routine. The pulse is one input
    > and
    > > > the
    > > > > > serial stream is another.
Sign In or Register to comment.