Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: BANE on February 17, 2008, 08:09:48 AM

Title: making range finding prg. for Sharp IR Sensor?
Post by: BANE on February 17, 2008, 08:09:48 AM
Hello, I have a GP2D12 Sharp IR sensor that i'm trying to make a range finding program and not having luck :(.  I'm programming with BASIC MICRON software using the BOT BOARD II and BASIC Atom 28-pin.   

BOT BOARD II
http://www.lynxmotion.com/Product.aspx?productID=252&CategoryID=66 (http://www.lynxmotion.com/Product.aspx?productID=252&CategoryID=66)

BASIC Atom 28 - pin
http://www.lynxmotion.com/Product.aspx?productID=269&CategoryID=66 (http://www.lynxmotion.com/Product.aspx?productID=269&CategoryID=66)

I already tried asking on Lynxmotions forum, but no inteligent responses :'(.

Please help.

Bane
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: Admin on February 20, 2008, 08:00:50 AM
What do you want your program to do? Can you show us what code you've tried but failed with?

If you are just trying to read the sensor with code, look up the Analog-to-Digital converter examples.
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: airman00 on February 20, 2008, 07:53:42 PM
whats the problem?


Are you getting "good" values of the Sharp IR sensor from the ADC?
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: BANE on February 21, 2008, 12:13:41 PM
see pic (amazing art skillz!)

In the program i want to tell the servo to run until the IR sensor reads a certain value (what ever that value is).
Ex. I want for the robot to move 6" from the sensor, the program should activte the servo in the right direction until the sensor reads 6" and stops.  (to get the servo moving in the right direction,   "If sensor reads X< desired move, then move robot away from it, if X> then desired position, than move towards until right value."  Now that what i want it to do, but i need some info on how to get the sensors values (data sheet) that would be given and the conditional statement that i discribed.

Hope this is enough info ;)

(all ready have data sheet advalable on website, but couldn't find it helpful)

Bane
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: airman00 on February 21, 2008, 05:58:11 PM
what i need to know first ,is does the value of the Sharp IR sensor change with distance

Just hook up a MCU and LCD to see the values
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: BANE on February 21, 2008, 06:41:50 PM
yes, the sensor is stationary and the robot on the track is whats moving.  But i don't have a MCU or LCD to display their values.  Am I scruwd with out it or can i just play with what values it has by debugging.  But first i need to write a program that use the IR sensor

here is the pic again.

bane
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: airman00 on February 21, 2008, 07:01:33 PM
invest in a serial LCD  and you can control a SERIAL LCD with one microcontroller


Just make sure you buy a serial LCD and not parallel , serial uses one pin on your micro
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: BANE on February 22, 2008, 06:11:44 AM
like this one
http://www.lynxmotion.com/Product.aspx?productID=61&CategoryID=105 (http://www.lynxmotion.com/Product.aspx?productID=61&CategoryID=105)

is there anyother way around it?

bane
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: airman00 on February 22, 2008, 08:29:47 AM
over here is cheaper http://melabs.com/products/displays.htm (http://melabs.com/products/displays.htm)
Go with 4 line LCD since its only 10 bux more than the 2 line one

LCDs are necessary for debugging ( or you can do UART to your computer.... )
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: BANE on February 22, 2008, 05:26:47 PM
question:  even if i do get the display, i still need to have a program to take input from the IR sensor and display it on the screen?  What i really need is the program  ???(is that logical?)

bane
Title: Re: making range finding prg. for Sharp IR Sensor?
Post by: Admin on February 23, 2008, 03:57:00 PM
This is the program you would use (in pseudocode):

Code: [Select]
sensor_value = analog(rangefinder);

sensor_value = sensor_value*convert_constant;//convert to metric units

if(sensor_value > 6)
  servo(clockwise)
else if(sensor_value < 6)
  servo(counterclockwise)