Components: – PIC DEM 2 plus board
– PIC16f877
– SHARP gp2d12/gp2y0a21yk IR Distance Measuring Unit
Task: Measure distance using sharp sensors and display it on the demo board’s LCD
Purpose: To demonstrate the use and understanding of the MCU of your choice, and the distance sensors.
Objective: Use the PIC microcontroller to get a reading from the gp2d12 sensors. Translate that reading into a distance value and display it on the PIC DEM board’s LCD module.
I have worked with the SHARP distance sensors on a previous ‘Radar’ project, so they weren’t very had to get working. But as was the challenge the last time, getting an accurate and constant distance conversion formula would be the hardest part.
The biggest drawback with the SHARP range sensors is the non-linear data output, so I had to work out a way to linearize the data while maintaining the reading integrity.
I ‘Google-d’ a few interesting articles and though they were very helpful, I still struggled with the conversion. It worked with large ranges but it wasn’t consistent and since I was running on a dead-line, I couldn’t work on it for too long.
I opted to work with the sensors analog voltage as a reference instead of converting it to a distance measurement.
By now I was pretty comfortable with using the ‘PICDEM board’ and our chosen programming platform, ‘mikroC for PIC’…(We had been given a few simple assignments to work on in order to familiarize ourselves with both the hardware and IDE).
I used the pic16f877a’s internal ADC to read the sensor output and after converting the ADC value to a float voltage value, I used that as a range reference for my wall detection functions.
References: