Thread Starter

Hornett

Joined May 15, 2026
27
T
You have my condolences. The World is a crazy place these days.
Thank you, that means a lot


Are you going to actually use 74LS chips or are you going to program that Altera FPGA board that (I think) connects to Quartus.
I'm going to use 74LS chips, altera quartus is just to simulate the circuitry and show our instructor the output of each section
 

WBahn

Joined Mar 31, 2012
32,870
It sounds like you are not doing the very first thing that should have been done -- break the problem down into smaller subproblems that can be tackled individually and then brought back together. You are trying to tackle everything as a whole all at once.

Your problem description seems incomplete. You say that student entry is allowed only if there are fewer than 15 students and more than five seconds on the timer. So how can the number of students ever exceed 15?
 

Thread Starter

Hornett

Joined May 15, 2026
27
You say that student entry is allowed only if there are fewer than 15 students and more than five seconds on the timer. So how can the number of students ever exceed 15?
Nono, i meant as in the LED is green when there's fewer than 15 and more than 5 seconds on the timer, then the light turns orange when its on the halfway point (so either above 15 students (excluding the 30th student which marks maximum capacity), or when 5 seconds has passed marking that half of the allocated time has passed, but it still allows entry, then when either 30 students are in, or the timer hits 0, it closes and turns red
 

WBahn

Joined Mar 31, 2012
32,870
Nono, i meant as in the LED is green when there's fewer than 15 and more than 5 seconds on the timer, then the light turns orange when its on the halfway point (so either above 15 students (excluding the 30th student which marks maximum capacity), or when 5 seconds has passed marking that half of the allocated time has passed, but it still allows entry, then when either 30 students are in, or the timer hits 0, it closes and turns red
Okay. Thanks for the clarification.

You have a switch to lock the door, and a switch to reset everything. You define what happens when the door is unlocked. But you don't appear to have a way to unlock the door (other than resetting everything).
 

Thread Starter

Hornett

Joined May 15, 2026
27
Okay. Thanks for the clarification.
Anytime, forgive me for the lack of clarification in the main message



You have a switch to lock the door, and a switch to reset everything. You define what happens when the door is unlocked. But you don't appear to have a way to unlock the door (other than resetting everything).
Yes, the same switch, when we switch the lock (L = 1), its locked and we can't change the student count, then we we switch it again (L=0), it is unlocked, but the timer resets to 10 and the student count remains the same
its a switch not a button
 

WBahn

Joined Mar 31, 2012
32,870
Anytime, forgive me for the lack of clarification in the main message




Yes, the same switch, when we switch the lock (L = 1), its locked and we can't change the student count, then we we switch it again (L=0), it is unlocked, but the timer resets to 10 and the student count remains the same
its a switch not a button
Okay... but if you are distinguishing between "switches" and "buttons", with "switch" implying two persistent states, what about the "switches" for student entry/exit and session reset? Are those also switches and not buttons? What is the behavior if the switch is left in the activated position?

To some degree, this is an issue you need to address regardless of whether they are switches or buttons. You also need to consider what the expected behavior should be if multiple switches are active at the same time, particularly the entry and exit switches. The most obvious interpretation in this case is that a student is leaving and another student is entering, thus the count remains unchanged. But if that's the case, you need to ensure that your system enforces that behavior, as opposed to discovering that the design leaves it undefined and the implementation gives priority to one and ignores the other.
 

Thread Starter

Hornett

Joined May 15, 2026
27
Okay... but if you are distinguishing between "switches" and "buttons", with "switch" implying two persistent states, what about the "switches" for student entry/exit and session reset? Are those also switches and not buttons? What is the behavior if the switch is left in the activated position?
In that case we can treat it like a toggle, i believe, each switch is an additional student entry orexit

To some degree, this is an issue you need to address regardless of whether they are switches or buttons. You also need to consider what the expected behavior should be if multiple switches are active at the same time, particularly the entry and exit switches
oh yeahh, thank you for letting me know

But if that's the case, you need to ensure that your system enforces that behavior, as opposed to discovering that the design leaves it undefined and the implementation gives priority to one and ignores the other.
okay thank you so much
 

dl324

