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

Can’t tell just from that,

Can’t tell just from that, but if you get something thats usually a good sign.

First thing is to make sure the code is in a loop so that multiple readings can be done. Otherwise you’ll only have one reading and thats it.

 

Thanks for that. It is in a

Thanks for that. It is in a loop so I don’t think tht’s the problem.

 

Does anyone know what the values in those four columns represent? My readings have changed slightly to:

 

122, $7A, %01111010, ‘z’

 

If I knew what columns were, maybe there’s a clue to be found in the change in readings from $7B to $7A or from ‘{’ to ‘z’.

 

Thanks.

 

TH

The columns are all saying
The columns are all saying the same thing: 122 in decimal is 7A in hexidecimal which is 01111010 in binary which is ‘z’ in ASCII. To make your life easier you can just ignore all but the first column.

Are you sure it’s looping

Are you sure it’s looping though?

Add a counter to verify it or add an led that blinks on reading.

I reprogrammed it and
I reprogrammed it and verified that it’s looping. The readings just don’t change. I did notice, however, that the reading is now down to 121 (first 123, then 122, now 121). Maybe this steady decrease is an indication that I received a defective sensor? Could I just be unlucky?

it’s possible that the
it’s possible that the sensor is bad. have you tried another component, like an LDR? thats a super simple device that should give you a good idea if things are working at least with your code.

Unfortunately, I don’t have
Unfortunately, I don’t have any other components to test with as I only bought the components that were required to complete the tutorial, nothing more. What’s an LDR? I guess I’ll test it out with that.

trymain:readadc 1,

try

main:

readadc 1, b1

debug

goto main

The housing of the Sharp IR
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.

Patrick: That is exactly the

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.

Try powering the sensor and

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.

Can you take a few pictures

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?

well

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! :smiley:

Complete novice here

with just the same problem.

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

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. :slight_smile:

Re-soldered the signal wire

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 dont understand what all**<br><p>I dont 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.

@TobyhoofIf you can, post a

@Tobyhoof

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

Hey, thanks for the response.
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.