the ultrasonic SRF04 with pic16f88


Results 1 to 16 of 16

Threaded View

  1. #1
    Join Date
    Mar 2008
    Location
    london
    Posts
    15

    Default the ultrasonic SRF04 with pic16f88

    hello everybody

    I have few problems with my ultrasonic ranger the SRF04.
    I managed to make it work with a pic 16f84 to measure distances in inches and centimeters and display the results on a serial lcd. worked really fine.

    then i tried to use the pic 16f88 with an internal clock ; but the lcd displays 0cm and 0 inches all the time which means that the SRF04 is not doing the job (the internal clock is working by the way. i tested it with another code)

    here is a part of my code in picbasic pro:

    DEFINE OSC 4
    INTRC_OSC_NOCLKOUT
    INTRC_IO
    OSCCON=%01101000

    include "modedefs.bas"



    trisa = %11111111
    trisb = %00000000

    lcd var portb.7
    'piezo var portb.4
    trigger var portb.6
    echo var porta.0

    baud con N2400
    dist_raw var word
    dist_inch var word
    dist_cm var word
    conv_inch con 15
    conv_cm con 6

    low trigger


    serout lcd,baud,[254,1] 'clear lcd screen
    pause 1000

    serout lcd,baud,[254,128,"-sonar ranger-"]

    'sound piezo,[100,10,50,5,70,10,50,2] 'make startup sound
    pause 1000 'pause 1 sec

    serout lcd,baud,[254,128,"inches: "] 'set up the lcd display
    serout lcd,baud,[254,192,"centimeters: "]

    main:

    gosub sr_sonar

    serout lcd,baud,[254,135,#dist_inch," "] 'display the disance in inches

    serout lcd,baud,[254,204,#dist_cm," "] 'display the distance in cm

    goto main

    end

    sr_sonar:

    pulsout trigger,1 'send a 10us trigger pulse

    pulsin echo,1,dist_raw 'start timing the pulse width
    'on echo pin
    dist_inch = (dist_raw/conv_inch)
    dist_cm = (dist_raw/conv_cm)

    pause 1

    return



    i suppose that the pins of the pic are not inputing or outputing the right datas. may be because i did not set the input and output properly.
    i had been strogling for few days , please help me to make it work.
    thanx
    regards
    Last edited by tur_bot; - 16th March 2008 at 18:58.

Similar Threads

  1. RX TX modules - intermitent communication
    By ruijc in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 11th June 2009, 00:13
  2. Replies: 8
    Last Post: - 7th December 2006, 15:42
  3. PIC16F88 problem with TOGGLE command?
    By russman613 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 17th September 2006, 23:31
  4. sensor ultrasonic 8051&PIC
    By hd_uni_pro in forum Schematics
    Replies: 1
    Last Post: - 13th September 2006, 12:58
  5. SRF04 Range Finder 16F628 R18iXL Board
    By Spindle in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th June 2005, 02:08

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