Offline
Sr. Member
Karma: 0
Posts: 381
|
 |
« on: October 20, 2011, 12:32:25 pm » |
Dear all
I'm in the process to implementing a sharp GP2Y0A02YK0F (20-150cm) ir distance sensor in my project. Reading around it draw much more current than 30mA medium when it fires and that make the sensor to return some heavy spikes on the power supply and consequently bad distance reading.
After reading a lot I saw some solution adding capacitors and resistors here and there, but I'm not sure how to do that and which one solution is correct.
Could someone help me making the right filter? Note that my arduino platform is powered by eight 1.2v rechargeable batteries. Could be a problem?
Please help me. I'm pretty sure about the arduino code, but have problem with electronics.
Regards.
|
|
|
|
|
Logged
|
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1540
|
 |
« Reply #1 on: October 20, 2011, 04:16:23 pm » |
From the datasheet:
●Advice for the power supply • In order to stabilize power supply line, we recommend to insert a by-pass capacitor of 10μF or more between Vcc and GND near this product.
In your code you might also try calling analogRead() twice and only use the second result -- see if that gives a more reliable reading.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 277
Posts: 25501
Solder is electric glue
|
 |
« Reply #3 on: October 21, 2011, 05:10:27 pm » |
I know what the datasheet say In electronics what the data sheet says should not be disregarded. There are two things those threads suggest:- 1) Improving the supply decoupling, like the data sheet says and you can read about here http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html2) Actually smoothing the analogue signal from the sensor to remove noise from it. Try 1 first, only go to 2 when you have further problems.
|
|
|
|
|
Logged
|
|
|
|
|
Dubuque, Iowa, USA
Offline
Edison Member
Karma: 13
Posts: 1540
|
 |
« Reply #4 on: October 21, 2011, 05:31:15 pm » |
In addition to the decoupling capacitor, In your second link there's a post that says you should also ground the black plastic case of the sensor. It would be something simple to try...
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 381
|
 |
« Reply #5 on: October 24, 2011, 08:40:01 am » |
Thank you very much. I will try as explained in the datasheet.
Could you please help me in another thing? I'm working with 9*1.2V battery for arduino power totale 9.6V.
The sharp ir sensor work from 4.5 to 5.5V. Do I need to stabilize the power out of arduino for my sensor?
Regards.
|
|
|
|
|
Logged
|
|
|
|
|
Netherlands
Offline
Tesla Member
Karma: 90
Posts: 9401
In theory there is no difference between theory and practice, however in practice there are many...
|
 |
« Reply #6 on: October 24, 2011, 10:25:27 am » |
The Arduino makes 5V from the 9.6V by means of an LM7805 (voltage regulator) If you connect the rangefinder to the Arduino 5V pin it should work. Have played with a rangefinder too, resulted in the multiMap() function for interpolation of the distances, see - http://arduino.cc/playground/Main/MultiMapmight be usefull,
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 381
|
 |
« Reply #7 on: October 24, 2011, 01:40:28 pm » |
Unfortunatly no luck  Spikes remain as you can see from serial output after adding 10uF capacitor as described in the ddaatasheet. Any hints? I'm not doing any calculation, only value from sensor. 236 236 228 <-- 238 237 236 236 238 237 236 238 236 236 237 236 236 238 228 <-- 236 237 263 <--- 237 236 237 236 236 237 239 236 236 236 237 228 <-- 236 237 237 237 237 236 236 237 237 236 237 237 237 237 245 <-- 237 237 236 237 241 <-- 248 <-- 237 236 236 237 237 237 232 236 236 236 237 237 237 243 <-- 256 <-- 237 236 236 236 236 237 237 237 237 236 237 236 237 237 237 237 238 237 243 <--
|
|
|
|
|
Logged
|
|
|
|
|
New Hampshire
Offline
God Member
Karma: 13
Posts: 776
There are 10 kinds of people, those who know binary, and those who don't.
|
 |
« Reply #8 on: October 24, 2011, 02:18:59 pm » |
Mid to low 200 values are in the range of voltages which correspond to the bottom of the non-linear range of readings from the Sharp sensor. As a result, even moderate jumps in ADC values only correspond to relatively small changes in distance readings. Perform the conversion calculations and see what kind of variation you are getting in terms of actual distance readings. If you're within +/- 1 cm in real world operation, you're doing excellent. If it's worse than around +/-3-5cm, then there's likely room for improvement. Don't expect too much from these sensors. Here's a good resource for linearizing the output from these sensors: http://www.acroname.com/robotics/info/articles/irlinear/irlinear.html
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 381
|
 |
« Reply #9 on: October 24, 2011, 03:13:47 pm » |
Thank's a lot. Very good info you give.
I will try with distance calculation as soon as I can. Below the distance formula used for this sensor in the shop where I bought it.
Distance (cm) = 9462/(SensorValue - 16.92)
You said to not expect too much from this sensor. Do you know any other Ir sensor with a range from 20 to 150cm or more?
Regards.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 381
|
 |
« Reply #10 on: October 26, 2011, 01:28:31 am » |
After some tests calculating distance measurements, I have spike values around.
Distance from the wall 105cm, this is what I had in serial monitor:
106 107 106 107 107 123 <- 107 106 107 95 <- 107 108 106 105 107 106 128 <-
and so on.
Seems a very difficult sensor to use for may application.
|
|
|
|
|
Logged
|
|
|
|
|
New Hampshire
Offline
God Member
Karma: 13
Posts: 776
There are 10 kinds of people, those who know binary, and those who don't.
|
 |
« Reply #11 on: October 26, 2011, 10:57:26 am » |
Could you show the code and wiring schematic for your setup?
Those spikes seem excessive.
Are you switching ADC channels in between readings?
Is your ADC circuitry well isolated?
Can you average ADC readings to mitigate the spikes? (keep in mind that the sensor operates relatively slowly, about 40ms between readings. This provides ample time to take multiple readings and average them to reduce the impact of noise on the ADC line.
Also, the surface the IR sensor is reading against can influence the results. A textured or specular surface can cause larger variations in readings. Also, going from brighter to lighter surfaces will change the readings as well. I can't remember the direction, but a black matte surface will read as either closer or farther away than a white matte surface, both at the same actual distance.
|
|
|
|
|
Logged
|
|
|
|
|
Belgium
Offline
Newbie
Karma: 1
Posts: 16
The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt. - Bertrand Russel
|
 |
« Reply #12 on: December 21, 2011, 09:24:44 am » |
These reading are strange and might be caused by a low supply voltage. The sensor should work at 3.3V, but if you have a 5V Arduino board, I would advise to use the 5V Vcc. PS: I did some sensor calibration tests and created a small library: http://arduino.cc/forum/index.php/topic,83947.0.html
|
|
|
|
|
Logged
|
|
|
|
|
|