Hi:
I've developed a machine which implements a real-time dynamically reconfigurable state machine. This is done by having two sets of state transition tables in memory, ping-pong style, then synchronously switching from one state machine data structure to the other when it is appropriate to do so.
Transitions are done in 2-4us on a TMS320F2812 DSC. The output of the state machine is waveform generation tables that produce digital waveforms and time-domain pulses as a function of crank angle in an engine lab experiment. The inputs to the state machine are the cycle count, external world input bits and button presses. The state machine is evaluated once per engine cycle.
The main purpose of this is that with optically accessible engines, combustion is usually "skip-fired" so that a burn takes place only 1 in
10 cycles, for ex. Thus, rather than make a single waveform table with 9 duplicate cycles and 1 fired, by using a state sequencing waveform generator, only the waveforms of unique cycles need to be stored. Also, the state machine can modify the waveforms based on external input conditions, which a simple sampling arbitrary waveform generator cannot do.The only problem with this scheme is that the users are challenged by the state machine concept, and the programmer who has to develop the user interface (which must be backward compatible with an older system without sequencing capability) is also "not used to thinking in the state machine metaphor." So he is stressed trying to figuring out how to make a generalized user interface to this, that doesn't let the users hang themselves.
I tend to argue that it isn't a big deal, the state graphs are usually going to be rather simple. I proposed some language extensions to the old description file format that would allow access to the state machine function in a readable way, but that was ignored. I don't make light of the programmer's task--it is challenging and I'd have to spend a long time thinking about it myself to solve it.
Rather than get into the specifics of the engineering of this system, I'm interested in simply considering if there are alternate approaches to accomplishing the desired effect. That is:
- Dynamically reconfigurable waveform tables, synchronous with the engine cycle boundary, must have all decisions deterministically made and internal data structures switched in 2-4 us, but frequency of this process needing to happen is low, about 30Hz max.
- Absolutely glitch-free waveform table switching.
- No discontinuities of the waveform cycle sequence, ie., no skipped or duplicated cycles when changing data.
- Make decisions on what waveforms to output based on 16-bit cycle count, and 16-bits of external input bits.
Oh, the way waveforms are generated is by compare match interrupts with value of a counter which is interfaced to a quadrature encoder. This mechanism should be retained.
I have spent considerable time studying the development of industrial automation, robotic, machine, avionics, etc. control technology, and it seems to be the case that the state machine concept is central and standard.
Further, that in the past 10 years, the reconfigurable (table-driven) state machine concept has become accepted as the preferable way to implement a state machine, if the need exists to change the state graph without reprogramming.
Thus, I think it is likely that I have selected the best architecture for this application.
But I am always interested to learn new ideas and consider alternative approaches.
Any thoughts are welcome.