Digital Logic (Part 1) Prof Kin Hong Wong Department of computer Science and Engineering 香港中文大學 ENGG1100 Introduction to Engineering Design The Chinese University of Hong Kong
ENGG1100 Introduction to Engineering Design Digital Logic (Part 1) Prof. Kin Hong Wong Department of Computer Science and Engineering
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong 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 V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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 V15.02.09 Introduction 2
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong 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 V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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 V15.02.09 Introduction 3
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong Exampl e Termina Magnetic sensors How to keep the robot S1 to move forward? Method If the robot deviates to the left, turn right If the robot deviates to Magnetic the right, turn left strip following robot (2013-4) · The above ru| es are logic functions and operations ight following robot (20145) V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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. V15.02.09 Introduction 4 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 V15.02.09 Introduction 5
1.1 What is digital logic? Understanding the difference between Digital and Analog operations V15.02.09 Introduction 5
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong Analog and digital signals Analog signals: the signal can be any values within the valid range Voltage Example: Range =0>10 Volts 10M E.g. The signal can be 1 356 Volts or2.432∨o|ts Analog value Digital signals: It can only be HGH( or called‘1’) or loW(or called 0). Examples In TTL Transistor-transistor -logic OV standard High=1≈5vots,LoW=0≈0vot Time(ms Usually several bits(more than one Voltage digital bit)are used to represent a One digital Bit number corresponding to an 5V analog value E.g. 8-bit to represent a value from 0 to 28-1=255, or 32-bit to OV represent a value from o to 23-1 Time(ms V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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 1.356 Volts or 2.432 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 28 -1 =255, or 32-bit to represent a value from 0 to 2 32 -1 V15.02.09 Introduction 6 Voltage Time (ms) Voltage Time (ms) 5 V 0 V 10 V 0 V 1 1 Analog value One Digital Bit
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong 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 Digital data saved in CDs Analog to Digital conversion( adC) 具 Digital to Analog conversion(DAC) V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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 V15.02.09 Introduction 7 Analog to Digital conversion (ADC) Digital data saved in CDs Digital to Analog conversion (DAC)
1.2 Digital Operations AND, OR NOT V15.02.09 Introduction 8
1.2 Digital Operations AND, OR, NOT V15.02.09 Introduction 8
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong 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 Digita NOT(Negation) Input1 Digit Digital operation Digital Output Input2 V15.02.09 Introduction
ENGG1100 | Term 2 | 2014-15 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) V15.02.09 Introduction 9 Digital operation Digital Input1 Digital Input2 Digital Output
ENGG1100|Term2|201415 题香港中文大學 The Chinese University of Hong Kong Exercises Multiple choice questions 1 Are these values digital or analog? emperature: Ans: Humidity: Ans 2) Are you a Chinese Univ. student, the answer is: ans ? ls the above answer analog or digital?: Ans 3)Do you have a mobile phone in your pocket, he answer is: ans Is the above answer analog or digital? Ans 4)What is the temperature in this room the e answer is ans Is the above answer analog or digital? Ans ? Answers 1)Analog, analog 2)Yes, digital 3) Yes, digital 4)20 Degrees, analog V15.02.09 Introduction 10
ENGG1100 | Term 2 | 2014-15 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: ________? V15.02.09 Introduction 10 Answers: 1) Analog, analog 2) Yes, digital 3) Yes, digital 4) 20 Degrees, analog