The Infrared sensor

Now, a little tutorial on IR sensors. The sensor you are using has both a transmitter and a sensor. The transmitter transmits a narrow beam of light, and the sensor receives this beam of light. The difference in transit ends up as an angle measurement at the sensor, as shown here:

The Infrared sensor

The different angles give you an indication of the distance to the object. Unfortunately, the relationship between the output of the sensor and the distance is not linear, so you'll need to do some calibration to predict the actual distance and its relationship to the output of the sensor.

The voltage to distance chart for the device looks like this:

The Infrared sensor

This kind of chart will come from the sensor's date sheet. There are really two parts to the curve; the first is the distance up to about 15 centimeters, then the distance from 15 centimeters out to 150 centimeters. You can simplify the code if you ignore distances closer than 15 centimeters, and model the distance from 15 centimeters and out as a decaying exponential with the form Constant * InputValue-exponential value. This will be the calculation that you will use later in the program.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.189.129