Let's Make Robots!

Sharp GP2D120 IR Sensor Readings

Hi.

 

I just built my first robot following the "First Robot" tutorial. The only problem I am having is with the Sharp GP2D120 IR sensor. When I run the code as per the tutorial (i.e. "readadc 1, b1" and "debug"), the values for b1 are displayed as:

 

123, $7B, %01111011, '{'

 

The readings do not change even if I put something in front of the sensor. Do those readings provide a clue as to what is wrong with my robot?

 

Thanks for any help you can provide.

 

TH 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

@Tobyhoof

If you can, post a photo or an accurate diagram of where you have wired stuff up like OrdinaryDave did.

with just the same problem.

When I say novice I mean virtually no experience here at all. So I'm sorry. :p

As I say, I have the same problem, although the readings I get fluctuate between about 120 and 140.

Here's a picture of what I've done: http://www.b3tards.com/u/a4ccb79cb7aa28350d3d/circuit.gif

The white wire is the signal wire from the sensor. The power and ground wires are elsewhere on the board (In a V and a G).

The blue lines are where I've soldered short wires between the points, to short them out. Only I'm nto sure they're the right points. After reading the circuit board manual and the instructions on this site, I made a guess at that, but could well be wrong.

 

Thanks for any help. :)

Re-soldered the signal wire onto the pin next to the hole it was in and now get a constant reading of 225. Here's a picture of the whole circuit: http://www.b3tards.com/u/a4ccb79cb7aa28350d3d/circuitphoto.jpg

Any help would be fantastic. I'm completely lost and just guessing at stuff, tbqh.

I don`t understand what all those connections over on the analog pins are and I can`t make any sense of the manual. It has a schematic for a stamp like module but no diagram showing your boards pins and google is absolutely no help. Yay for blackbox hardware. I did find Frits walkthrough about that picaxe starter kit though. From the look of it you have connected the sensor cable to ground and the analog in to +ve which is why you have a constant 255.

Remove all the short blue wires and connect the white wire from the sharp IR to the centre pin instead of the hole.

Although it turned out it was just my dodgy soldering skills on the signal wire. It works fine now! He's been trundling around and exploring the house.

1) make sure:

a) black wire goes to negative (ground)

b) red goes to positive (v)

c) blue (the signal one, i think it's blue) goes to ADC pin 1

2) you should supply it with 5 volts, more or less

3) I'm also pretty sure you should short all the other analog input pins on the Picaxe to V (positive)

 

Hope it works! :D 

Can you take a few pictures and show us the code.

Its good there is a reading but im not sure why  is it not changing.

How many volts are you using?

Try powering the sensor and reading the signal pin with a meter. If you have a variable voltage up to 2 volts or so with moving your hand in front of it, then the sensor is good.

Then check your connections to micro, common ground, correct input pin, etc.

Haven't looked at code. 

Patrick: That is exactly the code I used initially.

 

RobotFreak: The sensor is attached to the plastic rotating disk part of the servo using black electrical tape. I'm pretty sure it's isolated.

 

Thanks for the suggestions.

 

How sensitive are these sensors? I know my kids dropped them once or twice.

The housing of the Sharp IR Sensors is conductive. If you put it on a metal chassis of your robot, it may cause this behaviour. Try to isolate the sensor from the chassis.