the ultrasonic SRF04 with pic16f88


Closed Thread
Results 1 to 16 of 16

Hybrid 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.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Just an idea ...

    May be some comparators and adc to disable ???

    Good evening

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Red face how ??

    good idea but how can I do it???
    how can I disable the ADC and comparators in a 16f88???

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


    Did you find this post helpful? Yes | No

    Default

    There could be a possibility to find that kind of information in the datasheet.

    I did that for all types I use and it worked !!

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


    Did you find this post helpful? Yes | No

    Default datasheet

    hi
    i just tested my port with few led and they work fine, inputing and outputting.
    but the srf04 is still not working.
    I have no idea of what is going on.

    anybody with an idea????

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    - Try External clock !!! ( internal Osc is "not so accurate" ...)

    - Place "Low trigger" just before "Pulsout"

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  7. #7
    Muaz's Avatar
    Muaz Guest


    Did you find this post helpful? Yes | No

    Default

    Hi, This post of mine is very knowledgable and may enhance the information of the viewers , however I would like some specific information for myself. If someone can help me then please send me a private message. Best Regards,

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