Least possible amount of hardware to implement this Boolean logic - Page 1
Forum section: electronics / beginners

author: hamed
author_rank: Newbie
timestamp: November 04, 2017, 11:31:29 am
content: 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.

author: Mjolinor
author_rank: Frequent Contributor
timestamp: November 04, 2017, 11:55:47 am
content: 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 . MI don't know why you introduced a L = ~D variable at all.

author: brucehoult
author_rank: Super Contributor
timestamp: November 04, 2017, 12:02:36 pm
content: 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 chipCode:#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;}

author: hamed
author_rank: Newbie
timestamp: November 04, 2017, 12:06:16 pm
content: Quote from: Mjolinor on November 04, 2017, 11:55:47 amThere 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.Quote from: Mjolinor on November 04, 2017, 11:55:47 amI can have both inverted and non-inverted outputs, so I though one of them might make the design simpler.

author: Mjolinor
author_rank: Frequent Contributor
timestamp: November 04, 2017, 12:16:17 pm
content: 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 . MThree 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.

author: hamed
author_rank: Newbie
timestamp: November 04, 2017, 12:20:43 pm
content: Quote from: Mjolinor on November 04, 2017, 12:16:17 pmThe simplest output is D.(~P|M) which is "It's dark AND (there is no external power OR there is motion)"

author: hamed
author_rank: Newbie
timestamp: November 04, 2017, 12:22:21 pm
content: Quote from: brucehoult on November 04, 2017, 12:02:36 pmThis single IC solution looks very elegant to me. Thank you!

author: orolo
author_rank: Frequent Contributor
timestamp: November 04, 2017, 12:45:26 pm
content: 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 powerandno 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.

author: Mjolinor
author_rank: Frequent Contributor
timestamp: November 04, 2017, 05:01:40 pm
content: Quote from: hamed on November 04, 2017, 12:20:43 pmI 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?

author: IanMacdonald
author_rank: Frequent Contributor
timestamp: November 04, 2017, 05:26:54 pm
content: 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.

author: Mjolinor
author_rank: Frequent Contributor
timestamp: November 04, 2017, 07:20:41 pm
content: Quote from: IanMacdonald on November 04, 2017, 05:26:54 pmIt 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.

author: danadak
author_rank: Super Contributor
timestamp: November 04, 2017, 11:50:58 pm
content: Use tiny gate logic, its dirt cheap, and super small packages (why its dirt cheap).https://www.fairchildsemi.com/collateral/TinyLogic.pdfRegards, Dana.

author: Tom45
author_rank: Frequent Contributor
timestamp: November 05, 2017, 12:47:25 am
content: Quote from: IanMacdonald on November 04, 2017, 05:26:54 pmIt 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.

author: hamed
author_rank: Newbie
timestamp: November 06, 2017, 06:09:48 am
content: Quote from: Mjolinor on November 04, 2017, 05:01:40 pmExactly!Quote from: IanMacdonald on November 04, 2017, 05:26:54 pmIt stays on if it's on battery and it's dark.Quote from: Tom45 on November 05, 2017, 12:47:25 amIt is exactly an emergency / night light.

author: Mjolinor
author_rank: Frequent Contributor
timestamp: November 06, 2017, 10:31:57 am
content: Ah, all becomes clear now.Probably due to the light.