







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








The main objective of this project is to design a device for later on pattern-recognition. Instead of regular visual pattern recognition, this project will be making a different approach by using distance sensors. This project will be using low to moderate priced distance sensors for precise distance profiling. It will also be equipped with a small display for testing and evaluation purposes.
Two models of the triangulation sensors were considered and evaluated.
GP2Y0A21YK0F โ Sharp Microelectronics Distance Measuring Sensor Unit โ Analog โ 5~80cm
GP2Y0A02YK0F โ Sharp Microelectronics Distance Measuring Sensor Unit โ Analog โ 15~150cm
Both the models have the following design.
Theory of Operation
These triangulation distance sensing units measure the distances by sending out an infrared beam at a preconfigured angle constantly. Both the transmitter side and the receiver side have an infrared filter in the front. The infrared filter is specifically shaped to receive the reflected beam correctly. The return beams, after being repositioned by the filter lens, is detected by the Position Sensitive Detectors. The signals are, then, processed and outputted in analog form.
The output from these sensors can be read directly by the Analog to Digital Convertor for digital usage and processing.
GP2Y0A21YK0F โ Sharp Microelectronics Distance Measuring Sensor Unit โ Analog โ 5~80cm
GP2Y0A02YK0F โ Sharp Microelectronics Distance Measuring Sensor Unit โ Analog โ 15~150cm
The above is the ideal characteristic of the 20~150 cm sensors. The sensor does perform very well in the sense of matching the ideal characteristic. However, there exists an issue that as the distance go pass beyond 80cm (roughly >75cm), the recorded voltage values become indistinguishable. As a result, it is determined that its effective range can only be rated to about 15cm ~ 75cm.
During the evaluation process of these sensors, this model of distance measuring sensor unit seemed to have less issues. It does not interfere with each other as easily and could tolerate small angles of biased surfaces. However, small interference on the output voltage could still be seen when they are placed closely in the following configuration.
After many tests and trials, โcreativeโ array configurations do not work most likely due to the beam reflection. A general working array configuration would be as follow:
The sensors were also tested with different materials of different reflectivity. It does pretty well over a wide range of materials including wood, steel, aluminum, copper, paper of different colors, card board of different colors, and rusty surfaces. However it does not perform well against plastic surfaces or transparent surfaces.
Ideal Moving Direction
The encoder is used to track the current position. Based on the movement and the rotation of the axle, direction and displacement can be determined for storing sensor data. The encoder used in the project is capable of 7200 rotations per minute and has a line resolution of around 2000. The reason for using such configurations is to have the device capable of moving in high speed and still triggers the centimeter reading correctly.
The microcontroller is the main controller for determine the current stage of the whole program. It constantly receives signal from encoder to check the distance. When the displacement is greater than the set values it will turn on its routine for analog to digital conversion. It also communicates to a PC and a LCD screen. The UART is triggered only when new ADC conversion has been done. The LCD screen is also programmed in the same manner that it will be updated whenever new results are returned from the ADC functions. In addition, the LCD screen will get updated every one second.
The LCD display is mainly used for displaying purpose. It helps on determining the testing and evaluation results and serves a visual aid. It is programmed to display a square array map of the distance record stored in the ADC conversion arrays.
The Serial Interface for talking with computer is for miscellaneous information output. It can also serve as a data storage device. However, a portable storage device would be the best option of this project.
The program is composed of three main parts.
It utilizes the on-chip Analog to Digital Conversion component. The on-chip Analog to Digital Convertor is accurate to 12-bit accuracy. It also has an internal analog MUX for MUXing between different input ports. The settings are just as usual and details can be found from the manuals of the dsPIC4013. One important setting is the timing for conversion. The conversion results are greatly affected by the conversion timing, hence, itโs important not to set the timing too short which may cause inaccurate readings.
The functions of the ADC conversion are written in the way that the function takes two numeric inputs which indicate the port to start and the number of port to sweep through. The analog sampling is set to 30 program clocks and the conversion is set to 4 program clocks. There is no interrupt used for sampling for better system stage tracking.
The ADC results are converted to cm equivalent values for later usage.
It uses the Input Capture and a logic input port for encoder. It is set to trigger every 16th^ capture of the rising edge. Once the interrupt is triggered, it will check the logic input port immediately for determining the direction of movement.
The main program is coded in an endless loop fashion with initializations before entering the loop. The loop will check the encoder values for current displacement and determine whether to call the ADC functions or not. It will update the graphics on the LCD once the new ADC results had been generated.
The sensors are not engineered to have equal output voltage level. Hence, it would be best to implement a calibration process in the program stage that can be initiated by the user at any time. A good way to do this is to have the corresponding distance voltage values to be stored on the chip in the fashion of offset. To initialize and calibrate it, the sensors shall be pointed to distant place where the output voltage will be the voltage level corresponding to 150cm. From that, all subsequent measurements can simply subtract the 150cm values and convert using the offset scheme to have the correct distance worked out.