# Light Switch Digital Logic Problem

Thread Starter

#### archelon

Joined Jan 27, 2012
3
Hey all,

I'm having trouble with this homework problem from my digital logic class.

A low voltage lighting system is to use a binary logic control for a particular light located at the intersection of T-shaped hallway. There is a switch for this light at each of the three end points of the T. These switches have binary outputs 0 and 1 depending on their position and are named X1,X2,X3. The light is controlled by an amplifier with an input Z. When Z is 1 the light is ON and when 0 the light is OFF. You are to design a logic circuit Z = F(X1,X2,X3) so that if any of the switches is changed the light will change.

I would love to show you all the progress I have made, but I can't even figure out where to start. If someone could just point me in the right direction that would be fantastic.

Cheers

#### holnis

Joined Nov 25, 2011
49
The best way to study is to attempt to do these exercise on your own before looking at the answers.

First of all, try to define the truth table, it is a method to show how the output of your digital circuit reacts to the inputs. All the possible combinations of inputs for the circuit are listed, and the resulting outputs are defined at the end of each row.

#### mlog

Joined Feb 11, 2012
276
Try doing it with 2 inputs. If you figure that out, then go to 3 inputs.

#### crutschow

Joined Mar 14, 2008
28,529
You could use a toggle flip-flop to remember the state of the light (input signal to Z). Then you need to determine how to clock the FF and toggle it to the opposite state whenever any of the switches change state.

#### holnis

Joined Nov 25, 2011
49
Here is what the truth table might look like.

X1 X2 X3 Z
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

To the OP, to verify that this is correct .. If you change any one of the inputs does the output change? Now do this for each of the lines and if the output changes for a change in any of the inputs then the truth table has been proven to be valid.

You could use a toggle flip-flop to remember the state of the light (input signal to Z). Then you need to determine how to clock the FF and toggle it to the opposite state whenever any of the switches change state.
Actually, i didn't get your point how is that possible using the FF ? Can you explain more, please.

#### crutschow

Joined Mar 14, 2008
28,529
Here is what the truth table might look like.

X1 X2 X3 Z
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1

To the OP, to verify that this is correct .. If you change any one of the inputs does the output change? Now do this for each of the lines and if the output changes for a change in any of the inputs then the truth table has been proven to be valid.

Actually, i didn't get your point how is that possible using the FF ? Can you explain more, please.
His requirement can not be readily done with a static logic circuit, it needs sequential or clocked logic. Thus the truth table needs to show a change in the input, not just their static position. That is, for any arrangement of switches shown on your chart, Z can be either a 1 or a 0, depending upon the history of the previous switch positions.

The FF holds the state of Z. Then you need a logic circuit that triggers the FF to change state when any of the switches changes state. That satisfies the requirement that Z changes state when any switch changes state.

#### rain175

Joined Feb 13, 2012
1
My post may be from left field and a few years late but....
Looks to me like a simple addition of the 3 inputs would solve the problem.
0+0+0=0 Change any of the inputs and the output changes.
1+0+0=1 Then subtract 2 for any thing over 1.
1+1+0=2-2=0 and once again
1+1+1=3-2=1
It would be nice to see a block digram of circuit.

#### holnis

Joined Nov 25, 2011
49
The FF holds the state of Z. Then you need a logic circuit that triggers the FF to change state when any of the switches changes state. That satisfies the requirement that Z changes state when any switch changes state.

Ok, Thanks. I think I've got it right now.

#### crutschow

Joined Mar 14, 2008
28,529
An easy way to generate a short clock pulse on a transition is to feed the transition to both inputs of an XOR gate with one input delayed by a couple of inverter gates in series or an RC circuit.

#### Brownout

Joined Jan 10, 2012
2,390
I think this can actually be done with static logic. Write out the truth table for an x-or gate. You can easilly see that changing any single input changes the output state. Then you can expand that idea to an arbitrary number of inputs.

#### crutschow

Joined Mar 14, 2008
28,529
I think this can actually be done with static logic. Write out the truth table for an x-or gate. You can easilly see that changing any single input changes the output state. Then you can expand that idea to an arbitrary number of inputs.
You are correct. I was mistaken, you can do it with static logic. It appears that the solution to the OP's problem just requires two XOR gates. All the OP has to do is figure out how to connect them.

Last edited:

#### mlog

Joined Feb 11, 2012
276
You are correct. I was mistaken, you can do it with static logic. It appears that the solution to the OP's problem just requires two XOR gates. All the OP has to do is figure out how to connect them.
You guys are right. It's simpler than I first thought. My first attempt was to use an XOR, but I thought I needed clocked logic to retain the memory of the prior state.

It did help me to realize the simple solution by solving the problem with two inputs. Once I solved it with two, then three inputs was a piece of cake. I also made a state diagram that helped me to check my solution.