# Logisim - Counter with clock and Magnitude Comparator not working as expected

I have the next circuit in logisim: It is a simple 8 bit counter, with a magnitude comparator that outputs 1 when certain value is met.

The problem is that if I simulate with a clock, the counter reaches 1d (just before the target value 1e) and then it resets to 00, so the circuit never outputs 1.

Is it something that I am doing wrong?

Thanks!

Edit:

This is the circuit that I am building:

Context: It is a problem of a college assignment. I have to build a "ventilation system". T will be 1 when certain temperature is reach inside a room. N is an orange led, R is an red led and V turns on the fans in the room. First I build a Moore's diagram and define the states of my circuit.

• E0 : Temperature in the room is normal, N, R and V are off.
• E1 : Temperature in the room reached target. N (orange led) turns on. R1 = 1 and C1 starts counting.
• E2 : When T is 1 for 30 seconds, then N turns off, R and V turns on. (The fans start to cooldown the room).
• E3 : Once when T is 0, the fans (V) will be on for the next 5 mins (assume that they will prevent T from change to 1 again). Also, N is on and R is off. R2 = 1 and C2 starts counting.
• Finally C2 reaches 5 mins, S2 fires and everything comes back to E0.

Then I built a Moore's FSM (Ei = AB; E0 = 00; E1 = 01; E2 = 10; E3 = 11):

Then, I built this table who it will help me define the logic equations for the outputs, A(t+1) and B(t+1):

The equations:

With the equations then I built C3:

First flip flop is A, the second is B.

C1 and C2 are modules like the first one, but with different target values. I found out if I feed a constant 1 to R1 it solves the problem. Now, when C3 feeds 1 to R1 the counter resets just before reaching the target value. If I increase or decrease the target value, the counter stills reaches target-1 and resets.

Maximum value is set to ff and 'Action on Overflow' is set to 'wrap around'.

My circuit does not fire S1 even though R1 is always 1 and C1 counts to 30 secs:

But if I put a constant 1, it does (even tough R1 stills at 1 also and never resets until S1 fires):

• Ground LOAD and set COUNT to 1? – jonk Nov 24 '20 at 8:09
• I can't replicate your problem. The counter is set to 5 bits, so is the comparator and the constant, and it outputs 1 when it reaches 0x1e. It does so even if I set them to higher than 5 bits. If I connect the output of the comparator to the reset pin of the counter, it resets at the correct value. What settings are you using (including the tick speed)? – a concerned citizen Nov 24 '20 at 10:14
• Do you have this circuit as part of a higher level circuit, which feeds back S1 to R1? -- What are your setting "Maximum value" and "Action On Overflow"? – the busybee Nov 24 '20 at 12:12
• @thebusybee yes, exactly. I updated the question with more information, maybe a little too much, sorry :( – Ulises Nov 24 '20 at 20:08
• @Ulises Have you need to set the comparator to unsigned? I just tried it again and I still can't replicate the problem, with or without unsigned, with or without tri-state. Maybe a shift register, last resort? – a concerned citizen Nov 24 '20 at 20:40