Connect with us

Help for switching operation

Discussion in 'Microcontrollers, Programming and IoT' started by chiragpatelbh, Nov 21, 2013.

Scroll to continue with content
  1. chiragpatelbh


    Nov 21, 2013
    Can any body help me with my switching operation requirement,

    I am looking for solution for,

    If i change any of inputs states should result in change of output state,

    means for example, If Inputs A=0, B=1 and output C=1, then if i change A=1 or B=0 should change output C=0
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    Nov 17, 2011
    What you describe is easily realized by a wire connecting C to B.

    I doubt that is what you want to achieve. You need to state the full truth table, i.e. all combinaions af A,B and resulting C. From that table you can use any method to arrive at the logical equations needed. You can for example use a Karnaugh map to represent the truth table and find a boolean expression that fulfills the function as required.
  3. BobK


    Jan 5, 2010
    Actually the way I read it, what the OP describes is ~A & B.

    This easily done with logic gates.

  4. Harald Kapp

    Harald Kapp Moderator Moderator

    Nov 17, 2011
    your equation is correct. But: since he doesn't tell us his other combinations, a simple wire is the cheapest solution to the two conditions stated, requiring no gate at all.
  5. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    Nov 28, 2011
    If you're looking for an arrangement where any of several switches can change the output state, you can use cascaded exclusive-OR gates or a "parity detection" circuit.

    The general idea is that given a number of inputs, the circuit counts how many inputs are active, determines whether that number is even or odd, and generates an output accordingly. So changing any one input will change the output.

    If the number of active inputs is even, changing the state of any input will change the number of active inputs to an odd number, and vice versa, and this will make the output change state.

    One way to implement this is using cascaded "exclusive OR" gates. An exclusive OR gate has two inputs (A and B) and one output (Q). The truth table ("0" corresponds to OFF, and "1" corresponds to ON) is:

    A B   Q
    0 0   0
    0 1   1
    1 0   1
    1 1   0
    Another way to look at the truth table is that it implements a "selectable inverter/buffer". When input A is 0, the output follows input B, but when input A is 1, the output follows the inverse (opposite) of input B. So input A determines whether the output is a copy of input B, or the opposite of it.

    These gates can be cascaded by feeding the output of one gate into one input of the next gate, and using the other inputs of the gates as the inputs to the circuit. The output is taken from the output of the last gate. The other input of the first gate can be used as an extra input to the circuit, or just tied to 1 or 0.

    There are also ICs with multiple inputs that do the calculation internally; these are called parity generators or parity checkers.

    If you have lots of inputs, you can use a 74HC280 IC. It calculates an even/odd parity on nine inputs. They can be cascaded if you have more than nine inputs. It is a member of the 74HC family and it requires a 5V DC power supply.

    If you have five inputs or less, you can use the cascaded exclusive OR gate method, using a 74HC86 from the 74HC family, or a CD4070B from the CMOS CD4000 series which uses a 3~15V power supply.

    CDRIVE Hauling 10' pipe on a Trek Shift3

    May 8, 2012
    I'm reading this question very differently than my friends that have replied thus far. Isn't this a simple code question? If it is you need to tell us what uC you're using and what language you're coding in.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day