Author Topic: Need Help Using SHARP IR Distance Sensor  (Read 7744 times)

0 Members and 1 Guest are viewing this topic.

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Need Help Using SHARP IR Distance Sensor
« on: October 21, 2011, 12:42:37 AM »
Dear all

I'm in the process of 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 and maybe a schema? 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 schema.

Regards.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #1 on: October 21, 2011, 01:07:26 AM »
Just add 100nF cap beween positive and negative leads of Your sensor.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #2 on: October 21, 2011, 01:29:41 AM »
Just add 100nF cap beween positive and negative leads of Your sensor.

Thank's a lot. So, a 100nF instead of the 10uF from datasheet is better? This because I use eight 1.2V batteries for my arduino platform?

That's all? Only 100nF cap between Vcc and Gnd and I solve all the false reading? Does this make problem to GP2Y0A02YK0F reading speed?

regards.


Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #3 on: October 21, 2011, 02:17:13 AM »
I do hope You use regulated voltage and not 8x 1.2V = 9.6V as MAX sensor supply voltage is 7V and recommended one is 4.5V to 5.5V.

So, a 100nF instead of the 10uF from datasheet is better?
If datasheet recommends 10uF (and it does), then use 10uF cap.

That's all? Only 100nF cap between Vcc and Gnd and I solve all the false reading?
I don't know, You tell me after you try it  ;)

Does this make problem to GP2Y0A02YK0F reading speed?
It does not, it actually improves it as cap compensates for sudden voltage drops.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #4 on: October 21, 2011, 02:19:45 AM »
I do hope You use regulated voltage and not 8x 1.2V = 9.6V as MAX sensor supply voltage is 7V and recommended one is 4.5V to 5.5V.

Thank's a lot. More clear ideas now.

Could you please tell me how to give 5.5V to my sensor out of 9.6V I give to Arduino?

Regards.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #5 on: October 21, 2011, 05:27:50 AM »
Could you please tell me how to give 5.5V to my sensor out of 9.6V I give to Arduino?
So You were running Your sensor on 9.6V  :o You must use voltage regulator such as LM7805.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #6 on: October 21, 2011, 05:51:37 AM »
Could you please tell me how to give 5.5V to my sensor out of 9.6V I give to Arduino?
So You were running Your sensor on 9.6V  :o You must use voltage regulator such as LM7805.

no, not at the moment I never running my Sharp IR sensor at 9.6V. I use 9.6V for other sensors I have.

But, now, I need to start using Sharp IR and I'm asking how to limit it to 5.5V due to 9.6 output from arduino :)

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #7 on: October 21, 2011, 06:02:21 AM »
How do You know that Your IR Sharp sensor gives false readings if You did not plug it in?  ;D
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #8 on: October 21, 2011, 06:33:04 AM »
How do You know that Your IR Sharp sensor gives false readings if You did not plug it in?  ;D

That's a nice question  ;D

I read more and more around before trying the sensor. Maybe too much  :-\

What do you think about something similar to use instead of LM7805?
http://en.wikipedia.org/wiki/Voltage_divider

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #9 on: October 21, 2011, 07:00:38 AM »
What do you think about something similar to use instead of LM7805? http://en.wikipedia.org/wiki/Voltage_divider
OK, to start with, Your controller board and all sensors must get regulated voltage in order to provide You with error free (to some extent) readings and calculations. Some controller boards have embedded voltage regulators, hence You can power them with unregulated supply. When it comes to sensors, only a handfull (if any) of them can take unregulated voltage. In order to get accurate reading, voltage level has to be the same all the time. Here comes the problem when using voltage divider. Say, if You set voltage divider to output half of the input voltage (in your case 9.6V / 2 = 4.8V), when battery pack gets partly discharged it may output only 8V instead of 9.6V, hence voltage divider output becomes 4V - which is too low for your IR Sharp sensor to work reliably (see datasheet). However, if You use voltage regulator (You can imagine it as automatic voltage divider which maintains constant output voltage level) You get constant voltage as long as input voltage supplied to the regulator equals to regulated voltage plus voltage drop across regulator (so in Your case it is 5V + 2V = 7V).
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #10 on: October 21, 2011, 07:13:27 AM »
Very clear. Going to learn how to connect those LM7805 to my configuration... Does this LM7805 have problem giving much than 150mA to the output?

The sharp ir sensor has peak around 220mA.

Thank's.
« Last Edit: October 21, 2011, 07:21:16 AM by GS88 »

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #11 on: October 21, 2011, 08:52:47 AM »
Going to learn how to connect those LM7805 to my configuration...
Always analyze datasheet as it tells/shows You everything about the device. LM7805 datasheet shows You the following:



What it means is:
  • Battery pack +terminal goes to INPUT pin of LM7805
  • Battery pack -terminal goes to COMMON pin of LM7805
  • IR Sharp positive wire goes to OUTPUT pin of LM7805
  • IR Sharp negative wire goes to COMMON pin of LM7805
  • IR Sharp signal wire goes to ADC pin of Arduino

