In the other hand, avoid the use of a capacitor between the signal output and GND or Vcc: it may dramatically reduce the sensor dynamics low pass filter. Below, we will see how to numerically filter this output in order to improve the precision without decreasing the dynamics. AD conversion of the sensor analog output When powered with a 5V potential, the Sharp sensor has a maximum output voltage of about 2. The highest useable distance gives approximately 0. In order to obtain the best precision, the highest limit of the converter on 8 bits should more or less correspond to the highest output voltage of the sensor, that is the lowest measurable distance, and vice versa.
|Published (Last):||28 July 2013|
|PDF File Size:||20.35 Mb|
|ePub File Size:||14.16 Mb|
|Price:||Free* [*Free Regsitration Required]|
In the other hand, avoid the use of a capacitor between the signal output and GND or Vcc: it may dramatically reduce the sensor dynamics low pass filter. Below, we will see how to numerically filter this output in order to improve the precision without decreasing the dynamics. AD conversion of the sensor analog output When powered with a 5V potential, the Sharp sensor has a maximum output voltage of about 2.
The highest useable distance gives approximately 0. In order to obtain the best precision, the highest limit of the converter on 8 bits should more or less correspond to the highest output voltage of the sensor, that is the lowest measurable distance, and vice versa. In doing so, the full scale of the converter is used.
For my own application , I used a Ubicom SX52 microcontroller with a entries lookup table. Statistical analysis of the sensor output In order to measure the noise present on the sensor output, I made some tests and statistics with a GP2D12 sensor placed at about 25cm in front of a flat white wall.
In particular, the standard deviation does not depend on the measured distance. However, the precision of the distance cannot be directly deduced because the output is non linear. A constant standard deviation over the full range of the sensor output does not lead to a constant precision of the computed distance.
This graph Fig. Therefore, it would be wise to average several successive output values to improve the precision. Note that this quite important noise is essentially due to the sensor itself electronic noise. The noise introduced by the converter is marginal. See Fig. As the converted values from the AD converter are 8-bit coded, the best we can do is to use a lookup table with entries.
The microcontroller offers the possibility to store bit data in the program memory. It is therefore easy to store the distances in millimeters from to that would require 10 bits. As the microcontroller has not a lot of program memory, in the case of the use of several GP2D12, it seems wise to have a single table for all the sensors. The following graph Fig. A linear approximation between each pair of successive points is made. On the following graph Fig. It is easy to understand that the values above mm are almost unusable.
At mm, the precision is only 20mm and becomes better with closer distance about 2mm at mm. Of course, using a unique lookup table for several sensors slightly decreases the precision, but however must represent a good compromise in certain cases. Dynamic distance measurement The analog output of the Sharp GP2D12 sensors moves in voltage steps when the measured distance changes. These steps last about 40ms see Fig.
Because there is some noise on the sensor output, we can get an improved value of the distance by averaging the output along the step. Therefore the processor can have an updated value every 1ms and thus about 40 values per step.
These 40 values will be averaged over time in order to obtain a good approximation of the step level without noise this procedure acts like a digital low-pass filter. To achieve this, the points belonging to the same steps must be recognized and clustered.
There are essentially two criteria to achieve this clustering. The first is certainly the difference between successive data. If the difference is greater than a specified threshold, the processor can know that it is the next step. The second one is the maximum time allowable for a step.
If two of them are merged, we can end the set of successive values belonging to the same step by knowing the maximum length of this set. The maximum number of conversion during a step is So if there is no significant transition after 43 readings, we can assume that future data are part of the next step. If some data are not well classified, in this case, this is not so important because it will not significantly change the mean value of the steps.
If all the steps are at the same height static case , this clustering process will lose the synchronization. But, as soon as a transition appears, the algorithm will automatically synchronize again.
This algorithm has been implemented in the microcontroller. The computed means of the steps are represented in black on Fig. Please note that the clustering is applied to the rough sensor values and not to the distances after conversion through the lookup table.
This algorithm is intended to filter the noise of the sensor output, which is constant over the full scale of distances. If the successive values from the sensor were first converted into distances, the noise would have not always the same magnitude. We can see that there was not enough difference between the fourth and the fifth steps. Therefore the 43 first points have been allocated to the fourth step. And the last points actually 38 before the next recognized transition are part of the fifth step.
Note that the computation of this average does not require 40 or 43 registers in memory. A sum variable on bit is updated at each reading of the converter. When the end of a cluster is detected, the sum is divided by the number of data in the set.
Each computed average will be then transformed into a distance via the lookup table. This distance is time stamped with the middle of the previous step. Dynamic measurement summary To sum up, we have now an algorithm, which is able to process the rough sensor data at 1kHz and output an enhanced distance value about each 40ms i.
The vertical gray lines indicate the moment when the end of a step has been detected: a jump higher than the specified threshold or the overrun of the maximum successive values allowable for one step. The little circles symbolize the distances at the moment they are calculated. The crosses are the same values but plotted at the position they are time stamped thus 60ms before their calculation.
Now, if several sensors are used, there will be several such processes, asynchronously. If simultaneous distances must be estimated that was the case in my project , it is possible to implement a routine based on the above-described algorithm see this document for further information.
See it here. Complete step by step instructions are provided! The solution came from Andreas Peter thanks Andreas for showing me these devices! These small and rather inexpensive infrared devices are able to measure distance between 10 and 80 cm with reasonable precision and good immunity to variations of obstacles reflectivity and ambient light. Andreas sensor interface has a few drawbacks though. The GP2D02 he could find has a digital serial output not well suited to RCX analog input, thus requiring a rather complex design, big and power hungry. So I decided to try to connect the analog output GP2D12 sensor using the simplest design possible - and use only power coming from sensor input.