Joined Mar 30, 2015
18,333
I'd do as @WBahn suggested. Break the problem up into smaller pieces. 10-0 countdown counter with appropriate inputs from the student counter and relevant switches. Student counter with relevant inputs from the 10 second countdown counter and switches. 0/L indicator, etc.
 

WBahn

Joined Mar 31, 2012
32,870
Also, encapsulate as much of the information as possible.

If a block only needs to know whether or not there are fewer than 15 students in the room, don't send that block the full set of signals for how many students are there, just a single signal that tells it what it needs to know. The same with the time. If all that a block needs is to know whether or not there the time remaining is more than five seconds, only send it a single signal that provides just that information.

You may need to consider adding states that progress through the switch press/release actions. That depends on the kind of counter you use/implement.

Don't forget to debounce your switches. That's gong to be critical for your entry/exit switches.
 

Thread Starter

Hornett

Joined May 15, 2026
27
I'd do as @WBahn suggested. Break the problem up into smaller pieces. 10-0 countdown counter with appropriate inputs from the student counter and relevant switches. Student counter with relevant inputs from the 10 second countdown counter and switches. 0/L indicator, etc.
okay thank you!

quick question if you don't mind, do you know how im able to set a maximum or a minimum to not go above 30 for example or below 0? if that makes sense
 

Thread Starter

Hornett

Joined May 15, 2026
27
If a block only needs to know whether or not there are fewer than 15 students in the room, don't send that block the full set of signals for how many students are there, just a single signal that tells it what it needs to know. The same with the time. If all that a block needs is to know whether or not there the time remaining is more than five seconds, only send it a single signal that provides just that information.
ohhhh i think i can do that okayy


You may need to consider adding states that progress through the switch press/release actions. That depends on the kind of counter you use/implement.
I made 5 states, RESET or Initial (when pressing the Reset button) / OPEN when there are 0-14 students and/or Countdown is 10-6 / HALF when we reach half capacity or half time passed / Closed when full capacity is reached or countdown is 0 / and LOCK when its manually locked


Don't forget to debounce your switches. That's gong to be critical for your entry/exit switches.
if you don't mind, do you mind giving me a small example?
 

WBahn

Joined Mar 31, 2012
32,870
I made 5 states, RESET or Initial (when pressing the Reset button) / OPEN when there are 0-14 students and/or Countdown is 10-6 / HALF when we reach half capacity or half time passed / Closed when full capacity is reached or countdown is 0 / and LOCK when its manually locked
Your initial diagram shows a clear distinction between combinatorial logic and sequential logic, with the sequential logic being run by a single clock. If that is the way you plan to implement your design, then what is going to prevent it from counting multiple students entering if you leave the ENTER switch closed (or pressed) for multiple clock ticks? You can deal with that by having the machine walk through a sequence of states that represent things such as "ENTER not pressed", then to "ENTER pressed, entry not counted" then to "ENTER pressed, entry already counted" then to "ENTER not pressed". You also have to consider what happens if the switch is cycles completely between clock ticks. If the clock is fast enough, this becomes so unlikely that it can be ignored. But if you have a slow clock (such as 1 Hz), then it is very possible, so you need to add latches to your switches and perform some kind of handshaking to reset them. If you use a counter that has separate up/down inputs, this can be simplified.

if you don't mind, do you mind giving me a small example?
When a mechanical switch is either pressed or released, it generally "bounces", meaning that it makes and breaks contact multiple times as if goes from firmly open to firmly close.

Think of dropping a ball on the ground. It doesn't just stop and stay on the ground the moment it makes contact, it bounces on and off the ground multiple times before finally coming to rest. Your logic circuits are going to see that on-off-on toggling and interpret it as multiple activations of the switch. It doesn't know better. Debounce circuits ensure that the logic sees exactly one on-off or off-on even each time the switch is activated. There are a few ways to do that -- search for switch debouncing and read up on it.
 

Thread Starter

Hornett

Joined May 15, 2026
27
You can deal with that by having the machine walk through a sequence of states that represent things such as "ENTER not pressed", then to "ENTER pressed, entry not counted" then to "ENTER pressed, entry already counted" then to "ENTER not pressed".
OHHHH SO I HAVE TO VERIFY THE ENTRYY, so Entered --> Entery verified (or exit)

