Author Topic: Least possible amount of hardware to implement this Boolean logic  (Read 2147 times)

0 Members and 1 Guest are viewing this topic.

Offline hamedTopic starter

  • Newbie
  • Posts: 5
  • Country: tr
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.
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #1 on: November 04, 2017, 11:55:47 am »
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.

 

Offline brucehoult

  • Super Contributor
  • ***
  • Posts: 4036
  • Country: nz
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #2 on: November 04, 2017, 12:02:36 pm »
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

Code: [Select]
#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;
}
 
The following users thanked this post: hamed

Offline hamedTopic starter

  • Newbie
  • Posts: 5
  • Country: tr
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #3 on: November 04, 2017, 12:06:16 pm »
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.
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #4 on: November 04, 2017, 12:16:17 pm »

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.

 

Offline hamedTopic starter

  • Newbie
  • Posts: 5
  • Country: tr
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #5 on: November 04, 2017, 12:20:43 pm »
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)"
 

Offline hamedTopic starter

  • Newbie
  • Posts: 5
  • Country: tr
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #6 on: November 04, 2017, 12:22:21 pm »
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

Code: [Select]
#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!
 

Offline orolo

  • Frequent Contributor
  • **
  • Posts: 352
  • Country: es
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #7 on: November 04, 2017, 12:45:26 pm »
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.
 
The following users thanked this post: hamed

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #8 on: November 04, 2017, 05:01:40 pm »
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?
 

Offline IanMacdonald

  • Frequent Contributor
  • **
  • Posts: 943
  • Country: gb
    • IWR Consultancy
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #9 on: November 04, 2017, 05:26:54 pm »
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.
« Last Edit: November 04, 2017, 05:35:50 pm by IanMacdonald »
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #10 on: November 04, 2017, 07:20:41 pm »
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.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #11 on: November 04, 2017, 11:50:58 pm »
Use tiny gate logic, its dirt cheap, and super small packages (why its dirt cheap).


https://www.fairchildsemi.com/collateral/TinyLogic.pdf


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: ebclr, hamed

Offline Tom45

  • Frequent Contributor
  • **
  • Posts: 556
  • Country: us
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #12 on: November 05, 2017, 12:47:25 am »
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.html

The application discussed here may have that as one of its requirements.
 
The following users thanked this post: hamed

Offline hamedTopic starter

  • Newbie
  • Posts: 5
  • Country: tr
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #13 on: November 06, 2017, 06:09:48 am »
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.
 

Offline Mjolinor

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: gb
Re: Least possible amount of hardware to implement this Boolean logic
« Reply #14 on: November 06, 2017, 10:31:57 am »

Ah, all becomes clear now.

Probably due to the light. :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf