The Boe-bot
Hi,
I use the book "Robotics with the Boe-Bot" by Andy Lindsay.
I have a question regarding the coding that Andy Lindsay use in the
book.
-->FOR counter = 1 to 64
--> PULSOUT 13, 650
--> PULSOUT 12, 850
--> PAUSE 20
-->NEXT
Andy Lindsay put a value of 20 for PAUSE command which means 20
millisecond pause for the motor servo for each rotation. So, my question is
why Andy Lindsay put 20 ms for pause? Why not for example 50ms?
Why do we have to put PAUSE command?
Thanks for helping.
I use the book "Robotics with the Boe-Bot" by Andy Lindsay.
I have a question regarding the coding that Andy Lindsay use in the
book.
-->FOR counter = 1 to 64
--> PULSOUT 13, 650
--> PULSOUT 12, 850
--> PAUSE 20
-->NEXT
Andy Lindsay put a value of 20 for PAUSE command which means 20
millisecond pause for the motor servo for each rotation. So, my question is
why Andy Lindsay put 20 ms for pause? Why not for example 50ms?
Why do we have to put PAUSE command?
Thanks for helping.
Comments
The two PULSOUT statements generate the pulse and the pause 20 statement does the wait for 20ms for each cycle.
Hope this helps.
Are you saying that the two PULSOUT statement generate a pulse of between 1 to 2 ms?
So, what happens if the PAUSE statement increase from 20 ms to (let's say) 100 ms? Will it affect the RPM (Revolution Per Minute)?
If the PAUSE is increased, the servo will turn itself off at some point and no longer hold position (until the next pulse comes along). This threshold varies from servo to servo, but I think it's around 50ms.
Here's my other question.
I'm using different frequencies to follow an object.
___________________________________________
FOR freqSelect = 0 TO 4
LOOKUP freqSelect, [noparse][[/noparse]37500, 38250, 39500, 40500, 41500], irFrequency
_______________________________________________________-
Since the zones are overlapping each other (I hope you all know what I mean), I've tried to use different frequencies based on the appendix in the book.
But, I still can't get the suitable frequencies because the zones are overlapping. Is there other way (besides the appendix in the book), to get suitable frequencies?
Thanks again.
Since 37500 works "the best" -- has the LONGEST range -- I'd tend to run the frequencies in the opposite direction you're running them.
In other words, it should be 41500 FIRST, not last. Although, having said that, running the 37500 first means you'll detect an object at the longest possible range, then 'step' in the ranges until you don't detect it anymore -- which I guess is useful, so I withdraw my comment.
One attribute of the IR-Detector method is that it is "fuzzy" -- you get 'approximate' results -- an object is "far" or "close". You're not going to get repeatable "It's 1", 3", 5" away" kinds of measures. Still, getting ANY kind of range indication from what was supposed to be ONLY a 'detect', 'can't detect' measurement is pretty good.
Remember that the IR distance sensing uses an anomaly of the IR detector in that the selectivity of the detector to the IR modulation frequency is imperfect and, by varying the frequency of the IR beam, the detector exhibits different sensitivities to the light and its effective threshold varies.
You may have to calibrate your particular detector by writing a short program to step through a set of frequencies, changing when you press a pushbutton and turning on an LED when the detector responds. By graphing the curve of frequency vs. distance, you can determine your own "zones" and choose frequencies that don't overlap or overlap the way you want them. Since the amount of reflected IR depends on the materials, the angle of incidence of the light, etc., you will want to use your actual setup and the object you want to follow to do the calibration.
Let's say I use 3 frequencies, 37500, 39500 & 41500. and I arrange them like this:
___________________________________________
FOR freqSelect = 0 TO 4
LOOKUP freqSelect, [noparse][[/noparse]41500, 39500, 37500], irFrequency
_______________________________________________________-
Then, the zone 0 (when the object is near to the robot) is 41500, zone 1 is 39500, zone 2 is 37500 (when the object is far from the robot). Is it so?
"By graphing the curve of frequency vs. distance, you can determine your own "zones" and choose frequencies that don't overlap or overlap the way you want them." quoted from Mike's comment.
Why is it that for e.g. I use 37500 and it detects the object when the distance between the object and IR detector is 30 cm, but when I put the object near to the detector (somewhere between 0 to 30 cm), the detector doesn't detect the object?
Truthfully, I don't know. Maybe the detector is getting overloaded at close range. That's another good reason for starting with the least sensitive "zone".
The FREQOUT statement itself doesn't do what you probably think it is doing. On the BS2, it has a limit of 32767Hz (see the manual). The actual waveform is produced via PWM and the averaging to produce the waveform happens in the detector since the LED can respond rapidly to the PWM pulse stream. Above 32768Hz, the frequency of the harmonic is supposed to be 65536 - FREQOUT frequency according to the manual. I suspect this is an artifact of the algorithm used to produce the PWM signal.
As allanlane5 suggested, this is a cheap technique for getting rough distance detection with simple parts that were not intended for this use.
So, 37500 covers ALL zones. 41500 is a "closer" zone. If it's in 41500, it should also be in 37500. If it's in 37500 but NOT in 41500, you know it's "further away" than zone 41500. In other words, the detection distances are circles, not 'bands'.
I don't know why something detected at 30 cm wouldn't also detect at zero cm -- all you're "detecting" is the reflection of IR light into the IR-Detector. Now probably 'position' matters -- if you're trying to detect a flat mirror that's turned 45 degrees (or a square robot corner-on to you) that might be very difficult to detect.
Mike Green, what do you mean by PWM?
Here's the other question.
FREQOUT 8, 1, 38500
My question is why did Andy Lindsay put 1 ms to send 38500 to P8? What happen if it is more than 1 ms? What's the difference?
Thanks.
Post Edited (ziana) : 4/22/2008 8:56:35 AM GMT
The "Using an IR-LED with IR-Detector for collision detect" approach just needs enough IR modulated light (aka "Blinking at 38500 Hz) to trigger the Detector. 1 millisecond is enough for that. More than one millisecond would work, but takes more time.
Actually the BS2 is using a very helpful attribute of the IR-Detector chip -- that it has some "latency". Namely, its output stays "LOW" for a little bit after the IR-LED has cut off. This gives the BS2 time to 'read' the state of the IR-Detector. But you MUST read the IR-Detector pin IMMEDIATELY after the FREQOUT statement for this to work.
See this Wikipedia article: en.wikipedia.org/wiki/Pulse-width_modulation