ECOR 1032: Mech Lecture 4 Mechatronics Combinatorial Logic

Combinational Circuits

ECOR 1032

Circuits and Mechatronics

From Sensors to Actions: Our Goal

  • Core Problem: Making Decisions

    • Objective: Build the "brain" that connects inputs (like sensors) to outputs (like alarms, motors, or lights).

    • Requirement: A formal way to define the rules for making decisions.

What You Will Be Able To Do
  • Translate a real-world problem into a logical statement and a truth table.

    • Example: "the cart is unsafe".

  • Implement logic using two different methods:

    • Method 1 (Hardware): Design a physical circuit by wiring logic gates together.

    • Method 2 (Software): Write a Python if statement that produces the identical result.

  • Analyze pros and cons of a hardwired circuit versus a software-based solution for a mechatronic system.

Scenario Analysis

Scenario 1: Conservation Vault After Hours
  • Context: A small museum with light-sensitive artifacts stored in a climate-controlled vault.

  • Problem: Alarm requirement stemming from a situation where the door was propped open while lights were on, leading to artifact damage.

  • Condition for Alarm: Triggers only if the door is open while the vault lights are on.

    • Avoid false alarms from closed doors and power glitches.

  • Task: Capture this exact condition reliably.

Scenario 2: Remote Pump Station Safeguard
  • Context: A borehole pump that feeds a reservoir with varying conditions.

  • Problem: Prevent uncontrolled motor running leading to machine failure due to overheating.

  • Requirements: Hardwired shutdown that trips only when:

    • The motor is running.

    • Either temperature is high or line pressure is low.

  • Goal: Prevent dry-run burnout without nuisance trips during maintenance.

Scenario 3: Lab Cart Interlock
  • Context: An electric utility cart that caused injury when rolled down a ramp due to mishandling.

  • Desired Logic: Interlock system that:

    • Allows starting only when:

    • The authorized key is inserted.

    • The brake is engaged.

    • A seated operator is present.

  • Importance: The cart must remain inert if any conditions are not met.

Review of Logic Gates

  • Gates and Their Truth Tables:

    • Basic types to recall: NOT, AND, OR, NAND, NOR, XOR, XNOR

    • Symbols and meanings previously established carry over.

Combinational Logic

  • Definition: Outputs depend only on current inputs with no memory or feedback.

    • Contrast: Sequential logic uses state and timing (i.e., has memory).

Common Two-Input Logic Notations
  • Gate Types and their Representations:

    • AND:

    • Canonical: A · B

    • Boolean: AB

    • C-style: A & B

    • HDL-style: A & B

    • Python: A and B

    • Textbook Alt.: A ∧ B

    • OR:

    • Canonical: A + B

    • Boolean: A + B

    • C-style: A | B

    • HDL-style: A | B

    • Python: A or B

    • Textbook Alt.: A ∨ B

    • NOT:

    • Canonical: A

    • Boolean: A′

    • C-style: !A

    • HDL-style: !A

    • Python: not A

    • Textbook Alt.: ¬A

    • Other gates (NAND, NOR, XOR, XNOR) follow similar notation patterns.

Scenario Logic Examples

