IR Proximity Motor Control

Jump To:
The Sharp IR Distance Sensor
           There's two parts to the theory of this project that we need to cover before looking at the schematic. The first part is how the IR distance sensor works and the second part of the theory section will be looking at how the motor is controlled.


           The video above demonstrates in a crude manner what the output of the IR distance sensor does when connected directly to a red LED. The LED gets brighter when the piece of paper nears the sensor because the voltage output increases. The opposite happens when the piece of paper is moved backward away from the sensor.

The Sensor's Output
           Let's take a look at the datasheet's theoretical output vs. distance. The graph below shows what voltage output from the sensor you should expect when a white piece of paper is placed in front of the sensor.


           As you can see right away, the output voltage is not linear which makes things a little annoying as we won't be able to have a straight-forward correlation between voltage and distance. Sharp has made a few attempts at building an algebraic equation that you can use, check the app notes on their website for more info on those.
           We won't be dynamically evaluating the sensor output in this project and converting it to distance, instead we'll use set voltages hard-coded in the software with some if statements. That means we'll need to pick 9 voltage levels at certain distances. Below you can see the 9 we chose and the 'windows' that those points form.


          The specific distances are chosen as follows:
  • Window #1 6cm-8cm
  • Window #2 8cm-10cm
  • Window #3 10cm-12cm
  • Window #4 12cm-14cm
  • Window #5 14cm-16cm
  • Window #6 16cm-18cm
  • Window #7 18cm-20cm
  • Window #8 20cm-22cm
We call them 'windows' because each window has two sides defined by the distance. For example if the sensor's output voltage is +2.4v, then take a look at the graph above and you will see that we are inbetween 6cm and 8cm, thus we're inside of Window #1's range. Our software will create these 'windows' using IF statements.