uCee - Of Rangefinders and ProxDots
So, today I've been working on uCee (note the slight spelling difference from my previous post - I like uCee as a name better than uC).
Specifically, I've been working on getting my range finders working in a reasonable fashion. I'm using three GP2Y0A41SK0F Sharp IR analog range-finders. I'm powering them with 5 volts, but since the maximum voltage they return is about 3.1 volts, I can hook them directly to the analog inputs on my Teensy 3.1, which allows a max of 3.3 volts on analog inputs.
However, as anyone knows who has used them, Sharp IR range-finders have a curious piece of behavior that occurs as the object being sensed gets close enough - the signal inverts, and starts acting as if the object is moving away instead of getting closer. For the sensors above, that happens at 30 mm away. I was going to use a ProxDot sensor in conjunction with the range sensor, but they trigger when the object is about 45-50mm away. However, since ProxDots have 2 IR LEDs, I tried covering one with a tiny piece of black electrical tape, so there would be only half the strength of light for it to sense. Sure enough, with one LED covered, the ProxDot triggers at almost exactly 30mm, which is perfect.
The code (without the ProxDot) is as follows:
Specifically, I've been working on getting my range finders working in a reasonable fashion. I'm using three GP2Y0A41SK0F Sharp IR analog range-finders. I'm powering them with 5 volts, but since the maximum voltage they return is about 3.1 volts, I can hook them directly to the analog inputs on my Teensy 3.1, which allows a max of 3.3 volts on analog inputs.
However, as anyone knows who has used them, Sharp IR range-finders have a curious piece of behavior that occurs as the object being sensed gets close enough - the signal inverts, and starts acting as if the object is moving away instead of getting closer. For the sensors above, that happens at 30 mm away. I was going to use a ProxDot sensor in conjunction with the range sensor, but they trigger when the object is about 45-50mm away. However, since ProxDots have 2 IR LEDs, I tried covering one with a tiny piece of black electrical tape, so there would be only half the strength of light for it to sense. Sure enough, with one LED covered, the ProxDot triggers at almost exactly 30mm, which is perfect.
The code (without the ProxDot) is as follows:
int value = analogRead(sharpPin);
float voltage = value * 0.0032258; // 0-1023 -> 0-3.3 volts
float exactDistance = (100 * ((1.25 / voltage) - 0.15));
int distance = (int)exactDistance;
if (distance > 200)
distance = -1;
So now I'm going to combine in the ProxDot sensor, and add a few lines of code:
int value = analogRead(sharpPin);
float voltage = value * 0.0032258; // 0-1023 -> 0-3.3 volts
float exactDistance = (100 * ((1.25 / voltage) - 0.15));
int distance = (int)exactDistance;
if (distance > 200) {
distance = -1;
} else {
int proxDot = digitalRead(proxDotPin); // signal is low if something is sensed, high otherwise
if (!proxDot)
distance = max(0, 55 - distance);
}
And presto - I get a much more useful distance value at close ranges.
2 Comments:
It is a neat idea to use a IR ProxDot detector to switch between the two regions of the voltage v distance curve to extend the close range sensing.
Is the close range region as reliably as the long range part? The close range response appears almost linear, is this the case?
Brian
By
Unknown, At
January 26, 2014 at 6:12 PM
I don't know if it is linear - I'm basically treating it as if it is. It certainly seems close enough to be reasonable.
By
Unknown, At
January 26, 2014 at 8:01 PM
Post a Comment
Subscribe to Post Comments [Atom]
<< Home