Scenario 1: Door and Light to Alarm Problem


  • Inputs: DoorOpen (D), LightOn (L).


  • Output: Alarm (A).


  • Logic Equation:
    A = D · L


  • Truth Table:

    D

    L

    A


    0

    0

    0


    0

    1

    0


    1

    0

    0


    1

    1

    1

    • Plain Language Solution: Sound the alarm only when the door is open and the light is on.

    Scenario 2: Machine Shutdown Condition


    • Inputs: MotorRunning (M), TemperatureHigh (T), PressureLow (P).


    • Output: Shutdown (S).


    • Logic Equation:
      S = M · (T + P)


    • Truth Table:

      M

      T

      P

      S


      0

      0

      0

      0


      0

      0

      1

      0


      0

      1

      0

      0


      0

      1

      1

      0


      1

      0

      0

      0


      1

      0

      1

      1


      1

      1

      0

      1


      1

      1

      1

      1

      • Plain Language Solution: Trigger shutdown when the motor is running and either temperature is high or pressure is low.

      Scenario 3: Start Enable Interlock


      • Inputs: KeyInserted (K), BrakeEngaged (B), SeatOccupied (S).


      • Output: StartEnable (Y).


      • Logic Equation:
        Y = K · B · S


      • Truth Table:

        K

        B

        S

        Y


        0

        0

        0

        0


        0

        0

        1

        0


        0

        1

        0

        0


        0

        1

        1

        0


        1

        0

        0

        0


        1

        0

        1

        0


        1

        1

        0

        1


        1

        1

        1

        1

        • Plain Language Solution: Enable start only when the key is inserted, the brake is engaged, and the seat is occupied.

        Logic Circuit Design

        Reading a Logic Diagram
        • Example: Understanding how to follow signal flow left to right and evaluate output from given inputs.

        Logic Circuit for Y = NOT((A AND B) OR C)
        • Hierarchy:

          • Level 1: A · B

          • Level 2: O1 + C

          • Level 3: NOT(O2)

        Boolean from a Diagram
        • Translate previous diagram into Boolean algebra.

        • Stepwise Solution:

          • Intermediate outputs:

          O1 = A · B
          O2 = O1 + C = (A · B) + C
          Y = O2 = (A · B) + C

        Truth Table


        • For the function
          Y = (A · B) + C


        • Inputs and Outputs:

          A

          B

          C

          O1 = A · B

          O2 = O1 + C

          Y = O2


          0

          0

          0

          0

          0

          0


          0

          0

          1

          0

          1

          1


          0

          1

          0

          0

          0

          0


          0

          1

          1

          0

          1

          1


          1

          0

          0

          0

          0

          0


          1

          0

          1

          0

          1

          1


          1

          1

          0

          1

          1

          1


          1

          1

          1

          1

          1

          1

          Three-Level Logic Circuit Example

          • Diagram Purpose:

            • Understand structure of a three-level combinational logic circuit.

          • Hierarchy of Outputs:

            • Outputs identified as O1, O2, and O3 using basic logic gates described earlier.

          Boolean From a Diagram
          • Translation into Boolean Algebra:

            • Identify outputs:

            • O1 = A ⊕ B

            • O2 = C · D

            • O3 = O1 + O2 = (A ⊕ B) + CD

            • Final output:
              Y = O3 ⊕ E = ((A ⊕ B) + CD) ⊕ E

          From Boolean Algebra to Schematic

          Working Backward from an Equation
          • Steps to Draw a Logic Circuit:

            • Step 1: Identify the Final Gate (Output).

            • Example: In
              Y = (A · B) + C , final operation is the NOT.

            • Step 2: Identify Its Inputs.

            • Example: Inputs to the NOT gate feed from sub-expressions.

            • Step 3: Repeat for Each Sub-Expression, analyzing until reaching primary inputs.

            • Step 4: Connect Inputs to Form Complete Diagram.

          Diagram from a Boolean Expression

          • Target Expression: Y = A(B + C′)

            • Equivalent Expression:
              Y = A · (B + C)

          Building the Schematic: Work Backward
          • Process to Develop Circuit:

            • Analyze each logical operation in order of precedence to construct levels of circuits.

          From Truth Table to Equation

          Goal & Method: Sum of Products (SOP)
          • Method Steps:

            1. Identify Minterms: Find rows where Y = 1.

            2. Write Product Terms: Minterm for rows with output 1.

            3. Sum the Terms: Combine individual minterms using OR operation.

          SOP Example


          • Truth Table:

            A

            B

            C

            Y


            0

            0

            0

            0


            0

            0

            1

            0


            0

            1

            0

            0


            0

            1

            1

            1


            1

            0

            0

            0


            1

            0

            1

            1


            1

            1

            0

            1


            1

            1

            1

            1

            1. Identify Minterms from this example for all rows where output Y=1.

            2. Sum these Minterms into canonical form: Y = (ABC) + (ABC) + (ABC)

              • Note on simplification of this expression using Boolean algebra.

            Truth Table for Original Function


            • Function:
              Y_{ ext{orig}} = (A · B) + C


            • Comparison of outputs:

              A

              B

              C

              Y_orig


              0

              0

              0

              1


              0

              1

              0

              0


              1

              0

              1

              0


              1

              1

              0

              1

              SOP Derivation vs. Original Expression

              • Both derived expressions are logically equivalent:

                • Original:
                  Y_{ ext{orig}} = (A · B) + C

                • Derived SOP:
                  Y_{ ext{SOP}} = ABC + ABC + ABC .

              • Conclusion: Both produce the same truth table but are structurally different.

              Implementing Sum of Products: From Equation to Schematic

              1. Derived the equation yielding
                Y_{ ext{SOP}} = (A · B · C) + (A · B · C) + (A · B · C) .

              2. Understand that this leads to a standard two-level circuit formed by AND gates feeding into a single OR gate.

              Same Logic, Different Complexity
              • Various circuits yielding the same output for every possible input, demonstrating logical equivalence.

              • Analyzing complexity:

                • Original Design = 3 simple gates.

                • Derived from Truth Table requires 4 complex gates and additional NOTs.

              Practical Application: Lab Cart Safety Buzzer

              • Problem Statement: Need to add a buzzer to indicate unsafe operation.

              • Inputs:

                • K (Key Inserted): 1 = YES, 0 = NO

                • B (Brake Engaged): 1 = ON, 0 = OFF

                • S (Seat Occupied): 1 = YES, 0 = NO

              • Desired Action Output (Z): Buzzer = 1 for SOUND, 0 for SILENT.

              Step 1 & 2: Truth Table and Equation
              • Translate the logic for conditions to an algebraic expression: Z = K · (B + S)

                • Truth Table Verification:
                  | K | B | S | Z = K · (B + S) |
                  |---|---|---|------------------|
                  | 0 | 0 | 0 | 0 |
                  | 0 | 0 | 1 | 0 |
                  | 0 | 1 | 0 | 0 |
                  | … |

              Solution 1: Dedicated Hardware Circuit
              • Circuit Construction: Logic circuit physically made from standard gates with reliability and speed benefits illustrated.

              Solution 2: Software Implementation
              • Illustrate the exact same working logic implemented in a microcontroller (e.g., Arduino, Raspberry Pi).

              • Python Pseudocode:

              # Read Sensors (Inputs)  
              k_in = GPIO.input(PIN_KEY)  
              b_in = GPIO.input(PIN_BRAKE)  
              s_in = GPIO.input(PIN_SEAT)  
              
              # THE LOGIC  
              if k_in and (not b_in or not s_in):  
              # Set Output HIGH (Buzzer ON)  
              GPIO.output(PIN_BUZZER,  True)  
              else:  
              # Set Output LOW (Buzzer OFF)  
              GPIO.output(PIN_BUZZER,  False)  
              
              • Context of microcontroller functioning and GPIO usage detailed.

              Conclusion: Two Ways to Make Decisions
              • Combinational Logic Compared to Software:

                • Hardware (Gates):

                • Logic defined by wiring. Speed: Nanoseconds.

                • Reliability: Extremely high; not affected by OS failures.

                • Flexibility: Low; rewiring needed to change logic.

                • Ideal Usage: Safety-critical applications requiring quick response.

                • Software (Code):

                • Logic defined by programming instructions. Speed: Milliseconds.

                • Reliability: Good; depends on code quality.

                • Flexibility: High; modify code to change behavior easily.

                • Ideal Usage: Complex and evolving tasks involving networks.