reading ultrasonic receve


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: reading ultrasonic receve

    Hmmmmm.... try putting the trig = 0 before the main loop:
    Code:
        trig = 0            ' start output in LOW state
    
    main:
    GOSUB distance    
        SELECT CASE dist
            CASE 0          ' PULSIN timed out and returns zero, turns LED OFF
                LOW led 
            CASE IS < 8     ' dist <8 inches but not zero, turns ON LED
                HIGH led 
            CASE ELSE       ' dist >8 inches turns LED OFF
                LOW led
        END SELECT
    GOTO main    
    
    distance:
        PULSOUT trig,1      ' each count = 10us
        PULSIN sens,1,dist  ' will time out in 655ms if nothing received
        dist= dist/15 'convert to inches
        PAUSE 100
    RETURN
    
    END
    Louie

  2. #2
    Join Date
    Feb 2013
    Posts
    11


    Did you find this post helpful? Yes | No

    Default Re: reading ultrasonic receve

    I put the low trig before the main but it still blinks I wonder if the sensor is sending stray numbers when it starts the distance routine, is there a way I can sim the pic in multisim 11? I may try programming another pic and make sure it is not an internal error

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: reading ultrasonic receve

    You may right about the stray or false triggering as mentioned in the data sheet.
    Now try putting a little delay after the PULSOUT to give the device time to complete the transmit function before listening for an echo.

    Code:
    distance:
        PULSOUT trig,1      ' each count = 10us
        PAUSEUS 120      ' Wait for transmit pulse to complete
        PULSIN sens,1,dist  ' will time out in 655ms if nothing received
        dist= dist/15 'convert to inches
        PAUSE 100
    RETURN
    
    END
    Louie

Similar Threads

  1. Ultrasonic range meter
    By Crista in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th June 2008, 18:01
  2. the ultrasonic SRF04 with pic16f88
    By tur_bot in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 20th March 2008, 17:24
  3. sensor ultrasonic 8051&PIC
    By hd_uni_pro in forum Schematics
    Replies: 1
    Last Post: - 13th September 2006, 12:58
  4. ultrasonic sensor
    By PoTeToJB in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th May 2006, 20:26
  5. SRF08 Ultrasonic Rangefinder
    By rad in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 25th July 2003, 21:01

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