ActivityBot infrared/led sensors distance
Hello everybody.
I've got a question about the infrared led/sensors included with the activitybot.
In the tutorial (roaming), all we can do is to detect an object or not.
I'd like to know if it is possible to know at what distance the object is detected (like the ping sensors that already do this job).
I'd like to use the infrared sensors in addition to the ping sensors.
thanks in advance.
I've got a question about the infrared led/sensors included with the activitybot.
In the tutorial (roaming), all we can do is to detect an object or not.
I'd like to know if it is possible to know at what distance the object is detected (like the ping sensors that already do this job).
I'd like to use the infrared sensors in addition to the ping sensors.
thanks in advance.
Comments
You could also use the technique to use IR Sensors in Chapter 8 of the Robotics with BoeBot text to give you zones.
The sensor Publison linked to is made to measure distance and would work much better in this application.
Even though it's not easy to measure distance accurately, the technique Publison linked to might give you some ballpark figures.
I'm guessing you're using C with your ActivityBot? I think it was Phil who came up with a better technique than used in the BoeBot book for measuring distance with the simple IR sensors. I think he varied the modulation frequency of the IR. I'm pretty sure the technique was done in Spin but if you're interested, I could help you find the thread.
I believe Phil used this same technique with the Scribbler 2's IR sensor.
You can still measure distances with the ActivityBot's IR sensors if you want. Just keep in mind that unlike the Ping))), infrared distance with the ActivityBot's parts is dependent on how reflective the material is. A cool thing about measuring infrared distance is you don't even need to modify the circuit from the Navigate with Infrared Flashlights tutorial. Just modify the code as shown below.
Infrared Tutorial: http://learn.parallax.com/activitybot/navigate-infrared-flashlights
Infrared Circuit: http://learn.parallax.com/activitybot/build-ir-sensor-circuits
Infrared Code: (just for objects): http://learn.parallax.com/activitybot/test-ir-sensor-circuits
Distances in SimpleIDE Terminal
Object Detection Code Modified for Distance
The for... loop increases the voltage at the IR LED's cathode time through. This makes the overall voltage across the LED circuit lower with each repetition, which in turn makes the LED flashlights dimmer, which makes the IR sensor more nearsighted. The for... loop also has code added that counts the number of times the object was not detected. More not-detections means larger distance.
The value that is currently 160 can be adjusted. It can be increased if the measurement zeros out way before the object is right in front of the IR LED or decreased if you have a constant value > 0 up-close.
The value that is currently 8 can be increased for higher resolution. For example, reducing 8 to 4 would give a range of 0 to 40 instead of 0 to 20.
i will buy the sharp ir sensor later but
Actually i want to lurn with the kit i have.
Thank to andy for the code.
See you soon.
don't you think i must replace "dac_ctr(26,..." and "dac_ctr(27,..." with "dac_ctr(11,..." and "dac_ctr(1,..." ?
We want to increase the voltage at the IR LED's cathode, but not the voltage at the LED cathode (integrated on the board that are using port 26 and 27) ?
I'm waiting for your answer, i don't want to test if it is not that (which would mean that I did not understand).
And sorry for my poor english, i'm from Reunion Island in the indian ocean.
bye.
Many applications require a reflective sensor that detects not only presence but also proximity by measuring the strength or weakness of the reflected signal. Instead of a fixed detection threshold, analog information from the sensor is needed. This is possible with the TSOP4038, TSOP58038, and TSOP58P38 IR proximity sensors. The length of the sensor’s output pulse in response to the emitter signal varies in proportion to the amount of light reflected from the object being detected. For near objects, the output pulse approaches 100 % of the emitted pulse, for far objects the output pulse becomes shorter.
Those look like cool sensors and it would probably be easier to write distance detecting code for those sensors than the current sensors used in the AB and S2. But the AB and S2's sensors can detect distance if the input to the IR LED is varied. This can be done by making the IR LED vary in brightness and use the brightness information as part of the distance calculation or one can vary the modulation frequency of the IR LED. I think Phil used the later technique in the S2.
Both techniques' readings are influenced by the how reflective the object being detected is. Objects reflecting a lot of IR will seem closer than those not reflecting as much IR. I think the Vishay sensor would have the same limitations.
That's a healthy level of caution, and hopefully for you, it will result in fewer encounters with the magic blue smoke that electronic parts make just before they die!
In answer to your question, there is not an error in the code. I tested it before posting with the IR receivers in the ActivityBot kit that have the silver metal cases, and it worked better than I expected. Both sides give me detections in the 0 to 20 ranges for roughly equivalent distances. In contrast, the similar Boe-Bot approach only resulted in 0 to 4 measurement ranges with considerably more measurement noise. The Boe-Bot still does really well following objects, so I'm looking forward to testing for improved performance with less noise and the 0 to 20 detection range.
With reference to the circuit in:
http://learn.parallax.com/activitybot/build-ir-sensor-circuits
...and the code in:
http://forums.parallax.com/showthread.php/153755-ActivityBot-infrared-led-sensors-distance?p=1241755&viewfull=1#post1241755
Let's focus on the left IR detector circuit: P11.....1 k ohm.....(anode)-IRLED-(cathode).....D/A0.
The code switches P11 on/off (3.3 V / 0 V) at 38 kHz.
The code also sweeps the D/A0 voltage (which is controlled by P26) from 0 V to 2 V in 0.1 V steps (all approximations).
When D/A0 (set by P26) is 0 V, the voltage across the IR LED circuit is 3.3 V when P11 is high and 0 V when P11 is low. When P11 is high, the 3.3 V across the circuit makes current flow, and the IR LED glows (IR light on). When P11 is low, the voltage across the circuit is 0 V, so no current flows through the circuit and the IR LED does not glow (IR light off).
Let's now think about what happens half way through the loop, when dacVal is 80 and the D/A0 voltage is about 1 V. When P11 is high, the voltage across the IR LED circuit is 3.3 V - 1 V = 2.3 V. Less voltage, less current. So the IR light is on, but not as bright as it was with 3.3 V. This makes the IR receiver more nearsighted.
When P11 is low, the voltage across the circuit is 0 V - 1 V = -1 V. Keep in mind that an LED is a one-way current valve. Almost no current travels through when it's reverse biased. No current, no light. So, the LED stays off for the low time, and we still have our 38 kHz IR light on/off signal that the IR receiver needs to detect reflections from objects. And reverse bias voltages in the 0 to -3.3 V range will not hurt the IR LED.
Side notes:
I have not yet tested the black plastic IR detectors in the kit. They are a little more sensitive than the metal ones, and that's not necessarily a good thing. I typically use larger resistors in series with the IR LEDs to offset for that higher sensitivity with the black plastic detectors. That prevents them from detecting the floor in front of the robot, which is not supposed to be detected as an obstacle.
For initial testing, close the blinds to keep direct sunlight out of your area. I have not tested the effects of direct sunlight yet, but from past experiences, it has tended to swamp the IR, making it very nearsighted, or even blind.
There is a dizzying array of IR receiver types, each with different characteristics, "optimized" for something, noisy environments, sunlight, etc. Vishay's catalog shows several receiver types in both tin can packages and also black epoxy. Long story short, there is often no way to ID any particular IR receiver, other than what marked supplier bag it came out of, and there is room for error there, too. BTW, Radio Shack sells two wildly different receivers in the same package, same part number. The metal frame one is continuous-signal compatible, the black epoxy one is not.
The silver IR are optimized for Boe-Bot/ActivityBot forward detection. The black are optimized for SumoBot without being "too" different from the silver ones. They are slightly more sensitive, which is good for better opponent detection, and IR bouncing off the black sumo ring surface is not as likely to be detected as it is with an ActivityBot on wood floor or carpet.
The black ones were added to the ActivityBot kit for planned future activities that have more flex, and calibration will be used to keep our options of switching to all silver ones. We also make sure to document when the difference matters. For example, the circuit page cited in this thread has a nice red check-mark with this instruction: "Find the IR receivers in your kit. If you have two different kinds, use the ones with the silver metal cases for this activity."
Source: http://learn.parallax.com/activitybot/build-ir-sensor-circuits
...and while it's true that maybe you or somebody you know may have gotten an out of spec detector from us at some point, we also go the extra mile to make it right if it happens. As in, we send replacements immediately and also raid stock to find and eliminate the offending batch-o-receivers.
I tested it and it works perfectly.
Thanks to all.
See you soon.
The sensor needs 5V power and the Prop's I/O pins output 3.3V power.
You could use a latching (or normal) relay on the sensor's power line and use the Prop to turn it on and off through the relay.
Edit: Even if the sensor were a 3.3V device, I'm not sure it would be a good idea. Many devices draw short bursts of high current that could either damage the Prop pin or cause he sensor not to work correctly. I've tried powering some nRF24L01+ transceivers from a Prop pin with mixed results. Most of my transceivers wouldn't work when powered from an I/O pin even though they only draw 17mA of current. I'm not sure just why they wouldn't work this way but I'd thought I'd offer my experience as a warning.
Cluso99 wrote a post on this topic. You might want to see if you could find it (if I find it I'll post a link).
Edit again: I found Cluso99's thread.