• POnn Servo offset
• Cnn Canned sequence
• Knn Continuous canned sequence
• R Reset (stop) sequence
• U Range request (sonar)
• Z.. Pot update of a servo
• I Range request (IR)
• X Execute step of stored EEPROM sequence
• Y Execute (back) step of EEPROM sequence
• V View stored EEPROM steps
• E Save current position into EEPROM step
• A Set address of execution step
Loki can execute either one of the canned sequences,
or the EEPROM sequence that’s been saved. I developed
the simple six-step gait and turn sequences used by the
autonomous mode (and the canned sequences) with the
EEPROM commands.
Either the ‘Z’ or ‘+/-’ offset commands can be used
to position a servo, and then store all servos with the ‘E’
save command.
Sequences and Autonomous Mode
The SW3 pushbutton is pressed to start up the
autonomous mode of Loki. Loki starts by walking forward,
and will take random turns at random intervals. Loki turns
away if the IR sensors encounter an obstacle. The forward
walk is accomplished by continuously looping through
canned sequence #1.
A full left turn is really three #3 sequences, and a full
right turn is three #5 sequences. Although not very efficient
on space, the sequences are “man readable,” and easily cut
and pasted into a program or manually sent via a terminal.
Wondering what sequences #2, #4, and #6 are? They
are backwards gaits of #1, #3, and #5, respectively.
Sequence #7 reads the pot to determine position (more on
that later), and #8 is a waving posture.
To control the transitions between the sequences, a
FSM (finite state machine) is used. This FSM is scheduled to
run periodically by the main ISR. The FSM can be called the
first “behavior” for Loki. I intend to add additional behaviors
such as following a light source. These too are implemented
as FSMs. All FSMs run in parallel and all are scheduled
from the main ISR via the system ticks. This parallel FSM
operation allows a new behavior to be easily programmed
(that’s the theory). The multiple FSMs will be controlled
by subsumption. Loki doesn’t have all that implemented
yet, however.
Sensors
Loki has three sensors currently. The two IR distance
sensors (also called proximity sensors or rangefinders)
have analog outputs. The processor reads the IR sensors
with the A/D and is controlled by interrupts. The IR data is
conditioned and results in left and right range values in
inches. The ultrasonic sensor is interfaced by I2C and
Loki Crosses the Pond — Part 2
controlled by another FSM. The ultrasonic sensor data read
is in inch range readings. The behavior FSM checks these
ranges for use in deciding when to make turns and when to
stop. If a terminal is connected (either by a direct RS-232
connection or by Bluetooth), the telemetry (actually, just a
lot of printf statements) will be available, and the ranges
seen by the sensors will be displayed, along with some
sequence information.
LEDs
The controller board has five LEDs. D1 is the power
on LED. D2 is the “heart beat” LED which flashes at a one
second rate to indicate that the program is still running. D4
is the message LED that indicates when a command is
being received. D5 is the ERROR LED, which gets set when
a received command is in error. D6 is the move LED that
indicates when a servo move is in progress.
Switches
There are three switches on the controller board.
SW1 is a miniature toggle switch for +5V. SW2 (small
pushbutton) is the reset switch and resets the processor.
SW3 (small pushbutton) is the data switch used to initiate
autonomous activity. There is also the miniature servo
power switch on the body.
Servo Operation
The main timer already generates interrupts for the
main ISR at the frame rate of the servos (2,500 μs). This
rate is also divided down to generate system ticks at a 1/10
second rate for other background tasks. A second timer
times the pulse width for each of the four (or eight) servos
sequentially. We don’t just suddenly “jump” from one servo
position to the next. What we do is “sweep” the servo(s) to
Close-up front view of Loki (new legs). Sonar and IR sensors.
SERVO 07.2008 55