Does this LM7805 have problem giving much than 150mA to the output?
Again, datasheet is Your best friend. As it states at the top - regulator can handle 1A.

The sharp ir sensor has peak around 220mA.
How do You know?  ;D Datasheet says: "Consumption current : Typ. 33 mA [...] Max. 50mA".
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #12 on: October 21, 2011, 10:10:47 AM »
Going to learn how to connect those LM7805 to my configuration...
Always analyze datasheet as it tells/shows You everything about the device. LM7805 datasheet shows You the following:



What it means is:
  • Battery pack +terminal goes to INPUT pin of LM7805
  • Battery pack -terminal goes to COMMON pin of LM7805
  • IR Sharp positive wire goes to OUTPUT pin of LM7805
  • IR Sharp negative wire goes to COMMON pin of LM7805
  • IR Sharp signal wire goes to ADC pin of Arduino

Dear, thank you so much. Saw it and some more example on google. Seems quite simple to have 5V from my 9.6V output with LM7805 and some capacitor:
http://www.epanorama.net/circuits/psu_5v.html

Quote
Again, datasheet is Your best friend. As it states at the top - regulator can handle 1A.

Yes. From the link above:

"This circuit can give +5V output at about 150 mA current, but it can be increased to 1 A when good cooling is added to 7805 regulator chip. The circuit has over overload and therminal protection."

Quote
How do You know?  ;D Datasheet says: "Consumption current : Typ. 33 mA [...] Max. 50mA".

Searching in google the 33mA is the average value, but it has a peak power consumption of about 200 mA:
http://www.emartee.com/product/42073/Arduino%20Sharp%20IR%20Sensor%20%20%20GP2Y0A21YK0F

Aren't they right?

Regards.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: Need Help Using SHARP IR Distance Sensor
« Reply #13 on: October 21, 2011, 11:54:39 AM »
Searching in google the 33mA is the average value, but it has a peak power consumption of about 200 mA:
http://www.emartee.com/product/42073/Arduino%20Sharp%20IR%20Sensor%20%20%20GP2Y0A21YK0F

Aren't they right?
That is quite unusual, as datasheet does not mention anything about 200mA peak. Anyway, better to be safe than sorry, so go for system that can handle 200mA peak.

Good luck  ;)
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Need Help Using SHARP IR Distance Sensor
« Reply #14 on: October 21, 2011, 07:02:17 PM »
No, the Sharp data sheet does not mention the peak current draw but it is real.

For the GP20120 sensor I measured a pulse repetition of 1.02 msec and a 120usec pulse. At the pulse edges the V+ at the sensor's connector spiked by 80mV then sagged by 13mV for the duration of the pulse. The resistance to the 78L05 regulator and 10uF cap was from 24ga wires 4cm long.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #15 on: October 21, 2011, 08:34:46 PM »
Hi,

Searching in google the 33mA is the average value, but it has a peak power consumption of about 200 mA:
http://www.emartee.com/product/42073/Arduino%20Sharp%20IR%20Sensor%20%20%20GP2Y0A21YK0F

Aren't they right?
You have to understand how the Sharp position sensors work.
The IR-LED is poked with high current pulses to get the range they have. In between each pulse is a pause where the IR-LED is off and the rest of the circuitry use only a tiny bit of current.

The current consumption, when averaged over time may be 33mA, but the pulses will be high (up to around 400mA for some of the types) and that is exactly why you need the buffer capacitor, which will lower the impedance of the power supply, as seen from the sensors position.
As long as you can supply say twice the average supply and you have a fairly low ESR capacitor as the buffer, you are in the green.

If this sensor has got the same timing as the GP2Y0D810Z0F; (14 bursts of 20µs (repeated each 160µs), 1µF is a bit underrated, as it allows the voltage to drop to near 1V if the supply cannot cope (200mA * 20µs / 1µ = 4V [drop from 5V]).
A 4.7µF cap will help by keeping the voltage drop to 850mV and 10µF will keep it to 400mV.

Code: [Select]
You want the pulses to look like this:
 ______
 |     |
 |     |
 |     |
 |     |
_|     |_


Not like this:
 _
 |\
 | \
 |  \
 |   \
_|    |_


The Sharp sensors need stiff supplies, as their outputs will be influenced by any supply "noise", but please don't try to solve problems  in circuits that you haven't even got the parts for yet.
Better burn your powder on something real  ;D
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #16 on: October 22, 2011, 02:28:03 AM »
Thank's a lot.

I'm going out to buy some capacitors and a LM7805 to give it a try :)

Will let you know soon. I hope  :)

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #17 on: October 22, 2011, 05:38:13 AM »
Hi,

I'm going out to buy some capacitors and a LM7805 to give it a try :)
Besides the 7805, you'll need two capacitors.
Something like 220nF (0.22µF) from the input terminal to ground and 22µF will be good from the output terminal to ground. The caps should be mounted as close as possible (without straining anything).

You'll need a heatsink as well, but as long as your current requirement is as low, a bit of aluminum plate of around a square inch (2..3mm) thick should do.

