programs for infrared sensors

Have questions about a SparkFun product or board? This is the place to be.

Moderator: phalanx

Post Reply
leo357leo
Posts: 61
Joined: Sun Mar 28, 2010 12:17 pm

programs for infrared sensors

Post by leo357leo » Mon Mar 29, 2010 7:23 pm

Are there any programs from arduino to infra red sensor to measure changes in distance.

Thanks

riden
Support Volunteer
Posts: 1754
Joined: Fri Jun 03, 2005 10:41 pm
Location: Illinois

Re: programs for infrared sensors

Post by riden » Mon Mar 29, 2010 9:46 pm

Depending upon the distances involved, Sharp makes a line of IR sensors that work well with the Arduino. SparkFun carries them (see SEN-08958 and related products). For the code, Google "Arduino Sharp IR".
Ralph

leo357leo
Posts: 61
Joined: Sun Mar 28, 2010 12:17 pm

Re: programs for infrared sensors

Post by leo357leo » Tue Mar 30, 2010 5:18 am

Ralph, thanks for the info. I just bought an arduino and I'm learning the sketch language. I "v been on a few websites on programming the infrared for distance measurement.My project is to have the sensor on a post about 2 feet in front of me and I want the sensor to tell me with a buzzer when I've moved away from the sensor by more than 2 inches. Firstly, do you think infrred or ultrasound would be the best sensor. And do you have any ideas or websites on programs for this job.
Thanks,Leo

Michael J
Posts: 8
Joined: Wed Feb 03, 2010 7:56 am
Contact:

Re: programs for infrared sensors

Post by Michael J » Tue Mar 30, 2010 9:54 am

Hi,

I remember the Sharp sensors come in 2 varieties. I cannot remember the exact ranges but they are something like 2 - 12 inches and 4 inches and up. The output is analog and non linear. You can create a lookup table to map from the result returned by your A2D to a distance. I've done this with pretty good results.

The ultrasonic sensors (depending exactly which ones you buy) return one pulse at the start of a measurement and another at the end. You are responsible for measuring the time and then dividing by the speed of sound. These are very accurate, but do not handle reflections well.

So it depends a bit on what you want. If you want really precise measurements and the object of interest has a nice perpendicular surface, go for the ultrasonic. If the surface may be at an odd angle to your sensor, go with the IR. Lastly, the IR sensors may be affected by bright light.

Good luck,
Michael Jamet
See my FPGA cpu at sites.google.com/site/bunchofprojects.

leo357leo
Posts: 61
Joined: Sun Mar 28, 2010 12:17 pm

Re: programs for infrared sensors

Post by leo357leo » Tue Mar 30, 2010 3:33 pm

Michael, thank you for the reply. I am probably reflecting off clothing, so I think the IR would be better. Do you have any clues on programming the arduino so it tells me that I've moved away from the sensor by say 2 inches? Also I need a remote device to start the sensing. Any Clues?

Thanks, Leo

riden
Support Volunteer
Posts: 1754
Joined: Fri Jun 03, 2005 10:41 pm
Location: Illinois

Re: programs for infrared sensors

Post by riden » Wed Mar 31, 2010 6:56 pm

Could you give us a little more information? What are the distances involved and what is the nature of the remote activation you need? Your answers will help zero in on approaches.

As mentioned before, either a Sharp IR sensor or an ultrasonic sensor should do the trick. These devices usually have an analog output (as Michael said), so you can use the analogRead() function that reports on the output of the sensor. I've played with both types of sensors and they are really easy to use.

For remote activation, I'd consider using a cheap IR remote and a IR detector (like products from Vishay or Sharp). These receivers are more reliable than simple ir detectors because they are able to extract the remote data modulated on the IR signal.
Ralph

leo357leo
Posts: 61
Joined: Sun Mar 28, 2010 12:17 pm

Re: programs for infrared sensors

Post by leo357leo » Thu Apr 01, 2010 7:49 am

Ralph, thank you for your reply. If you can send me a program to convert analog to distance I would appeciate that. The distances I'm talking about are standing in front of an IR sensor about 2 feet away, start the sensor by activating it , say a push-button on my belt; then I want the sensor to buzz when I have moved away from the sensor by 2 inches.

Thanks,Leo

riden
Support Volunteer
Posts: 1754
Joined: Fri Jun 03, 2005 10:41 pm
Location: Illinois

Re: programs for infrared sensors

Post by riden » Fri Apr 02, 2010 10:24 am

Leo,

The more that I think about it, the more I believe that you will may want to take the ultrasonic sensor approach. My reasoning is that IR sensors work on detecting the amount of reflected light from the transmitter and that can vary widely based on the characteristics of the reflected surface. I suppose that a measurement could be made from a reference material (sheet of white paper, etc.) at 24" and 26" and then apply a conversion factor based on the reading of the actual material at the 24" starting location. It could be done and if you have a Sharp sensor, you could experiment with that idea. BTW, here is a link to information about Sharp IR Rangers.

Ultrasonic sensors work on the basis of time-of-flight. They are able to calculate exact distances based on the time it takes for a transmitted signal to leave the sensor, bounce off the target, and be detected by the sensor. The type of reflective material doesn't change the time involved, only the amplitude of the reflected signal. At 24" you shouldn't have any problems with any kind of material. Therefore, you will probably be up and running quicker using an ultrasonic solution. Have a look at the Maxbotics ultrasonic ranger products. You'll be spending about $8 - $9 more than the Sharp IR solution, but I think you will have fewer issues.

There are many sample programs for the Arduino for both types of sensors. Topeka, I mean Google, is your friend: Google Arduino Maxbotics and Google Arduino Sharp IR
Ralph

leo357leo
Posts: 61
Joined: Sun Mar 28, 2010 12:17 pm

Re: programs for infrared sensors

Post by leo357leo » Fri Apr 02, 2010 2:36 pm

ralph, thanks for your advice. I actually found a program that changes the input from the IR sensor to distance units. I actually got it up and running yesterday. I want to remotely start the sensor, so I can start the program and stop the program remotely. The whole idea with my program is to notify me if I've moved more than say 2 inches in a particular athletic move. I want to repeat the athletic move several times, and have the ability to determine if I have moved more than 2 inches each time. Any hints on programming for this job? I would like a buzzer to notify me if I have moved more than 2 inches from the initial read for that that particular move.

Thanks,Leo

riden
Support Volunteer
Posts: 1754
Joined: Fri Jun 03, 2005 10:41 pm
Location: Illinois

Re: programs for infrared sensors

Post by riden » Sat Apr 03, 2010 8:14 am

Could you do something where you step up to your device and then do your move? That way the sensor would be reading all the time and when you get at the desired distance for n number of seconds, the measurement begins. Step away and the device disables itself.

Otherwise, I go the IR detector route and have it wake up the Arduino.

BTW, congratulations on your progress thus far.
Ralph

Post Reply