Simulation of an alarm circuit: How it worksDescription| How it works| circuit with timer
The animation in this app works using Conditional Formatting and a macro. Cells are resized and merged to make the connectors and conditional formatting is used to change the connector colours (red if contents are TRUE, otherwise green). The macro is used for toggling the output of the oscillator periodically, generating the audio tone (using the 'Beep' VBA command) and to store the previous values for the flip flops and the positive edge trigger. The macro (Scan) is recursive, it keeps calling itself till the power off button is pressed.
Boolean Logic is simulated using the Excel functions AND, OR and NOT. To see the logic, select any connector and look at the formula bar to inspect the formula. For example, the trigger is simulated using the forumla =AND(Alarm,NOT(PrevAlarm)), where Alarm is the current alarm state and the PrevAlarm is the Alarm state at the previous scan (updated by the Scan macro). The flip flop is simulated likewise, the formula for the flip flop driving the buzzer is =AND(NOT(CL31),OR(CD25,PrevOut1),Power). CL31 is the Reset input and CD25 is the Set input. PrevOut1 is the previous output of the flip flop, which is managed by the Scan macro. When the power is turned off, all values are driven to logic state 0.