The rules that define when the states can change can alter the behavior in
significant ways. The different modes of the Servo Trigger are all
implemented using the same states, but with different transition rules.
FSMs are commonly illustrated using “bubble diagrams,” which draw the
states as circles, and the rules as arrows between the circles. Here’s the
bubble diagram for the bistable FSM.
Building New State Machines
In the Servo Trigger, a state machine is implemented as a single function,
which contains a
switch statement wherein each state is a case . At the
start of every PWM cycle, the state machine function is called to determine
the pulse width, and possibly move to new states.
If you want to implement a new state machine, it can be useful to start by
drawing the bubble diagram.
If your new FSM is a slight alteration to an existing one, the next best place
to look at the existing FSMs – it might be as simple as transplanting a state
transition rule from one function to another. If your FSM is more ambitious,
it’s still useful to read and understand how the FSM interacts with the rest of
the firmware.
Your application may need a subtle variation of an existing FSM, or a
complete re-formulation. Since the source code is available, you’re
welcome to modify it to suit your needs!
Resources and Going Further
Now that you’ve got your Servo Trigger running, it’s time to incorporate it
into your own project!
If you have any feedback, please visit the comments or contact our
technical support team at TechSupport@sparkfun.com.
Resources
• The design documentation is available for download from the Servo
Trigger Github Repository.
• The firmware was developed using Atmel Studio, with a JTAG-ICE3
debug module.
• Without the JTAG-ICE, you can still reprogram the board with the
Tiny programmer. You might want to use it with the pogopin adapter.
You’ll also need the command-line WinAVR tools.
Going Further
• The Servo Trigger can control any of our hobby servos.
• You can trigger it using many of our buttons and switches.
• The Open Servo is a different approach to controlling servo motors
by enabling them to speak I2C.
Page 1
of 1