ModSlaveSim help v3.07 - 4.4.2. On button and Off button - a simple latch
Download manual: HTML
A latch retains its value until it is told to change it.
This is achieved in the ModSlaveSim language by using an
if then
without an else
.
The simplest form of latch has an Output that can be 0 or 1, and two inputs: a Set input, which sets the output to 1, and a Reset input, which sets the Output to 0. If the Set and Reset inputs are both 0, the Output retains its last value.
It is similar to having two buttons - one for on and one for off. (Those with an electronics background will know this as a level-triggered RS flip-flop.)
Table 7. Simple latch
Register Address | Register Name | Statement |
---|---|---|
$100 | Set | |
$101 | Reset | |
$102 | Output | if $100 != 0 then 1 else if $101 != 0 then 0 |