Sharp has a number of different IR object detection and ranging modules that you can interface very simply to any PIC MCU. In this experiment, I will introduce you to the GP2D120 module, which provides an analog signal roughly proportional to the distance between it and some light-reflectingo bject. The Sharp modules are designed to work using between 3 and 6 volts, with 4.5 to 5.4 volts being the range where they work most efficiently .Other than providing reasonably clean power to the modules,you have to connect only a single line to a PIC MCU to read distances.
The circuit that I used for this experiment is quite simple, as you will see in Figures below, and it should not cause you too many problems in wiring it together. The basic GP2D120 moduleh as a white plastic connector on the bottom, and to use it with a bread board,I simply soldered three short breadboard wiring kit wires to the three pins on the backside of the module.
The code for the application is very straightforward and assumesth at the maximum voltagep ut out by the GPZD120 is 3.0 volts. Instead of displaying the distance as a binary value, I use the bargraph as a 10-position scale with a single lit LED. The application code (asmGP2D12) tests the voltage output from the GPZD120 by repeatedly subtracting 15 from the returned ADC value. The reason for taking away 15 is that 3.0 volts measured in a maximum 255 range for a 5-volt circuit is 150. Therefore. 15 is eauivalent to 300 mV.
I have been quite cavalier with the GP2D120 in this circuit because the circuit has only one LED active at any time and is poweredb y batteriesa, nd the breadboardh asa lot of built-in capacitanceIf. you were to use the GP2D120 (or any of the other Sharp IR object-detectionm odules)i n an application, I would recommend placinga fairly large( 10 mikrofarad or greater) capacitor close to the module's power-supply pins. As I will show in the following experiments,IR receivers can be somewhats ensitive to electrical noise, and in an application that has electrica motors running (e.g.,a robot), you will find that the output may be erratic. By adding the capacitor, you should be protecting the module from noise, which could prevent it from operating correctly.
Download Project Code
Wednesday, April 29, 2009
Interface GP2D120 IR Range Finder With PIC Microcontroller
Labels:
PIC Microcontroller Project
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment