Shop OBEX P1 Docs P2 Docs Learn Events
Sharp infrared sensor GP2D12 — Parallax Forums

Sharp infrared sensor GP2D12

arealareal Posts: 5
edited 2006-12-17 09:44 in Learn with BlocklyProp
Hi,

I'm currently working on a school project which i need to use a Sharp infrared sensor to measure distance. I was told that i need to calibrate my sensor reading. Although i've read the information from www.acroname.com·but i don't understand how i should do it. Can someone pls explain(more detail..pls)·how·to calibrate the sensor reading for accurate measurement? Thanks much.

magdalene

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 16:51
    www.acroname.com/robotics/parts/SharpGP2D12-15.pdf
    Analog·output voltage. (indication of 10-80cm,·4 to 32·in.)

    Post Edit:
    1) You're going to need to interface an analog signal to a digital input (via ADC, other means)
    2) The output of the D12 is "non-linear".· Save some EEPROM space for a·"look-up" table.
    3) What degree of "accuracy"?

    [noparse][[/noparse] Corrected a mistake in my metric to English conversion. ]


    Post Edited (PJ Allen) : 11/26/2006 8:42:32 PM GMT
    323 x 285 - 18K
  • arealareal Posts: 5
    edited 2006-11-26 19:29
    yes a 8-bit adc is to be used, accuracy required is about +/- 5cm.

    What should i do with the "non-linear" curve? I couldn't really get the distance values as shown by the curve. How should i calibrate this? Besides, in the excel file provided by acroname, there's a cell named "voltage", does it mean the reference voltage supplied to the adc?

    Initially i intend to convert the adc readings to distance readings by using the equation of the non-linear curve generated from excel "display curve equation"·function, but PBasic can only read integer. The equation generated involves floating points like 0.000037x^4+...+3.2236883. I got stuck here and don't know how can i calibrate it properly...

    Kindly·pls advise, if possible·can describe a bit more in detail pls? Thanks!!!

    magdalene
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-11-26 20:39
    The sensor output goes to the ADC input, the ADC output/s to the Stamp.· Supposing you get that much.·

    If you have a voltmeter, you should be able to hook up the sensor itself on a protoboard and·monitor·its output voltage as you place/move an object before the sensor, without a Stamp, or anything else, just to get a feel for what's happening.

    Then·I'd program the Stamp to just read the ADC and display that value using DEBUG.· Then I'd place an object before the sensor and note the values·returned by DEBUG, in 5cm steps,·in the range you are to measure (the range is 10-80cm, 70cm, that's 14 data points.)· With those values you could make up a·reference table in EEPROM.·

    So, later, when you need the Stamp to determine a distance, you'd have it read the ADC and compare it to your previously stored values.
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2006-11-30 05:05
    Here is a tutorial from MadLabs...

    madlabs.info/gp2d12/sharp_gp2d12.shtml

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • ZootZoot Posts: 2,227
    edited 2006-11-30 16:21
    Attached is an Excel spreadsheet that can be used to come up with a single equation for "linearizing" the output from the Sharp. Take readings with an object at 10cm, 20cm, ... up to 80cm and note the raw readings you get from your ADC. Those figures can be plugged into the table to generate the constants used for converting the raw measurement to linearized centimeters (this is not my file, btw). This is a possible alternative to an EE lookup table.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • arealareal Posts: 5
    edited 2006-12-11 02:54
    Hi Zoot,

    Can i know in the excel spreadsheet u mentioned, what is the input for supply V? is it 5V supplied from Basic Stamp Vdd pin or the voltage supplied to the reference pin of the ADC?

    Thanks!!

    mag
  • ZootZoot Posts: 2,227
    edited 2006-12-11 23:26
    Not sure if I totally understand your question. The spreadsheet lets you convert read values from your ADC to linearized cm. -- so it doesn't really matter what the actual read voltage is -- what matters is the reading you get at 10, 20, 30 cm, etc.

    If you are asking what 5v supply to use to power the Sharp, use an outboard regulator (like the regulator on a BOE) not the Vdd supplied by a Stamp (which I don't think will handle the current needed by the sharp).

    If you are asking about reference voltage, you need to divide 5v for reference. I would check documenation for your ADC.

    You can always check the actual voltage output of the Sharp by connecting a voltmeter to the sharp output pin and measuring it -- the closer you are the higher the voltage will be.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • arealareal Posts: 5
    edited 2006-12-12 02:32
    Hi Zoot,

    Sorry for my unclear message. The supply V i meant is actually the value which we are required to input in the spreadsheet which you mentioned. I've attached the pic for your reference. So is this supply V 5V or reference voltage?

    Thanks!!

    mag
    512 x 323 - 39K
  • ZootZoot Posts: 2,227
    edited 2006-12-12 13:39
    I believe that's the reference voltage, but you don't need to set that in the spreadsheet to get your 3 constants for the linearizing formula.

    You can just use the second table down on the left and enter your actual readings that you SHIFTIN from the ADC and the corresponding cm. values for your tests and the spreadsheet will generate your constants.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • ZootZoot Posts: 2,227
    edited 2006-12-13 23:56
    crustcrawler.com/code/sharp_ir_ADC0831_reader.bs2

    The above might be handy -- it's got circuit for setting up an ADC8031, the Sharp, and some test code. I would still use the spreadsheet and your own readings to get your 3 constants -- in my experience every IR ranger is slightly different, and wire lengths, your circuit, etc. can influence the exact readings you get on your own rig.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • arealareal Posts: 5
    edited 2006-12-17 09:44
    Thanks much Zoot for ur kind help! If i have question again will ask u here again ^^
Sign In or Register to comment.