Debounce circuits ensure that the logic sees exactly one on-off or off-on even each time the switch is activated. There are a few ways to do that -- search for switch debouncing and read up on it.
Okayyy thank you so much for the help, ill search up on it

You also have to consider what happens if the switch is cycles completely between clock ticks. If the clock is fast enough, this becomes so unlikely that it can be ignored. But if you have a slow clock (such as 1 Hz), then it is very possible, so you need to add latches to your switches and perform some kind of handshaking to reset them. If you use a counter that has separate up/down inputs, this can be simplified.
Assuming I can switch fast enough it shouldnt be an issue, can i count the switch as a "toggle" if that makes sense? like every flick of the switch counts as a student? or is that bad
 

dl324

Joined Mar 30, 2015
18,333
quick question if you don't mind, do you know how im able to set a maximum or a minimum to not go above 30 for example or below 0? if that makes sense
You just decode the outputs of the counters and do things at certain counts.

For example, if you want to turn on the red LED and disable the up-count clock, you can decode 3 on the 10's counter and AND that with the clock up input to disable further increments and also use that signal to turn on the red LED. You'd also use that signal to do something with the 0/L display.

Now that I've told you that. To decode 30, why don't you also need to decode 0 on the 1's counter?

Below 0 could be considered unnecessary in the actual application because after the last student has left the room, there's no one to use the decrement switch. But, if you really wanted to add a check, you could decode 00 and use that signal to disable the decrement input.

If you go down that path, what's to stop a student entering from switching the entrance switch more than once? Or an exiting student from decrementing more than once?
 

Thread Starter

Hornett

Joined May 15, 2026
27
For example, if you want to turn on the red LED and disable the up-count clock, you can decode 3 on the 10's counter and AND that with the clock up input to disable further increments and also use that signal to turn on the red LED. You'd also use that signal to do something with the 0/L display.
alrightt then that should stop it when it hits 30, thank you

If you go down that path, what's to stop a student entering from switching the entrance switch more than once? Or an exiting student from decrementing more than once?
In that case i'd have to debounce my switch?
 

Thread Starter

Hornett

Joined May 15, 2026
27
You need to answer this question or the hints will stop.
oh, sorry i was still confused a bit, but if I only check the 10’s digit for 3, then the door would stay locked for 31, 32, 33… up to 39 but I only want it locked exactly at 30.. OHHH SO I ALSO NEED TO CHECK 1'S DIGIT IS 0, SO IT LOCKS AT 30.. i think
Is that why?


What if they pressed the debounced switch more than once?
then we beat up the student for doing it on purpose.. joke.. well realistically in that scenario its the teacher flipping the swiitch when a student enters, unless you mean by mistake? I don't get what you mean, if for example teacher pressed the button twice for a student's entry, can't he just press an exit for a student leaving? or am i thinking too simply, sorry
 
Last edited:

dl324

Joined Mar 30, 2015
18,333
but I only want it locked exactly at 30.. OHHH SO I ALSO NEED TO CHECK 1'S DIGIT IS 0, SO IT LOCKS AT 30.. i think
Is that why?
Since something happens when the counter reaches 30, there's no need to check the first digit (because counts higher than 30 can't be registered). So decoding the 10's digit for 3 is sufficient.
unless you mean by mistake? I don't get what you mean, if for example teacher pressed the button twice for a student's entry, can't he just press an exit for a student leaving?
What's to say that the teacher couldn't press the button more than once for a student? What's to say that if they incremented one too many times that they couldn't accidentally decrement more than once?
or am i thinking too simply
There is no way to ensure that the person pressing the entry and exit buttons is doing it correctly. You just have to assume that they do it correctly because there's no way for you to verify correct usage.
 

Thread Starter

Hornett

Joined May 15, 2026
27
Since something happens when the counter reaches 30, there's no need to check the first digit (because counts higher than 30 can't be registered). So decoding the 10's digit for 3 is sufficient.
ohhh that makes it simpler, thank you


What's to say that the teacher couldn't press the button more than once for a student? What's to say that if they incremented one too many times that they couldn't accidentally decrement more than once?
thats true.. but would that still count as circuit fault? Would the blame then not fall on the teacher? As you said there's no way for you to verify correct usage
 
Top