# Logic Design: Interpreting entering and leaving a room.

1. Dec 28, 2013

### PrincePhoenix

The problem statement, all variables and given/known data
Hello. We have been given a project in our course "Digital Logic Design", which is an introductory course to Digital Logic. We are only allowed to use gates, multiplexers, flip-flops/latches, counters, comparators, simple displays (like seven segments) etc.

I am making an automatic room lighting system, for a room with one door.

The attempt at a solution
My logic is that there will be two IR transmittors and receivers, one each on either side of the door pane. Depending on the sequence in which the receivers go dark, the circuit will detect whether someone entered or left the room, increment/decrement a counter, counting the number of people accordingly. If the counter becomes zero, the light(s) are switched off. For greater than zero, it will be switched on.

So I thought it'd be two sequence detectors (made from different gates) (one for each sequence)(we've already built one in a lab, using flip-flops(so, synchronous)), with the two IR receivers acting as inputs to the sequence detectors. On detecting either of the two sequences one of them will increment and the other would decrement the counter through their outputs.

Now since it'd give an ouput in each clock cycle, the sequence of states that the detector will actually get will hardly ever match the ones for which I will make the sequence detector.

Any pointers on how this may be overcome? Is it possible to make it purely through a combinational circuit?
Can this logic work with an asynchronous circuit? (we haven't and won't be studying them this semester. We haven't studied counter yet. So I apologise for any weird assumptions made above about counters)

2. Dec 28, 2013

### Staff: Mentor

I don't understand that.
Once the second detector gets interrupted, send a signal to the counter and reset both sequence detectors.
Probably.

3. Dec 28, 2013

### D H

Staff Emeritus
What happens if two people enter the room together, and then only one leaves? You don't want to leave the other one person in the dark.

4. Dec 28, 2013

### Staff: Mentor

As long as they don't touch each other (in the projection of the sensors), the system can work.

5. Dec 29, 2013

### PrincePhoenix

What I meant to say was that each sequence detector would be looking for a particular sequence.
One sequence detector would output '1' for incrementing the counter when the input sequence for entering is detected. (lets say it would be 00->01->11->10->00), while the other does the opposite for the leaving sequence (sequences will be generated by the IR receivers, so depending on the sequence in which they get interrupted, two different sequences will be generated).

Being a synchronous circuit, it will be taking inputs every clock cycle. So if the clock is too fast, for the person's movement, it might take each input twice or maybe more, so it might not match the required sequence.

The second sequence detector gets interrupted? Or the IR receiver/detector?

6. Dec 29, 2013

### Staff: Mentor

Your clock (if you use one) has to be much faster than the persons, otherwise the system cannot work. The sequence detector needs a "wait" operation if nothing changes (it has to remember its state).

The second IR detector.

7. Dec 29, 2013

### PrincePhoenix

What is the "wait" operation? Staying in the same state if the inputs from the IR receivers remain unchanged? Or is it something more complicated?
For the sequence detector to wait if nothing changes is exactly what I think I need.

8. Dec 29, 2013

### Staff: Mentor

There's a reason that typical room occupancy sensor systems use passive IR (PIR) detectors to detect occupancy. Counting bodies entering and leaving a room has too many problems, and can be too easily fooled. The PIR sensor is used to turn on the lights when motion is detected in the room, and a timer is used to turn off the lights some amount of time after no motion is detected.

Also, be sure to use a synchronizer circuit if you are detecting some asynchronous events for processing in a synchronous circuit. Are you familiar with synchronizer circuits? Why are they necessary?

9. Dec 29, 2013

### PrincePhoenix

No. Haven't studied any synchronizer circuit or their uses.

10. Dec 29, 2013

### Staff: Mentor

11. Dec 30, 2013

### Staff: Mentor

Right.
Sure.

@berkeman: It is a course about digital logic. IR sensors in the room are a nice solution for a product, but probably not so interesting in terms of digital logic.