# Decimilia w/ Sharp IR sensor

Hello- I have my Decimilia board connected to a Sharp IR sensor model GP2Y0A700K0F. Where can I find the code to make them work together so I can view the measured distance?

Thanks very much.

The sensor you mention has been discontinued and replaced by the GP2Y0A710K0F. The sharp website says they are comptible except for mechanical issues.

So, the datasheet for the GP2Y0A710K0F will be useful and can be seen here:

There are a few things to note:

1) The output is a straightforward analogue output, so reading a distance measurement is as simple as connecting the output to one of the ADC pins on the Arduino and reading the value.

2) The output is non-linear. If you look at Figure 2 on page 5 of that datasheet you will see the output voltage for measured distances. If accurate distances are required you will need a way to compensate for this non-linearity. The second graph shows the output for 1/distance is pretty straight, so this may be ok.

3) The output doesn't cover the whole 0 to 5V input range of the ADCs meaning that you won't get much resolution. This may be ok, it depends on your application, but the best way to solve this is with an op-amp or two to provide offset and gain.

4) The sensor can't differentiate between distances less than about 80cm and those more than that. What distances are you looking to measure?

5) Although the typical supply current is spec'd at 30mA, the "Advice for the power supply" section it recommends a fairly high power supply requirment of 350mA.

From the graphs, the gradient of the straight(ish) line is (0.01 - 0.003) / (2.5 - 1.5) --> 0.007.

Extending the line to the output voltage axis gives an offset of 1.15.

So a simple equation can be used to go from voltage to 1/distance . . . 1/d = (V - 1.15) * 0.007.

The reciprical of that gives the distance. A few numbers plugged in shows it is close-ish.

Vo D 1.5 408 2.0 168 2.5 105

So the code without external op amps would be to

1) read the ADC (several times and smooth if necessary) 2) Do the sum.

I hope this helps a bit.

Mike

Thank you BigMike for the response. I learned a bunch and hope you can help with some of the details.

In item (3) you suggest including an op-amp or two to provide offset and gain. How do I accomplish this? I assume I need to add some kind of component?

In item (4) you ask what kind of distances I am looking to measure - my range is appx 3-4ft and I hope to measure down to as small an increment as possible within that range.

How do I add a larger power supply? I know that basic power can be supplied through the USB port - where would I connect an external power supply to the board? Would something like 12V 350mA work?

Thanks very much. I appreciate your help.

Tobee11

Here is a link to the wiki page on op-amps:

at the bottom of the page is a bunch of links to op-amp circuit collections. You can probably do what you need to do with a basic inverting or non-inverting op-amp circuit. You should be able to find one in the linked articles or someone here may be able to jump in and help out.

Your range is within range of the device, but it is right at one end of the range. 3- 4ft when the maximum is about 18ft. This will limit the increment you can measure. If you adjust the gain of the op-amp so that it amplifies the sensor output to, say, 5V for a 5ft (roughly 1.5 metres) measurement that may help things. With that set up, at best, the Arduino ADC will be able to measure to about 1.5 mm. (1.5 m / 1024 ). This is in ideal conditions. Noise and the inadequacies of the sensor will all play a part in limiting

As for the power supply unit - the sensor needs a regulated 5V supply rated at at least 350mA. I’m not sure if you can draw this from the USB connector. I would want to get a separate power supply for it. You may be able to track down a wall wart or some similar supply.

Is this a one off experimental thing? Will it be a permanent device? Are you going into production with it. This affects what you get as a power supply.

Sorry I can’t help with more specific information.

Regards,

Mike

This is a experiment I am running. Hopefully this method works well and will turn into something bigger. I believe I'll be able to make some headway from here - thanks again for your suggestions BigMike!