What's a Micro... Version 3.0, paper p. 193-194, Ch 6 Activity 3 TestMaxDarkWithHighPause
![John Kauffman](https://forums.parallax.com/uploads/userpics/555/nZBNEPT0B6FMD.jpg)
in Robotics
In this activity, rate of servos (pins 12,13) is supposed to change depending on quantity of light striking phototransistors in RC circuits on pins 3,6.
I run it but get no change in servo speeds. Can anyone explain to me how this code could generate the expected result?
Looks to me like PULSOUT args are hard coded. I thought I'd see tLeft and tRight used as 2nd arg in PULSOUT (perhaps after scaling and offset).
Thanks.
I run it but get no change in servo speeds. Can anyone explain to me how this code could generate the expected result?
Looks to me like PULSOUT args are hard coded. I thought I'd see tLeft and tRight used as 2nd arg in PULSOUT (perhaps after scaling and offset).
Thanks.
' TestMaxDarkWithHighPause.bs2
' {$STAMP BS2}
' {$PBASIC 2.5}
tLeft VAR Word
tRight VAR Word
PAUSE 1000
DEBUG "Program Running..."
DO
HIGH 6
PAUSE 1
RCTIME 6, 1,tLeft
HIGH 3
PAUSE 1
RCTIME 3, 1,tRight
PULSOUT 13, 850
PULSOUT 12, 650
LOOP
Comments
It's explained at the top of page 189.
Although 25 or 30 ms between servo pulses might not cause any noticeable difference,
delays of more than 50 ms or so will cause noticeable problems,
and larger delays will cause the servos to just twitch periodically instead of rotate.
A pair of phototransistor measurements in a really dark area might measure 50,000 each.
For both measurements, that would be 100,000 × 2 μs = 400 ms.
All the Boe-Bot’s servos would do with this delay between servo control pulses is twitch every 0.4 seconds.
In this activity, you will try a technique that can be used to reduce decay time measurements in darker rooms.
You will also test the effects of reduced light on servo performance using both measurement techniques.
In other words:
As there is less light on the Phototransistors their time values will keep increasing until the delay between servo pulses is too large for them to function properly.
Also at the bottom of page 193 it says:
The first step would be a test to find out how low the light level has to get
before the servos stop functioning properly with the HIGH-PAUSE-RCTIME approach.
And on page 194:
Gradually increase the shade until the servos start twitching. (A shoebox would work well for this.)
The code works properly but it would be nice if the code was commented to explain what it's doing since it's working the opposite of what you would expect.
This activity would be good to do in Propeller tutorials to make the case for multicore.