Matrix: Logic Maestro macro does not function as expected
Racehazards or race conditions can cause Logic Maestro macros not to run asexpected.
Any Logic Maestro macro where two conflicting actions are requested simultaneously will result in either nothing happening or unexpected behavior of the system. Run your simulations at slow speed if the system is not functioning correctly. Add 25 ms buffers where appropriate.
The following is an example of race conditions causing a macro to notfunction.
A three-state LED logic macro
A customer sent the above logic. Theyhave set up two controls that turn on one of three LED on one panel key dependingon the state of the controls. Thisappears to work in simulation but when applied to a frame (ignoring the factthat we are missing labels etc.) what we actually get is not correct. Thekey might flash amber and then switch off when the control is toggled. We don'tsee red or green.
Thereason for this can be seen if simulation mode is run at "Divide by40" speed:
Wecan then see below that when the bottom control is latched on, there is a shortperiod of time when both green and amber indication should be on. This is arace condition. The frame can't do both so it ends up doing neither.
The same thinghappens when the top control is toggled to go between amber/green and red. Thereason this happens is because each logic gate incurs a 25 ms processing delay.Therefore when we latch the bottom control, the message takes 25 ms longer toreach the amber panel control vs the green panel control. So the green isturned on before the amber is turned off. Similarly, when the top control istriggered the red indication is turned on 25 ms before either the amber orgreen indication is turned off. Note that going back the other way, we don'thave a problem since the red is also turned back off 25 ms faster in this direction. We therefore need tobuild in an equal amount of buffer so that a given control input reaches anyaction it governs at the same time. Unfortunately this is not always as simple as it sounds. In this example, weend up with the logic below. We have had to introduce extra toggles because one LED has to switch off before the other in both directions. Hencefewer 25 ms buffers are required on one side of the toggle compared with the other. The overall difference in times is not great as far as the user is concerned and the logic now functions as expected on the frame.