Sharp IR Sensor giving weird pulsing readings

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
skudfisher
 
Posts: 5
Joined: Thu Mar 22, 2012 10:19 pm

Sharp IR Sensor giving weird pulsing readings

Post by skudfisher »

So about a week ago I hooked up a Sharp IR sensor to a standard Arduino Uno on analog 0 and connected a little servo and wrote some code that made the servo arm move proportionally to the input from sensor. It was very basic and it worked great and I had no problems at all. So I set it aside for a week as I waited for new parts to arrive in the mail...

Today I plugged it in and nothing it working properly. I couldn't figure out why at first and narrowed it down to the IR sensor. I hooked the sensor up to my arduino alone and wrote some very basic code (which i'm 100% is correct) onto it to read from it and print it to the serial monitor and it seems like the input is just pulsing from 0 to 200 and back again rhythmically no matter what you move in front of the sensor. I can't figure out why this would happen. I've tried different analog pins in case it was shorting out somehow or something but it does the same on all of them.

A week ago all of this was working perfectly. Any idea what's going on?

Oh, and I also have a Maxbotix Ultrasonic Rangefinder which works perfectly with the exact same setup... is my Sharp IR sensor busted? Did I maybe short it out somehow? I bought it 2 weeks ago... Thanks

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Sharp IR Sensor giving weird pulsing readings

Post by adafruit_support_bill »

the input is just pulsing from 0 to 200 and back again rhythmically
0-200 raw counts? Or is that scaled to some units? What is the approximate period of the pulsing?

skudfisher
 
Posts: 5
Joined: Thu Mar 22, 2012 10:19 pm

Re: Sharp IR Sensor giving weird pulsing readings

Post by skudfisher »

Yeah, raw counts (just the number read directly from the pin). I would say about 10 seconds for each pulse. It's very odd. It gives 0's for about 3 seconds then runs up to somewhere between 175-200... then scales back down to 0 again in 10 second cycles. It just does this over and over again regardless of what I place in front of it. Even if I cover it up completely and don't move the cover.

And as I said, it was working fine a week ago with the exact same setup. I find it very odd.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Sharp IR Sensor giving weird pulsing readings

Post by adafruit_support_bill »

That is very strange behavior for that sensor. Can you post a photo of how you have it hooked up? Also the code you are using.

skudfisher
 
Posts: 5
Joined: Thu Mar 22, 2012 10:19 pm

Re: Sharp IR Sensor giving weird pulsing readings

Post by skudfisher »

Image
Image

Really super simple code and setup. I can't see anything I've done wrong. Also, I have a Maxbotix Sonar sensor that works perfectly with this exact same setup (pin A0 and those same 5V and GND pins).

You can see in the left the readout I'm getting (which today has decided to cap at around 65 instead of 200). If I switch the delay(100) to delay(10) or comment it out the readings I get are all over the map and not a smooth pulse... It seems incredibly strange to me...

And it was working fine a week ago! :)

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Sharp IR Sensor giving weird pulsing readings

Post by adafruit_support_bill »

That is pretty simple. And very strange! You're sure it wasn't accidentally hooked up backward at some point?

User avatar
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 6:59 pm

Re: Sharp IR Sensor giving weird pulsing readings

Post by philba »

Be careful where you place the sensor. You can get scatter echo from a surface parallel to the beam direction. creates really random readings.

Also, you should clean up the power and ADC part. The device pulls a fair amount of current to light the IR emitter and that puts some stress +V rail. So, I'd try a couple of things:
- use a 33 uF (or larger) bypass cap on the +V and Gnd leads of the sensor
- use 3.3V for your VRef.

Ignore the coincidence of all the 3s above... lol

Basically your device is putting noise onto the +5V rail. The bypass cap mitigates that somewhat. (I have 3 of those sensors on a sumobot and without the caps, it goes amok!). Using the 3.3V rail gives you a more stable reference source. If super solid readings are important, I'd get a separate Vref chip.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”