Best way to find a rising edge?


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    jcsquire's Avatar
    jcsquire Guest


    Did you find this post helpful? Yes | No

    Default

    ----------
    Last edited by jcsquire; - 31st May 2006 at 05:54.

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    I did it like this

    RESETALL VAR PORTA.0
    RSTPLS VAR BIT
    HULP0 VAR BIT


    RSTPLS = RESETALL & ~ HULP0
    HULP0 = RESETALL

    (& = logical and ~ = invert)

    ' At RSTPLS you will get a pulse what is one cycle of your program if RESETALL goes high.

    Ofcource
    while
    RESETALL = 1
    wend

    will also work

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    I am not sure exactly what you are trying to do ???

    ; If you are only looking for 0V-5V (and not 5V-0V) then try this
    ; example of monitoring RB0, RB2, and RB4 for change
    old var byte
    main:
    pause 10
    old = PORTB & %00010101
    if old = 0 then main
    ; do something here because a pin went high
    ; to find which pin went high
    if old.0 = 1 then here4RB0
    if old.2 = 1 then here4RB2
    if old.4 = 1 then here4RB4

    here4RB0:
    do something
    goto main
    here4RB2
    do something
    goto main
    here4RB4
    do something
    goto main

    Another approach - You also could just poll the port directly,
    main:
    If PORTB.0 = 1 then here4RB0
    If PORTB.2 = 1 then here4RB2
    If PORTB.4 = 1 then here4RB4
    pause 10
    goto main
    etc

    ************************************************** ************
    ; If you are looking for 0V-5V or 5V-0V then try this
    ; example of monitoring RB0, RB2, and RB4 for change
    old var byte
    nowHigh var byte
    main:
    old = PORTB & %00010101
    pause 10
    newHigh = PORTB & %00010101
    if old = newHigh then main ; no change on RB0, RB2, RB4
    ; do something here because a pin changed
    old = old ^ newHigh ; find changed pin(s) (bit or bits will be set for changed pin(s))
    if old.0 = 1 then here4RB0
    if old.2 = 1 then here4RB2
    if old.4 = 1 then here4RB4

    here4RB0:
    if newHigh.0 = 1 then
    do something ; pin when from low to high
    else
    do something else ; pin went from high to low
    endif
    goto main
    here4RB2
    do something
    goto main
    here4RB4
    do something
    goto main

    Good Luck,

    Paul Borgmeier
    Salt Lake City, Utah
    USA

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 12:12
  2. RC Servo decoding/encoding using 12F683
    By ScaleRobotics in forum Code Examples
    Replies: 13
    Last Post: - 14th September 2010, 00:49
  3. Interrupt On both (Rising and Falling)
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 12th March 2008, 14:34
  4. 2 interupts - portb.0 rising and falling edges
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th July 2005, 01:10
  5. Replies: 2
    Last Post: - 5th June 2005, 19:55

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts