ENGG1100 Introduction to Engineering Design Digital Logic (Part 1) Prof. Kin Hong Wong Department of Computer Science and Engineering.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 6 Digital Inputs
Advertisements

ENGG1100 Ch6: Introduction To Engineering Design (Digital Logic) Part 2 of digital logic KH WONG ENGG1100. Ch6-Digital Logic (part2) v3h1.
Prof. Sin-Min Lee Department of Computer Science
Lab7: Introduction to Arduino
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
Lecture 2: Systems Engineering
Indian Institute of Technology Hyderabad ROBOTICS LINE FOLLOWER HARI KISHAN TANDEY – ES12B1008 DILIP KONDAPARTHI – ES12B1010 SAI KARTIK – CE12B1015.
Information Processing & Digital Systems COE 202 Digital Logic Design Dr. Aiman El-Maleh College of Computer Sciences and Engineering King Fahd University.
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
ELECTRICAL. Circuits Outline Power Hub Microcontroller Sensor Inputs Motor Driver.
Dr. Andreas Kunz © 10/2004 inspire icvr BASICS OF ELECTRONICS.
1 Homework Reading –Tokheim, Section 5-10, 7-4 Machine Projects –Continue on MP4 Labs –Continue labs with your assigned section.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
EECC341 - Shaaban #1 Lec # 1 Winter Introduction to Digital Systems Analog devices and systems process time-varying signals that can take.
Laboratory 5: Introduction to LabVIEW. Overview Objectives Background Materials Procedure Report / Presentation Closing.
Faculty of Computer Science © 2006 CMPUT 229 Digital Logic From Switches to Memories.
Arduino Week 3 Lab ECE 1020 Prof. Ahmadi. Objective Data acquisition (DAQ) is the process of measuring an electrical or physical phenomenon such as voltage,
Arduino. Arduino is a tool for making computers that can sense and control more of the physical world than your desktop computer. It's an open-source.
Electrical Engineering 1 WISE Investments Electrical Engineering Lab Digital Logic Laboratory Dr. Keith Holbert.
CS 300 – Lecture 3 Intro to Computer Architecture / Assembly Language Digital Design.
Introduction.
ASPPRATECH.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
3. DIGITAL ELECTRONICS..
ENGG1100 Lecture 6: Introduction To Engineering Design (Digital Logic) Part 1 Kin Hong Wong ENGG1100. Ch6-Digital Logic (Part1) 25/2/14 1.
ENGG1100 Lecture7: Introduction To Engineering Design (Digital Logic) Part 2 Kin Hong Wong ENGG1100. Ch7-Digital Logic (part 2) 16/02/15 1.
ENGG1100 Introduction to Engineering Design Digital Logic (Part 2) Prof. Kin Hong Wong Department of Computer Science and Engineering.
ENGG1100 Ch6: Introduction To Engineering Design (Digital Logic) Part 1 KH WONG ENGG1100. Ch6-Digital Logic (v3e2.v5)1.
CS231 Fundamentals1 Fundamentals What kind of data do computers work with? – Deep down inside, it’s all 1s and 0s What can you do with 1s and 0s? – Boolean.
Chapter 2 Combinational Systems And / Or / Not. TRIAD PRINCIPLE: Combinational is about And / Or / Not combinations As well as equivalent functions. It.
Digital Logic Chapter 4 Presented by Prof Tim Johnson
COMPUTER SYSTEM ARCHITECTURE By Sohaib.  The digital computer is a digital system that performs various computational tasks.  The word digital implies.
Introduction to Computers and Programming – Computer Programming.
CS1Q Computer Systems Lecture 8
Module 1: Introduction to PLC
ERGM 1413 Programming and Playing with Intelligent Robots Prof. K.H. Wong Robot building v4.7b1.
Software Tutorial 26 Sept Agenda Development Environment Brain Board API Sensors Basic Behaviour Control.
LOGIC GATES A logic gate is an elementary building block of a digital circuit.digital circuit Most logic gates have two inputs and one output terminals.
ENGG1100 Ch5: Introduction To Engineering Design (Digital Logic) Part 1 of digital logic KH WONG ENGG1100. Ch5-Digital Logic (v3e2)1.
What is Mechatronics? Mechatronics is the synergistic combination of mechanical engineering, electronics, controls engineering, and computers, all integrated.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
Boolean Algebra and Logic Gates CSE-1108 Ahsanullah University of Science and Technology (AUST)
CS151 Introduction to Digital Design Chapter 2: Combinational Logic Circuits Lecture 5: Binary Logic and Gates.
The George Washington University Department of ECE ECE Intro: Electrical & Computer Engineering Dr. S. Ahmadi Class 4/Lab3.
The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class3/Lab 2.
ECEN 248 Lab 2: Logic Minimization and Karnaugh Maps
Boolean Functions and Boolean Algebra Laxmikant Kale.
CS1Q Computer Systems Lecture 8
Logic Design EE-2121 Manesh T. Digital Systems  Introduction  Binary Quantities and Variables  Logic Gates  Boolean Algebra  Combinational Logic.
Compiled by : Mr. Mark Anthony P. Cezar ( Lecture )
Laboratory 5: Introduction to LabVIEW
Introduction to LabVIEW
Lecture Notes / PPT UNIT III
Invitation to Computer Science, C++ Version, Fourth Edition
Basics of Logic gates - Part 2
Logic Gates Binary Day 3 PEOPLE 2016.
Digital-to-Analog Analog-to-Digital
Module 1: Introduction to PLC
Computer Science 210 Computer Organization
Prof. Sin-Min Lee Department of Computer Science
Arduino - Introduction
Fundamentals & Ethics of Information Systems IS 201
Module F: Presentation Understanding Robot Fundamentals
Thursday, 22 November 2018 Logic Gates
Digital Electronics Lab 2 Instructor:
Computer Science 210 Computer Organization
Functions Computers take inputs and produce outputs, just like functions in math! Mathematical functions can be expressed in two ways: We can represent.
Basic circuit analysis and design
Introduction to Arduinos
Presentation transcript:

ENGG1100 Introduction to Engineering Design Digital Logic (Part 1) Prof. Kin Hong Wong Department of Computer Science and Engineering

ENGG1100 | Term 2 | Overview Part 1: Introduction 1.1 What is Digital logic? 1.2 Digital operations (AND, OR, NOT) 1.3 Truth table 1.4 Robot Hardware 1.5 Software implementation of digital operations Part 2 (next week): Hardware/software Implementation 2.1 Robot system 2.1 Use of If-then-else (software method 1) 2.2 Use of switch case (software method 2) 2.3 Finite state machines 2V Introduction

ENGG1100 | Term 2 | Motivations and plans The brain of our robot is a set of digital logic functions We will introduce three techniques in digital logic design – Logic formula – Truth table – Finite state machine We will use a program in a micro-controller system to implement these techniques V Introduction3

ENGG1100 | Term 2 | Example How to keep the robot to move forward? Method: – If the robot deviates to the left, turn right – If the robot deviates to the right, turn left The above rules are logic functions and operations. V Introduction4 Magnetic sensors S1 S2 Terminal Magnetic strip following robot (2013-4) Light following robot (2014-5)

1.1 What is digital logic? Understanding the difference between Digital and Analog operations V Introduction5

ENGG1100 | Term 2 | Analog and digital signals Analog signals: the signal can be any values within the valid range – Example: Range =0  10 Volts – E.g. The signal can be Volts or Volts Digital signals: It can only be HIGH (or called ‘1’ )or LOW (or called ‘0’). Examples: – In TTL Transistor-transistor-logic standard: High=‘1’  5 volts, Low=‘0’  0 Volt Usually several bits (more than one digital bit) are used to represent a number corresponding to an analog value E.g. 8-bit to represent a value from 0 to =255, or 32-bit to represent a value from 0 to V Introduction6 Voltage Time (ms) Voltage Time (ms) 5 V 0 V 10 V 0 V 1 1 Analog value One Digital Bit

ENGG1100 | Term 2 | What is the meaning of digital logic? A signal is represented by ‘1’ or ‘0’ – Advantages: Easy to be implemented in a circuit. Less likely to be interfered by noise, temperature and radiation. Application, digital music V Introduction7 Analog to Digital conversion (ADC) Digital data saved in CDs Digital to Analog conversion (DAC)

1.2 Digital Operations AND, OR, NOT V Introduction8

ENGG1100 | Term 2 | Digital Operations Study how to combine inputs to generate outputs – In arithmetic operations: 2 Add 3= 5, result is 5 – In digital operations: we need a truth table to see the result 3 popular digital operations you will learn here – AND – OR – NOT (Negation) V Introduction9 Digital operation Digital Input1 Digital Input2 Digital Output

ENGG1100 | Term 2 | Exercises Multiple choice questions 1)Are these values digital or analog? Temperature : Ans: _________? Humidity : Ans: _________? 2)Are you a Chinese Univ. student, the answer is : Ans_____? Is the above answer Analog or digital? : Ans:_________? 3)Do you have a mobile phone in your pocket, the answer is : Ans:______? Is the above answer Analog or digital? Ans: ________? 4)What is the temperature in this room, the answer is Ans:___? Is the above answer Analog or digital? Ans: ________? V Introduction10 Answers:1) Analog, analog2) Yes, digital 3) Yes, digital4) 20 Degrees, analog

ENGG1100 | Term 2 | AND operation, example in real life You get a Degree from CUHK if you take 123 units and your GPA is greater than 1.5 – You may write a formula (X=take 123 units) AND (Y=GPA>1.5) then you can get a Degree from CUHK (W) You must eat and drink in order to live – You may write a formula (X=eat ) AND (Y=drink) then you can live (W) V Introduction11 XYXY W=X AND Y Notation

ENGG1100 | Term 2 | OR operation, example in real life If you live in Mongkok, you either take a bus or train to come to the Chinese University – You may write a formula (X=take bus) or (Y=take train) then you can come to the University (W) You can ride on a bus if you pay cash or pay using octopus – You may write a formula (X=pay by cash) or (Y=pay by octopus) then you can ride on the bus (W) V Introduction12 XYXY W=X OR Y Notation

ENGG1100 | Term 2 | NOT operation, example in real life I don’t love you = Not (I love you) – You may write a formula NOT (X=I love you) means I don’t love you (W) You are not rich = NOT (you are rich) – You may write a formula NOT(X=you are rich) that means you are poor (W) V Introduction13 X W=NOT X Notation

ENGG1100 | Term 2 | Exercise for robot control to follow the magnetic path Sensors: S2 S1 If S2 detects the magnetic strip, but not S1, has the robot deviated to the right or left of the path? Answer (right or left) : ______? V Introduction14 Answer: left Magnetic sensors S1 S2 Terminal S2 S1

1.3 Truth table A method to represent logic functions for digital signals V Introduction15

ENGG1100 | Term 2 | Truth table The idea is to have all different combinations of inputs arranged in a table Each combination gives one output For n digital inputs, there will be 2 n different combinations The truth table has 2 n rows Example: – n=2 (X and Y as inputs), so there are 2 n =4 rows – You can see that no two rows have the same combination of inputs – All possible combinations of the inputs (X,Y) are found in the truth table Example V Introduction16 Input: X Input: Y W= Output for the operation 00? 01? 10? 11? ? = depends on the operation

ENGG1100 | Term 2 | Truth table example for “AND” operation X, Y are 2 digital input signals We can use a “Truth table” to find the output Because there are n=2 inputs: X,Y So there are 2 n =4 rows in the truth table Steps to fill in the table – Fill in Y: 0,1,0,1 (from top) – Fill in X: 0,0,1,1 – Fill in the outputs – Compute output: – Output=1 only when both inputs are 1 V Introduction17 Input : X=eat Input: Y=drink Output W= X AND Y =live XYXY W= X AND Y

ENGG1100 | Term 2 | Truth table example for “OR” operation X, Y are 2 digital input signals We can use a “Truth table” to find the output Because there are n=2 inputs: X,Y So there are 2 n =4 rows in the truth table Steps: – Fill in Y: 0,1,0,1(from top) – Fill in X: 0,0,1,1 – Fill in the outputs – Compute output: – Output=1 only when either input is 1 V Introduction18 Input: X(pay by cash) Input: Y (pay by Octopus) Output W= X OR Y= (ride on a bus) XYXY W= X OR Y

ENGG1100 | Term 2 | NOT (or called negation) X is a digital input signal We can use a “Truth table” to find the output Because there are n=1 input: X So there are 2 n =2 rows in the truth table Step: Fill in X: 0,1 Fill in the outputs Compute output: Output=Reverse the input V Introduction19 X= you are rich NOT X (you are not rich) X W= NOT X

ENGG1100 | Term 2 | Exercises How many rows are required in the truth table for 3 inputs? Give examples of AND OR NOT V Introduction20 Answer: 2 3 =8 rows

ENGG1100 | Term 2 | Combinational logic (Combine NOT, AND, OR) X, Y, Z are 3 digital input signals We can use a “Truth table” to find the output Because there are n=3 inputs: X,Y,Z So there are 2 n =8 rows in the truth table Fill in Z: 0,1,0,1,0,1,0,1 Fill in Y: 0,0,1,1,0,0,1,1 Fill in X: 0,0,0,0,1,1,1,1 V Introduction21

ENGG1100 | Term 2 | Truth table We want to find : W=X OR (NOT (Y) AND Z) Step 1: fill in different combinations of inputs 2 inputs, so 2 3 =8 rows V Introduction22 XYZW=X OR (NOT ( Y) AND Z) 000? 001? 010? 011? W

