RE: [SeattleRobotics] Why FSMs? Example! (was Loki)
- Alan KM6VV said: Monday, December 31, 2007 9:30 PM
> Sometimes it's tough to avoid polling. Interrupts are oneThat's the basic idea behind IsoMax(TM). We have a scheduled
> solution. Or if periodic checking can service the device
> within latency requirements.
(periodic) interrupt that should run faster than your fastest
latency requirements. As I say, for mechanical systems, 100 Hz
is pretty good. For electronic ones, you may want to run faster.
This is the basic scan loop concept used in Relay Ladder Logic
In our language however, we gather all the waste cycles (those
not used by the polling interrupts to check transitions and do
actions) to give to the foreground routine which will usually
communicate with the operator, which is ultimately the final
waste of time, particularly if there is no operator there. A
task can be autostarted here as well, such as data logging and
progress following if desired. But if there is an operator, he
can query memory, dump values, see what's going on
interactively, while the real real-time program just keeps
runing in the background. The operator can even add more
programming while real-timer operations go on in the background
We started with the lowest common denominator, the scheduled
(periodic) scanning. We can also run in interrupts, where the
interrupt itself calls the FSM directly. And we've also
implemented other versions, to allow layers of latencies. But we
haven't released those codes yet. The next step has one layer
for mechanicals, and another layer which can be much faster for
faster processes like PID, and electronic communications.
> However there must still be a little overhead (depending onframes (PC).
> the processor) for entering a new function, such as stack
Yes, there's a bit of overhead, but the context switches we do
are very fast. No major stack frames to mess with et. al.
> Waits. "The rationale behind this method is a state is aWell, follow the line of reasoning: A real-time program must
> wait.". Why a wait? You give up a "tick" of the rate you
> call your various state machines, but what's the wait?
wait for external synchronization. But rather than blocking, it
can hand the wait off once it know the synchronizing event
hasn't happened yet. (An interrupt event if the hardware
supports this, or a timer event which can cause a periodic look
at a rate higher than the latency requirements.) The wait is the
state. State comes from Latin, Stare to stand. Nothing happens
when you stand. And you "stand at ease" until there is something
> Even faster if it's a vector instead of aMuch much faster. Why compute the state each time? You knew what
> switch/case, I see that.
the new waiting state was going to be last time a transition
happened. So why re-look it up every time the machine is called.
Better to just go to the test that determines whether to leave a
state or not. Again, set up the next wait vector on the way out
of the current state.
Then we also play some tricks in how we link the active machines
so they ripple through their time slice as quickly as possible.
- Dr. Bruce.
> Interesting question and explanation - except that butterflies actuallyhave
> 6 legs.... 4 long and 2 short.OK, I looked it up. In Danaidae (monarchs), Satyridae (whites, graylings)
and Nymphalidae (emperors) the two front legs are very short, have no claws
and are useless for walking. I thought Papillionidae (swallowtails) were
the same but they're not, they have 6 good legs.
It gets wierder. In Riodinidae, the males have 4 walking legs but the
females have 6.
Lycaenidae (blues) and Hesperidae (skippers) all have 6 legs.
What on earth can one learn from that?
Anyway, Alan asked what "bugs" are quadrupeds. I said mantises, monarchs
and swallowtails. I was wrong about swallowtails. I was taught all this
stuff decades ago so forgive me if I'm a bit rusty. I even spent one summer
as a student doing fieldwork in the west of Virginia catching swallowtails
and monarchs so I certainly _ought_ to have remembered the details.
I still can't think of any other arthropods with just 4 walking legs. I
think some crustacean larvae have only 4 legs but they don't use them for