28125 Parallax Inc, 28125 Datasheet - Page 295

TEXT ROBOTICS

28125

Manufacturer Part Number
28125
Description
TEXT ROBOTICS
Manufacturer
Parallax Inc
Datasheet

Specifications of 28125

Title
Robotics with the Boe-Bot
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
The left servo is different because Kp for that system is -35
Since the values -35, 35, 2, and 750 all have names, it’s definitely a good place for some
constant declarations.
With these constant declarations in the program, you can use the name
35,
these constant declarations, the proportional control calculations now look like this:
The convenient thing about declaring constants for these values is that you can change
them in one place, at the beginning of the program. The changes you make at the
beginning of the program will be reflected everywhere these constants are used. For
example, by changing the
entire program changes from -35 to -40. This is exceedingly useful for experimenting
with and tuning the right and left proportional control loops.
Example Program – FollowingBoeBot.bs2
FollowingBoeBot.bs2 repeats the proportional control loop just discussed with every
servo pulse. In other words, before each pulse, the distance is measured and the error
signal is determined. Then the error is multiplied by Kp, and the resulting value is
added/subtracted to/from the pulse widths that are sent to the left/right servos.
Kpr
in place of 35,
pulseLeft = 2 - distanceLeft * (-35) + 750
Kpl
Kpr
SetPoint
CenterPulse
pulseLeft
pulseRight = SetPoint - distanceRight * Kpr + CenterPulse
Enter, save, and run FollowingBoeBot.bs2.
Point the Boe-Bot at an 8 ½ × 11” sheet of paper held in front of it as though it’s
a wall-obstacle. The Boe-Bot should maintain a fixed distance between itself
and the sheet of paper.
Try rotating the sheet of paper slightly. The Boe-Bot should rotate with it.
Try using the sheet of paper to lead the Boe-Bot around. The Boe-Bot should
follow it.
= SetPoint - distanceLeft
SetPoint
Kpl CON
CON
CON
CON
CON
in place of 2, and
directive from -35 to -40, every instance of
-35
35
2
750
CenterPulse
* Kpl + CenterPulse
in place of 750. After
Kpl
in place of -
Kpl
in the

Related parts for 28125