Electronic – How to wire up a street light to change lights in specific states (digital circuit)

counterdigital-logicflipflophomeworksimulation

This is the final project for the only electronics course in my career. I have never taken any other electronics course and I'm seriously at a lost here. I need to score 100 here to pass the course.

I need to create a synchronous counter that will control a streetlight with 4 sides. The South-North side has 4 lights (an extra green one to steer left) while every other has 3.

The cycle lasts 14 seconds.

I have the counter made, but I have no idea how to actually make it turn on/off the lights at the specified times.

Problem instructions are as follow:

"The first green light of S-N and the one from N-S must light up for 5 seconds,
meanwhile, the red lights from E-W and W-E must be on as well.

After these 5 seconds, the yellow lights for both S-N and N-S turn on for 2 seconds.

After this, the red lights for S-N and N-S turn on
and the 2nd green light of S-N will turn on for 2 seconds to allow traffic coming from the south to steer to the west.
This is the only instance where 2 lights of the same side are lit up simultaneously.

While the 2nd green light from S-N is on, every other Red light must be on as well.

After the 2nd green light from S-N turns down, the red light of S-N and N-S will stay on, and the green lights of W-E and E-W will turn on for 3 seconds.

After these 3 seconds, the yellow lights will turn on (while the green ones will turn off) for 2 seconds

and then the red ones will turn on, starting the cycle anew.

Total duration is 14 seconds".

Counter and lights

This is SERIOUSLY driving me crazy because I see no way in which I could say "From 1 to 5 stay ON and then turn OFF", I cannot think of a single way of setting up logic gates so that they're only outputting 1 to the lights when
they're 0001, 0010, 0011, 0100 and 0101. Because if I make logic to output 1 when you have that, then literally every other binary code except from 0 and 15 will output one. I.e the lights will never turn off.

Note that this is entirely digital, using Digital Works. The solution cannot have any component that is not included in the program and should, in fact, only include Flip flops, LEDs, logic gates and of course the wires.

EDIT: Thank you for your help and tips. I managed to do it.
For reference, here is the completed and working circuit:

enter image description here

Best Answer

There are lots of ways to take this. You could go asynchronous or synchronous, for example. But I'll suggest a start using a synchronous counter. You need a modulo 14 counter. For that, I might suggest a modulo 7 LFSR (not the only way to go) with a separate FF that toggles to make a total of 14 states:

schematic

simulate this circuit – Schematic created using CircuitLab

The codes, in sequence, are: 0000, 0111, 0100, 1101, 1000, 0011, 1110, 0001, 0110, 0101, 1100, 1001, 0010, and 1111. (The missing codes are 1010 and 1011.) This provides 14 distinct states. You can then use these, with added logic, to generate your light controls. (Note that in the above diagram, not only do you have access to each bit but also access to the inverted state of each bit. Also, if these DFFs have both Q and /Q, then the above diagram can be simplified a bit.)

By the way, you only have 7 distinct light control wires. You need three for the east-west and west-east directions (all of which use the same controls for red, yellow, and green lights), plus three more for the shared north-south and south-north directions (again, all of which use the same controls for the red, yellow, and green lights), and one more control line for the special south-north special-green light.

This is not necessarily the best way to handle it. It may require some combinatorial logic that you may wish were smaller. But it certainly can work.

(Note that the CLK input should be driven with a \$1\:\text{s}\$ clock rate.)

Do you know how to lay out the combinatorial logic needed for your control lines to the lights? Is that the problem?


I've quickly laid out what I think may work, regarding K-maps for the above states. However, be aware that I may make mistakes. So check the following work for yourself. (In what follows, 0 means off and 1 means on.)

East-West and West-East K-maps:

$$\begin{array}{rl} \begin{smallmatrix}\begin{array}{r|cccc} Red&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&1&1&1&0\\ \overline{Q_D}\:Q_C&1&0&1&1\\ Q_D\: Q_C&0&1&0&1\\ Q_D\:\overline{Q_C}&1&0&x&x \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Yellow&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&0&0&0&1\\ \overline{Q_D}\:Q_C&0&0&0&0\\ Q_D\: Q_C&0&0&1&0\\ Q_D\:\overline{Q_C}&0&0&x&x \end{array}\end{smallmatrix}\\\\ \begin{smallmatrix}\begin{array}{r|cccc} Green&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&0&0&0&0\\ \overline{Q_D}\:Q_C&0&1&0&0\\ Q_D\: Q_C&1&0&0&0\\ Q_D\:\overline{Q_C}&0&1&x&x \end{array}\end{smallmatrix} \end{array}$$

North-South and South-North K-maps:

$$\begin{array}{rl} \begin{smallmatrix}\begin{array}{r|cccc} Red&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&0&1&0&1\\ \overline{Q_D}\:Q_C&0&1&0&1\\ Q_D\: Q_C&1&0&1&0\\ Q_D\:\overline{Q_C}&0&1&x&x \end{array}\end{smallmatrix} & \begin{smallmatrix}\begin{array}{r|cccc} Yellow&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&0&0&1&0\\ \overline{Q_D}\:Q_C&0&0&0&0\\ Q_D\: Q_C&0&0&0&1\\ Q_D\:\overline{Q_C}&0&0&x&x \end{array}\end{smallmatrix}\\\\ \begin{smallmatrix}\begin{array}{r|cccc} Green&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&1&0&0&0\\ \overline{Q_D}\:Q_C&1&0&1&0\\ Q_D\: Q_C&0&1&0&0\\ Q_D\:\overline{Q_C}&1&0&x&x \end{array}\end{smallmatrix} \end{array}$$

Special-Green South-North K-map:

$$\begin{array}{rl} \begin{smallmatrix}\begin{array}{r|cccc} Green&\overline{Q_B}\:\overline{Q_A}&\overline{Q_B}\: Q_A&Q_B \:Q_A&Q_B \:\overline{Q_A}\\ \hline \overline{Q_D}\:\overline{Q_C}&0&1&0&0\\ \overline{Q_D}\:Q_C&0&0&0&1\\ Q_D\: Q_C&0&0&0&0\\ Q_D\:\overline{Q_C}&0&0&x&x \end{array}\end{smallmatrix} \end{array}$$


I've included a possible solution below. It's validated, so it works. The point isn't to provide you with a direct answer, but is instead intended merely to let you know what one possible solution might look like.

You appeared to complain about the ability to hold the lights for given times (5 seconds, or 3 seconds, etc.) This shows exactly how that can be achieved.

I didn't attempt to optimize the design (I'm sure that more could be done.) But I simply took the above K-maps and developed what amounts to a CPLD or (AND-OR) matrix solution for the combinatorial logic. The clock is intended to have a one second cycle time.

enter image description here

Here is the lighting results from the above schematic:

enter image description here

Everything prefixed with NS applies to both the north-to-south direction as well as the south-to-north direction. The light prefixed with SN only applies to the south-to-north direction. The rest, prefixed with EW applies to both the east-to-west as well as the west-to-east directions.