The input voltage for the regulator is best drawn directly from the positive pole of your battery, to avoid interference going through the supply lines and all the grounds should be going directly to the battery negative pole.
Add a fuse in each line, as close to the battery as possible - this gives the best protection.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #18 on: October 22, 2011, 07:20:11 AM »
Thank you very much :)

I'm trying the circuit and it seem work fine. In input line I have 8 1.2V rechargeable battery and 5V on output. I'm using 10uF capacitor for input line and a 0.1uF capacitor for output line.

I don't have a fuse :( didn't buy it this morning. Could you please tell me where to connect my tester for mA measuring?

Maybe I've connected it in a wrong way because 7805 become very hot.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Need Help Using SHARP IR Distance Sensor
« Reply #19 on: October 22, 2011, 08:39:31 AM »
Lets see: 8 x 1.2V = 9.6V. Dropped to 5V on the regulators output is a 4.6V drop times the current draw is the power wasted as heat in the regulator. If you are powering the Sharp sensor at 33mA avg then the regulator heat is 152mW. At 1A its 4.6W.

Now go look at the data sheet for the 7805 and read this note under the specs:
Quote
Note 2: The maximum allowable power dissipation at any ambient temperature is a function of the maximum junction temperature for operation (TJMAX = 125°C or 150°C), the junction-to-ambient thermal resistance (θJA), and the ambient temperature (TA). PDMAX = (TJMAX − TA)/θJA. If this dissipation is exceeded, the die
temperature will rise above TJMAX and the electrical specifications do not apply. If the die temperature rises above 150°C, the device will go into thermal shutdown.
 For the TO-220 package (T), θJA is 54°C/W and θJC is 4°C/W. 

This expresses how well the heat gets out of the die to the case (θJC) and to the surrounding air (θJA). If a heat sink is not used then the temperature = TA + Power * θJA or for 33mA: 22°C + 0.152W * 54°C/W = 30°C or 8°C above ambient. At 1A the temperature rise will be 4.6W * 54°C/W = 248.4°C which is way above the MAXIMUM junction temperature so the regulator will go into thermal shutdown. A heat sink is required.

Or using this equation from above:  PDMAX = (TJMAX − TA)/θJA and setting the values as: PDMAX = (125°C - 22°C)/54°C/W = 1.9W max which with a 4.6V drop is 413mA Maximum current and the regulator will get hot enough to burn your finger.


To measure the current through the regulator you can either put an Ammeter is series with the output or put a small valve precision resistor in series with the output and measure the voltage drop across the resistor then calculate the current with Ohm's Law. I prefer the latter method.

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #20 on: October 22, 2011, 03:45:40 PM »
Hi,

I'm trying the circuit and it seem work fine. In input line I have 8 1.2V rechargeable battery and 5V on output. I'm using 10uF capacitor for input line and a 0.1uF capacitor for output line.
Please at least swap the two caps.


I don't have a fuse :( didn't buy it this morning.
Add one at your first opportunity - it might save you a bad experience, like burning down your home.

The rest of your questions, you got good answers from waltr on, so no point in repeating it.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #21 on: October 24, 2011, 12:42:49 AM »
Thank's a lot all. Very useful info.

Could you please explain while I have to swap the two capacitors? Or maybe could you let me know how to calculate right capacitors value base don input and output needed voltage?

Regards.

Offline GS88Topic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #22 on: October 24, 2011, 12:34:53 PM »
Unfortunatly no luck :(

5V output but spikes remain as you can see from serial output. Any hints?

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 <--

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Need Help Using SHARP IR Distance Sensor
« Reply #23 on: October 24, 2011, 01:23:31 PM »
Hi,


Could you please explain while I have to swap the two capacitors? Or maybe could you let me know how to calculate right capacitors value base don input and output needed voltage?
On the input side you need something to remove noise and HF ripple, while on the output, you need to stabilize the regulator against spurious oscillations (and remove noise/ripple) - You don't calculate the values, but reading datasheets and application notes (and taking a few power conversion seminars) during most of my life makes it sort of a given thing ;D
The voltage rating of the caps should be selected as roughly twice the nominal voltage it will see (and at least 1.5 times the voltage in the circuit).
Keep caps, especially electrolytics, away from heat, as this is the prime cap-killer.


Unfortunatly no luck :(

5V output but spikes remain as you can see from serial output. Any hints?

236
236
228 <--
238
237
[Snip lots of numbers]
238
237
243 <--
I'm not sure what you're doing here?
I assume that you have gotten the sensor now(?) but what is it that you're testing and how is it wired?
At what distance do you have an obstacle?
According to the datasheet, the sensor should give an analog output between close to 0V and up to ~2.75V (NOT 5V!)

If you're running motors or similar and the wires to the sensor are long(-ish) and unscreened, you might get injected noise from the motor/whatever.
A microcontroller PCB that's not optimally designed may radiate a lot of hard noise as well.

An oscilloscope is the optimal tool to see if there's any noise on the power lines.
« Last Edit: October 24, 2011, 01:57:30 PM by Soeren »
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here