Hi everyone. I am currently working on an automatic night light / power out light, and I need to implement a Boolean logic in hardware. I can implement it using an inverter, an OR and an AND gate. However, I was wondering if there is an optimum way of implementing it with the minimum amount of hardware (and no microcontroller). Let's say P shows external power to the circuit, D shows it's dark, and M shows motion is detected. My logic is D && (~P || M), or it can alternatively be ~L && (~P || M), where L stands for "It's not dark". I would be very thankful for your help.
If the circuit has no power then it will not work so there is no need to implement P into your logic.
That leaves you with: Output = D . M
I don't know why you introduced a L = ~D variable at all.
It depends what you mean by "minimum".
You could do it using hand made RTL or DTL logic with a couple of transistors.
Or you could do it with a single 7400 chip
#include <stdio.h>
int nand(int a, int b){
return ~(a&b);
}
int main(){
for (int D=0; D<=1; ++D){
for (int P=0; P<=1; ++P){
for (int M=0; M<=1; ++M){
int orig = D & (~P | M);
int t1 = nand(D, nand(P, nand(M,M)));
int test = nand(t1,t1);
printf("%d %d %d: %d %d\n", D, P, M, orig&1, test&1);
}
}
}
return 0;
}
If the circuit has no power then it will not work so there is no need to implement P into your logic.
That leaves you with: Output = D . M
There is a backup battery, so when there is no power and it's dark, the lights are on. If there is power, the light turns on when it's dark and motion is detected.
I don't know why you introduced a L = ~D variable at all.
I can have both inverted and non-inverted outputs, so I though one of them might make the design simpler.
OK.
It is not normal to assign another letter to inverted outputs so it should be ~D and D. Assigning another letter tends to confuse.
So the simplest form is Output = P . D . M
Three input gates are available but sort of rare. At this point I would look in the bits box and see what I have available if I wanted to use logic gates but it is probably easier to implement it with discrete components as stated above.
So the simplest form is Output = P . D . M
The simplest output is D.(~P|M) which is "It's dark AND (there is no external power OR there is motion)"
It depends what you mean by "minimum".
You could do it using hand made RTL or DTL logic with a couple of transistors.
Or you could do it with a single 7400 chip
#include <stdio.h>
int nand(int a, int b){
return ~(a&b);
}
int main(){
for (int D=0; D<=1; ++D){
for (int P=0; P<=1; ++P){
for (int M=0; M<=1; ++M){
int orig = D & (~P | M);
int t1 = nand(D, nand(P, nand(M,M)));
int test = nand(t1,t1);
printf("%d %d %d: %d %d\n", D, P, M, orig&1, test&1);
}
}
}
return 0;
}
This single IC solution looks very elegant to me. Thank you!
You can do this on the cheap noting that D.(~P|M) = ~(L | (P . ~M)), from DeMorgan identities. Since you can have inverted outputs, that reduces to (L | (P . ~M)). This can be implemented with four diodes (see attachment below).
If there is light, the ouptut goes high. If there is no light, the output will go high if there is external power
and no movement. I think this is what you're looking for.
If you don't have ~M directly available, you can get it with one transistor. Total: four diodes and one transistor.
So the simplest form is Output = P . D . M
The simplest output is D.(~P|M) which is "It's dark AND (there is no external power OR there is motion)"
I am obviously not understanding what you want to do if my statement is incorrect.
You need output if you have no power and no motion?
I thought you wanted output = "i have power" and "I have motion" and " I have night"
You want: Output = (dark and no power) or (dark and motion)
Is that right?
Doesn't seem to make much sense to have a light which only comes on with motion if there is mains power but which stays on all the time if on battery.
I would have thought the reverse would be what's needed.
Doesn't seem to make much sense to have a light which only comes on with motion if there is mains power but which stays on all the time if on battery.
I would have thought the reverse would be what's needed.
It sort of can make sense if it is an alarm and you need to know if some scroat has cut the power to your detector. That is what I am assuming this is.
Doesn't seem to make much sense to have a light which only comes on with motion if there is mains power but which stays on all the time if on battery.
I would have thought the reverse would be what's needed.
It is common to have emergency lights powered by batteries that turn on in the event of power failure so that people can see to exit the building. For example, see:
http://www.exitlightco.com/category/Emergency-Lights.htmlThe application discussed here may have that as one of its requirements.
You want: Output = (dark and no power) or (dark and motion)
Exactly!
Doesn't seem to make much sense to have a light which only comes on with motion if there is mains power but which stays on all the time if on battery.
It stays on if it's on battery and it's dark.
It is common to have emergency lights powered by batteries that turn on in the event of power failure so that people can see to exit the building.
It is exactly an emergency / night light.
Ah, all becomes clear now.
Probably due to the light.