3
\$\begingroup\$

I am working on simulating a traffic light control based on the "Digital Fundamentals" book by Thomas L. Floyd, but I encountered an "oscillation apparent" error when one of the counters reaches its maximum value.

The system has four states, each representing the lights of a traffic light control:

State 1 - Green/Red (G1/R2)   - 25 ticks
State 2 - Yellow/Red (Y1/R2)  - 4 ticks
State 3 - Red/Green (R1/G2)   - 25 ticks
State 4 - Red/Yellow (R1/Y2)  - 4 ticks

And the cycle should be G1/R2 -> Y1/R2 -> R1/G2 -> R1/Y2 -> Repeat.

Which state has a timing controlled by two counters: the upper counter, which counts the 25-second intervals, and the lower counter, which counts the 4-second intervals.

The diagram that I have until now:

enter image description here

The problem is that when one of the counters reaches its maximum value, the circuit oscillates instead of transitioning to the next state.

As shown in the image below: Traffic Light Circuit

What could be causing this oscillation? How can I ensure that the circuit transitions between states as intended?

\$\endgroup\$
1
  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$ Commented Jan 12 at 21:58

1 Answer 1

2
\$\begingroup\$

What could be causing this oscillation?

Logisim reports oscillation, if it cannot determine the final values after several rounds of recalculation, triggered by changed values.

One very simple example is this (yes, I use the international IEC gate forms, not the US-only old forms):

switchable oscillator

Change the value of the input to "1", and the circuit will oscillate.

So you have one or multiple feedback loops, at least one of which causes the oscillation.


Concerning the counters, you change the counting direction via the upper left input. This changes the carry output immediately. In the feedback loop analysis we need to take this into account.

From the documentation (emphasis by me):

The counter holds a single value, whose value is emitted on the output Q. Each time the clock input (diagrammed with a triangle on the component's south edge) triggers according to its Trigger attribute, the value in the counter may update based on the two inputs on the component's west edge: The upper input is called load and the lower is called count, and they are interpreted as follows.

load count trigger action
0 or z 0 The counter remains unchanged.
0 or z 1 or z The counter increments.
1 0 The counter loads the value found at the D input.
1 1 or z The counter decrements.

East edge, lower pin (output, bit width 1)
    Carry: When load and count indicate to increment, this output is 1 whenever the counter is at its maximum. When load and count indicate to decrement, this output is 1 whenever the counter is at 0. At all other times, this output is 0.


Feedback loops

I reproduced your circuit, just a bit denser. And I cut open the relevant feedback loops (by replacing the wires with outputs and inputs) and provide the different states here.

This is the situation right after the rising edge, when the upper counter reaches its maximum. Both open feedback loops show that they want to change.

situation right after the rising edge

When I let the upper feedback loop propagate its "1", it immediately returns to "0".

upper feedback loop propagates

When I let the lower feedback loop propagate its "0", it immediately returns to "1".

lower feedback loop propagates

When I let both feedback loops propagate their values, they immediately return to their former values.


How can I ensure that the circuit transitions between states as intended?

Correct your circuit. ;-)

More specifically, correct the Boolean logic of the feedback loops that cause the oscillation.

For this, simplify your design. Separate concerns and implement them on their own. For example, design and build the Boolean logic of the state machine first and test it. Only then add the counters. After that design and build the Boolean logic for the lights.


Final notes:

  • Strive to draw circuits simpler. You have wires folded multiple times, unaligned gates, unnecessary big gates, unused inputs at gates, multiple inverters in paths...

    This is my attempt, for example. It does not look finished, because the Boolean logic is not yet clear.

    my attempt

  • Please check your statements before posting. It would be helpful if you added the maximum count of each counter, too.

    Which state has a timing controlled by two counters: the upper counter, which counts the 25-second intervals, and the lower counter, which counts the 4-second intervals.

    This cannot be true and it is for sure the other way, because the upper counter clearly shows just one hex digit and can therefore only count to 15 at maximum, while the lower counter shows two hex digits and can therefore count more.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.