Skip to content
Tactiverge

Computer engineering · also Robotics

Super-loops and finite state machines

Much firmware runs as a super-loop: an endless loop that reads inputs, decides what to do and updates outputs, over and over. A finite state machine keeps complicated behaviour clear by naming a small set of states, such as idle, moving and fault, and defining exactly which events move the system from one state to another. To do several things at once, a loop should never sit in a long delay. Non-blocking code instead checks how much time has passed and acts only when a task is due, using unsigned arithmetic so timer wrap-around is handled correctly.

Why it mattersA gripper's firmware can be written as states such as open, closing, holding and releasing, which makes every transition easy to test.

Learn it

  1. 1Super-loops and finite state machinesEmbedded Systems · Programming foundations
  2. 2Non-blocking timing and timer wrap-aroundEmbedded Systems · Programming foundations