State Machines There are four PICs in our circuit - each runs a separate state machine shown in the below pictures. Pseudocode and code listings for header and source files can be downloaded by clicking the underlying buttons.
Note that some of our timing relies on user reaction times being on the scale of seconds. Some of our timers are set for time scales of milliseconds. So while theoretically it is possible to break the state machines during those millisecond time frames, we found that in practice it does not happen due to the speed at which people actually move.
The four PICs communicate in two ways. The main game PIC sends out an active low signal to indicate when the other PICs should be on. For this signal, a low value tells the other PICs to turn on, while a high value tells the other PICs to revert to a waiting state.
The second way the PICs communicate is with a custom protocol where the two PICs that wish to communicate share a wire. The signal is unidirectional. An event is communicated by sending a 50 ms high pulse and guaranteeing that a 50 ms dead (low) time will exist after the pulse ends. By monitoring the digital input frequently enough, the receiving PIC should catch this pulse and generate an event to respond. This signaling method is sufficient because the events communicated between the PICs occur on human time scales and do not repeat quickly enough to necessitate a faster communication method.
While one of these pulses is being sent, the laser state machine enters an "active transmission in progress" state which ignores additional beam break events while the 100 ms transmission is being sent.