Sharp GP2D12 Range Finder???


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario
    Posts
    23


    Did you find this post helpful? Yes | No

    Unhappy

    hmm.. .

    Doing some more testing with a2d I've noticed that in order to get an accurate voltage reading for example on porta.0, the input must come from some form of voltage divider with both 0 and +5v as ref.(a pot for example with a2d on wiper)
    Is this due to an adcon setting or something like that. My point is does the sharp sensor need a voltage divider at input??? Getting more confused.....

    john

  2. #2


    Did you find this post helpful? Yes | No

    Default No voltage divider needed

    The Sharp distance sensor is powered from 5 volts, the same as your PIC. I just take the Sharp output direct to the PIC with a 1 uF smoothing capacitor from the sensor output to ground. The Sharp updates every 40 mSecs or so and the smoothing capacitor is probably unnecessary but I usually smooth all inputs to the ADC out of habit.

    After setting up ADCON0 and ADCON1 I leave at least 50 uSecs for the ADC to settle before I set the Go/Done bit to start the conversion.

    Code snips for a PIC 16F877A

    ReadSharpSensor: ' channel 5
    ADCON0 = %11101001
    ADCON1 = %10000000
    gosub getadcval
    Height = adcval

    This is the GetADC subroutine

    GetADCVal: ' the calling point needs to set ADCON0 & ADCON1 first
    pauseus 50
    clearwdt
    ADCON0.2 = 1 ' starts conversion
    WaitConversion: ' get ADC result
    IF ADCON0.2 = 1 then waitconversion ' loop until conversion ends
    adcval.highbyte = ADRESH ' upper two bits of result
    adcval.lowbyte = ADRESL ' lower eight bits of result
    return

    HTH
    Brian

Similar Threads

  1. Questions on ultrasonic distance finder
    By lilimike in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 20th April 2010, 21:19
  2. using a pot to control a time range
    By glkosec in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th June 2008, 19:59
  3. Sharp GP2D12 8bit
    By Argo in forum mel PIC BASIC
    Replies: 0
    Last Post: - 25th October 2007, 23:40
  4. sharp GP2D12 interface pic16f676
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th April 2006, 17:26
  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