ENGG1100 | Term 2 | We can solve it step by step Step2 V Introduction23 W XYZNOT(Y) Produce NOT (Y) from Y first. X,Z are not used in this step. input output

ENGG1100 | Term 2 | We can solve it step by step Step 3 V Introduction24 W XYZNOT(Y)Z AND (NOT(Y)) input output input Then, produce [Z AND (NOT (Y))]. X, Y are not used directly in this step.

ENGG1100 | Term 2 | We can solve it step by step Step 4 V Introduction25 XYZNOT(Y)Z AND (NOT(Y)W=X OR (Z AND (NOT(Y))) input output W=X OR (Z AND (NOT(Y)))

ENGG1100 | Term 2 | Exercise 1.1 Use a truth table to find the output of NOT( X AND Y ) OR Z V Introduction26

ENGG1100 | Term 2 | Exercise1.1: NOT( X AND Y ) OR Z Fill the blanks in X,Y, Z columns V Introduction27 XYZX AND YNOT (X AND Y)W=(NOT (Z AND Y)) OR Z

ENGG1100 | Term 2 | Exercise1.1: NOT( X AND Y ) OR Z Fill the blanks The answer is in the appendix V Introduction28 XYZX AND YNOT (X AND Y)W=(NOT (Z AND Y)) OR Z

Robot Hardware V Introduction29

ENGG1100 | Term 2 | Robot Hardware Controlled by an Arduino computer Write programs and download to run The robot will be put in a sphere, it has LED display Board 7-segment display Light seeking sensors Magnetic sensor for power on/off V Introduction30

ENGG1100 | Term 2 | V Introduction31 The Intelligent Robot system Arduino board (programs to be run in the Arduino computer): : void Loop { If …. then…. else…. } Inputs Outputs Motor drivers Magnetic on/off sensor Programmer to update the program Bluetooth H-bridge motors Light sensors S1 S2 S3 S4 S5 S6 Light source

ENGG1100 | Term 2 | Light following design You need to design the robot to follow a light source Your work: Program the motor actions responding to which light sensor receives the strongest light energy You learn magnetic strip following method here then find out how to do light following yourself V Introduction32 Light sensors (Si) S1 S2 S3 S4 S5 S6 Light sensors

1.5 Software Implementation V Introduction33

ENGG1100 | Term 2 | Software Implementation Document about the use of Arduino E-learning Edit program Compile Download to the Arduino board of the robot Run the program V Introduction34

ENGG1100 | Term 2 | How to use “If-then-else” IF (condition) then output is result 1, else output is result 2 //Example1: //just to illustrate the idea, not a runnable program If (“you_eat” and “you_drink”) you _can_live; Else “you_die”; //Example2: // && means “AND” if(Din1() && Din3()) Out1(1); // same as if(Din1()==1 && Din3()==1) Out1(1); else Out1(0); The above program means: if Din1 is 1 AND Din3 is 1, then Out1 is 1. Else Out1 is 0 //Example3: // || means “OR” If (Din1() || Din3()) Out3(1); // same as if(Din1()==1 || Din3()==1) Out1(1); Else Out3(0)); The above program means: if Din1 is 1 OR Din3 is 1, then Out3 is 1. Else Out3 is 0 V Introduction35

ENGG1100 | Term 2 | You will learn this in Lab6. You are given: An Arduino computer with the debug board In here, inputs are represented as In1=A, In3=B and output Out1=Q. //program segment in the main loop of Lab6.ino void loop() { // Experiment 1.3 Out1=In1 AND In3 //that means if In1 and In3 are ‘1’, Out1 is ‘1’. Otherwise Out1 is ‘0’ if(Din1() && Din3()) Out1(1 ); //&& means logic function AND else Out1(0); : } V Introduction36 In1 In3 Out1

ENGG1100 | Term 2 | A more complex function You will test it in Lab 6. //Program segment in the main loop of Lab6.ino void loop() { : // Experiment 2.1 Out2=(NOT(In2) AND In3) AND In4 if((!(Din2()) && Din3()) && Din4()) Out2(1); else Out2(0); : } V Introduction37

ENGG1100 | Term 2 | Summary Learned Digital logic The use of the truth table Our robot system design To implement logic functions using if-then-else V Introduction38

END V Introduction

ENGG1100 | Term 2 | Appendix 1 ANSWER1.1: W=(NOT( X AND Y )) OR Z Fill the blanks V Introduction40 XYZX AND YNOT (X AND Y)W=(NOT (X AND Y)) OR Z