PLCs (Programmable Logic Controllers) are a very useful control solution for an exhibit variety and interactive applications. These general purpose control devices can accept an inputs number from such devices as pushbuttons, motion joysticks, detectors, etc. They can have analog, multiple relay, and serial outputs to control lights, sound effects, motors, etc. A control program that determines in the middle which outputs is activated when certain combinations of inputs are received. Available resources include numerous counters, timers, and registers.
The drawback of principal to these devices has been the steep learning curve and inherent difficulty with program maintenance using their traditional Relay Ladder Logic (RLL) programming language. However, PLC programs can become very simple to create, and are easy to maintain and modify by using state machine programming techniques.
A state machine model is a paradigm programming wherein the “machine” (i.e.: the controller) can only ever be in one of a set of distinct states (conditions) at any given time. It is actually a great simplification—as we shall see while this concept may sound complex.
Programming of state machine can be done on any PLC through clever use of SET and RESET instructions and using internal contacts to direct flow. It is much simpler, however, if the PLC supports this programming type directly. The good news is that today many do. The bad news is that they seldom refer to it as “state machine programming,” nor do different manufacturers use the same term. You will see it referred to as “STL programming,” “stage programming,” “SFC programming,” and various other terms.
All of these have one thing commonly: a special internal “contact” attached directly to the power rail controls flow into each state. This contact mostly always has an ‘S’ designation for state. The key concept is that one, and only one, state can be active at any one time, and all the logic in the other (inactive) states is disconnected from the power rail.
PLC Programming State for Exhibit Control
Below is the programming PLC programming state for exhibit control:
S0—Initialization State
This state will apply to every program virtually you create it is the initial state that is always entered upon power up. It is one time executed, and is never re-entered unless the PLC is a RESET or powered down occurs.
This state is primarily used to initialize data variables. It is good programming practice to place all counter and timer data here, and then load the counters and timers from the variables.
This state will initialize the message look-up table, and setup the look-up table pointer to point to the first message number in the table. It transitions to S1 when completed. For clarity, we will not show the ladder diagram for this state.
S1—Wait for Trigger State
Monitor the input of Motion detector for a trigger from the motion detector. Upon receiving a trigger, transition to S2.
S2—Set Message Bits State
Transfer the number of current message from the look-up table to the output of Bitx relays as a five-bit binary value, then transition to S3.
S3—Strobe Message State
Wait for a 0.2S delay to allow the outputs of bit to stabilize, then pulse the Message strobe relay for 0.4S to signal the message repeater to play the message determined by the Bitx relays (i.e.: Y0 through Y4), then transition to S4.
S4—Wait for Message State
Wait 0.4S to be sure the message has started playing, then monitor the input of Message playing until the message has completed playback, then transition to S5.
S5—Get Next Message Number State
Increase the look-up table pointer to make the next message in the “random” sequence the number of current message. If it was at the end of the table, reset the pointer to the start. Then transition to S6.
S6—Wait State
Wait for a delay of programmable to prevent an immediate trigger of the next sound effect by the same visitor. The delay of value is determined by the value of a variable initialized in S0. Then transitions to S1, and start the process again.