This example shows a 1Hz period counter using Shared Variables in
QFIRE Studio
.If the input signal is logic low, the counter must increment by one. If not, reset the counter. But, if the counter reaches the maximum it should stop incrementing until reset.
As a test input signal, a unit step happens at 6s. It is modeled as in figure below:

Figure 1 - Diagram of the input signal
Figure 2 shows the diagram which models the counter.

Figure 2 - Diagram for the logical conditions required
When the count value is lower than the threshold, the Shared Variable 0 receive the signals from Switch 2, otherwise it receives signals from Switch 3. Its behavior can be detailed as follows:
The test input signal modeled in Figure 1 generates the signal in the following graphic:

Figure 3 - Test signal (unit step at 6s)
And the the count value for this simulation is represented by the following graphic (increments when input is low, decrements when input is high, and is bounded between 0 and 5):

Figure 4 - Counter output signal
At the time of 4s the counter reaches the threshold value and holds it until the time of 5s. When the input signal becomes high at 6s, the counter resets.
About MWF
MWF is a traditional Brazilian company that provides a wide range of electronic and mechatronic products for industry sectors such as automotive, agricultural machinery and aerospace.
Contact Us
Rua Doutor Siqueira, 139 / Sala 804 Campos dos Goytacazes - RJ, Brasil
contact@mwf-technologies.com
© 2018-2026 MWF. All rights reserved.