Presentation 9 - Purdue College of Engineering

Seongwoon Ko
Ankith Cherala
Jinliang Wei
Kelton Stefan

Design Considerations

Main Function Flow Chart

Code Modules

Hierarchical Arrangement of Code Modules

Biped Control GUI

14 KB RAM, 512 KB Flash – large enough

Language: Embedded C
◦ Compiler takes care of where to put variables and
code.

Explicitly Put into Flash (declared as const)
◦ Look-up tables for trigonometric functions
◦ Vector arrays of foot positions for static subactions (later)

8 PWM channels to control 8 servos

Problem: not fully utilize the duty resolution
◦ Servo refresh period: 25 ms
◦ Pulse width 0.6 ms ~ 2.4 ms controls 0 ~ 180
degrees of turning
◦ Only use 7.2 % of the duty register resolution
◦ Not accurate enough

Solution:
◦ Set PWM period to 2.5 ms
◦ 1 servo refresh period consists of 10 PWM periods
◦ Set PWM duty register only for the first period, set
others to 0 (timer is used)


Connected to WiFly card for communicating
with control GUI
Interrupt-driven receive
◦ Not know when user will send command

Program-driven write
◦ Send status message to user periodically

Connected to accelerometer for measuring
external force.

Micro as master, accelerometer as slave

Interrupt-driven
◦ Needs to take immediate action for external force
for balancing


1 ATD channel connected to ultrasonic range
finder to detect obstacles
Program-driven
◦ Checks output periodically
◦ Biped walks slowly, so enough time to avoid
obstacles

Accumulate timer tickets to trigger the
following actions:
◦ Set and reset PWM duty register
◦ Read output from ultrasonic range finder
◦ Send status message to PC

User-Control Mode
◦ Read control message, act accordingly
◦ Assume no need to self-balance or avoid obstacle –
user should take care of it

Auto-Navigation Mode
◦ Read environment data, walk freely while avoiding
obstacles and balancing itself

State Machine + Interrupt Driven + Pooling
Loop

Two States:
◦ User-control state
◦ Auto-navigation state

Interrupts: WiFly, accelerometer, timer

Interrupts service routines set flags, infinite
main loop checks flags and acts accordingly

Four Main Actions: Walk, Turn, Stop, Balance

Each action done by doing sub-actions
◦ Walk: lift left foot -> bent for balancing -> move
left foot to front -> …

Static sub-actions and Dynamic sub-actions

Variables to store foot positions and states

Periodically adjust itself




Static sub-action: pre-defined array of foot
positions and orientations (stored in flash)
Static sub-actions performed under default
conditions (no significant external force other
than gravity)
When a static sub-action is done, modify foot
position and foot position state
If needs to change to another action, move to
another sub-action based on current foot
position state




Dynamic sub-action: calculate next foot position
and orientation based on current foot position
and environment information (acceleration, …)
Significant external force -> Switch from static
sub-action to dynamic sub-action
When possible -> switch back to static subaction
How to calculate next foot position? – not yet
know
Timer
Accelerometer(SPI)
WiFly Card(SCI)
o Balance itself under significant
external force (dynamic subactions).
o In SPI ISR, SPI interrupt is also
handled but simply change
acceleration value.
o Return with each servos at their
positions before interrupt – to
resume appropriate static subaction



Read message from WiFly card and push it to
message queue – possibly pending messages
Increment msgCnt by 1
Note: SCI interrupt is disabled/ignored when
serving SPI interrupt
Preliminary Flowchart

PWM-Servo Control module
◦ Control the servo to turn to given an angle

Inverse-Kinematics module
◦ Given a foot position and orientation, calculate
servo angles

Next-Sub-Action module
◦ Based on the action to perform and current feet
positions, determine next sub-action to perform

Dynamic-Next-Position module
◦ Based on environment information and current foot
positions, find next foot positions to balance itself

SCI-WiFly module
◦ Provides functions initializing SCI port 1, sending
messages to and receiving messages from WiFly
card

MsgParser module
◦ Parse messages received from WiFly card and set
appropriate global variables.

SPI-Accelerometer module
SPI initialization; SPI interrupt service routine

ADC–Obstacle module
◦ ATD channel initialization; Read and set obstacle
distance and modify other variables if needed

Timer module
◦ Timer initialization; Timer interrupt service routine

Status LED module