Shop OBEX P1 Docs P2 Docs Learn Events
Ping))) — Parallax Forums

Ping)))

robotjj123robotjj123 Posts: 3
edited 2005-12-27 23:13 in Robotics
Ping))) works for a while and then hangs. I discovered that it hangs while waiting for the transition from low to high after I change the SIG pin to an input. Any ideas?

Thank You!
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-27 18:56
    Posting your code might be a good way for us to determine what's going on.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • robotjj123robotjj123 Posts: 3
    edited 2005-12-27 19:13
    I have tried different delays and timeouts, and it always hangs eventually.

    ; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    ReadCPing
    ·global·ReadCPing
    ···bcf··center_pin
    ; change to output
    ···bcf··center_tris
    ···bsf··center_pin
    ; ping high for 5us
    ···movlw·sonarinitdelay
    ···movwf·uSeconds
    ···call·Delay_uS
    ; ping low
    ···bcf··center_pin
    ; change to input
    ···bsf··center_tris
    ···bcf··center_pin
    ; after a short time, anywhere from 5 secs to 1 min, hangs here
    Wait4CPingSet
    ···btfss·center_pin
    ···goto·Wait4CPingSet
    ; turn on timer
    ···clrf·TMR0H····; clear tmr
    ···clrf·TMR0L
    ···bsf··T0CON, TMR0ON··; turn on tmr0
    Wait4CPingTimer
    ···btfss·center_pin
    ···goto·CPingFound
    ···movlw·sonartimeout
    ···cpfsgt·TMR0L····; is tmr > w (time out) skip if f > w
    ···goto·Wait4CPingTimer···; no
    ···goto·rReadCPing
    CPingFound
    ···movff·TMR0L, pingval
    ···bsf··sensor, bCPing
    ···incf·Sonar
    ···incf·Sonar
    rReadCPing
    ···movlw·sonardelay
    ···movwf·mSeconds
    ···call·Delay_mS
    ···return
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-27 21:15
    What microcontroller are you using?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • robotjj123robotjj123 Posts: 3
    edited 2005-12-27 21:59
    pic18f452 20 mhz
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-27 23:13
    We don't have any example code for the PIC using the PING))).· But I would definately suspect something wrong in your code...I have not·seen anything like this happen.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
Sign In or Register to comment.