ECE 372 Microcontroller Design

Similar documents
MBI5050 Application Note

Chapter 9 MSI Logic Circuits

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

Laboratory 9 Digital Circuits: Flip Flops, One-Shot, Shift Register, Ripple Counter

EXPERIMENT 2: Elementary Input Output Programming

University of Illinois at Urbana-Champaign

EECS145M 2000 Midterm #1 Page 1 Derenzo

Lab #5: Design Example: Keypad Scanner and Encoder - Part 1 (120 pts)

UNIT V 8051 Microcontroller based Systems Design

Lab #6: Combinational Circuits Design

Laboratory 10. Required Components: Objectives. Introduction. Digital Circuits - Logic and Latching (modified from lab text by Alciatore)

Lab #11: Register Files

16 Stage Bi-Directional LED Sequencer

Laboratory 8. Digital Circuits - Counter and LED Display

Logic Devices for Interfacing, The 8085 MPU Lecture 4

PHYSICS 358 Advanced Electronics Laboratory Manual Fall 2014 Dr. Adam T. Whitten

I/O Interfacing. What we are going to learn in this session:

Digital Clock. Perry Andrews. A Project By. Based on the PIC16F84A Micro controller. Revision C

Alice EduPad Board. User s Guide Version /11/2017

EEM Digital Systems II

Laboratory 7. Lab 7. Digital Circuits - Logic and Latching

Embedded System Training Module ABLab Solutions

Experiment 7 Fall 2012

Chapter 3: Sequential Logic Systems

Laboratory 11. Required Components: Objectives. Introduction. Digital Displays and Logic (modified from lab text by Alciatore)

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

Keyboard Controlled Scoreboard

7 SEGMENT LED DISPLAY KIT

Chapter 7 Memory and Programmable Logic

Copyright 2011 by Enoch Hwang, Ph.D. and Global Specialties. All rights reserved. Printed in Taiwan.

TV Character Generator

V6118 EM MICROELECTRONIC - MARIN SA. 2, 4 and 8 Mutiplex LCD Driver

Microcontrollers and Interfacing week 7 exercises

Chapter 8 Functions of Combinational Logic

cs281: Introduction to Computer Systems Lab07 - Sequential Circuits II: Ant Brain

Decade Counters Mod-5 counter: Decade Counter:

Experimental Study to Show the Effect of Bouncing On Digital Systems

Integration of Virtual Instrumentation into a Compressed Electricity and Electronic Curriculum

EE 367 Lab Part 1: Sequential Logic

Half-Adders. Ch.5 Summary. Chapter 5. Thomas L. Floyd

Part (A) Controlling 7-Segment Displays with Pushbuttons. Part (B) Controlling 7-Segment Displays with the PIC

YEDITEPE UNIVERSITY DEPARTMENT OF COMPUTER ENGINEERING. EXPERIMENT VIII: FLIP-FLOPS, COUNTERS 2014 Fall

Introduction to Digital Electronics

Data Conversion and Lab (17.368) Fall Lecture Outline

Physics 120 Lab 10 (2018): Flip-flops and Registers

Embedded Systems. Interfacing PIC with external devices 7-Segment display. Eng. Anis Nazer Second Semester

Combinational vs Sequential

CHAPTER 4: Logic Circuits

TV Synchronism Generation with PIC Microcontroller

Section 24. Programming and Diagnostics

Chapter 5 Flip-Flops and Related Devices

Experiment 3: Basic Embedded System Analysis and Design

Figure 1: segment of an unprogrammed and programmed PAL.

CSE221- Logic Design, Spring 2003

Analogue Versus Digital [5 M]

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422) COUNTERS

IS01BFRGB LCD SmartDisplay from NKK Switches Low cost implementation featuring the ATtiny13A from Atmel Complete software solution

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

ECB DIGITAL ELECTRONICS PROJECT BASED LEARNING PROJECT REPORT ON 7 SEGMENT DIGITAL STOP WATCH USING DECODER

Christmas LED Snowflake Project

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

Reaction Game Kit MitchElectronics 2019

COMP2611: Computer Organization. Introduction to Digital Logic

An Introduction to CY8C22x45

Hardware Design I Chap. 5 Memory elements

CHAPTER1: Digital Logic Circuits

IS01BFRGB LCD SmartDisplay from NKK Switches Simple implementation featuring the ATmega88PA from Atmel Complete software solution

MODULAR DIGITAL ELECTRONICS TRAINING SYSTEM

IMPLEMENTATION OF A BINARY SELECTION SYSTEM CREATED IN XILINX USING FPGA

Dynamic Animation Cube Group 1 Joseph Clark Michael Alberts Isaiah Walker Arnold Li

NORTHWESTERN UNIVERSITY TECHNOLOGICAL INSTITUTE

Shift registers. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

UNIVERSITI TEKNOLOGI MALAYSIA

CS8803: Advanced Digital Design for Embedded Hardware

Preliminary Design Report. Remote Fencing Scoreboard Gator FenceBox

Embedded Systems. Interfacing PIC with external devices 7-Segment display. Eng. Anis Nazer Second Semester

Digital Systems Based on Principles and Applications of Electrical Engineering/Rizzoni (McGraw Hill

STATIC RANDOM-ACCESS MEMORY

ENGR 40M Project 3b: Programming the LED cube

Section 24. Programming and Diagnostics

Digital Circuits 4: Sequential Circuits

Contents Circuits... 1

ME 515 Mechatronics. Introduction to Digital Electronics

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

IMS B007 A transputer based graphics board

The outputs are formed by a combinational logic function of the inputs to the circuit or the values stored in the flip-flops (or both).

Nan Ya NT5DS32M8AT-7K 256M DDR SDRAM

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

Digital Circuits. Innovation Fellows Program

ECE 2274 Pre-Lab for Experiment Timer Chip

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

Sequential Logic Notes

Logic Design Viva Question Bank Compiled By Channveer Patil

EE 109 Homework 6 State Machine Design Name: Score:

CHAPTER 4: Logic Circuits

EKT 121/4 ELEKTRONIK DIGIT 1

Digital Circuits I and II Nov. 17, 1999

UNIT III. Combinational Circuit- Block Diagram. Sequential Circuit- Block Diagram

uresearch GRAVITECH.US GRAVITECH GROUP Copyright 2007 MicroResearch GRAVITECH GROUP

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

Transcription:

E.g. Port A, Port B Used to interface with many devices Switches LEDs LCD Keypads Relays Stepper Motors Interface with digital IO requires us to connect the devices correctly and write code to interface with the devices

Where can we connect external hardware? Unused ports (most ports has digital IO functionality) Expand through the serial interface SPI serial peripheral interface UART I 2 C External Components to Expand IO Ports Where can we connect external hardware? 6-bit 28-pin Starter Board Port B (RB0 RB5) Port A (RA0, R, R) RB0, RB, RB4, and R can only be used on stand-alone programming Corresponds to pins 3, 4,, and 2 2

Digital Inputs What does the following circuit do? MCLR (Reset) Switch Schematic from 6-bit 28-pin Starter Board Note: MCLR is an active low signal. Active low signals are asserted if the input is low (0) For PICs, if the MCLR input is 0 the PIC is reset Used for Hardware De-Bouncing of Switch Input Resistor connected to Vdd is used to Pull-Up the input pin to a logical high Vdd is 3.3V for Logic high () will be seen when button is not pressed Logic high () will be seen when button is not pressed Pressing switch creates conduction path to ground Without capacitor, simple switches exhibit bouncing 3

Used for Hardware De-Bouncing of Switch Input Analog Voltage at Input Pin: Digital Value Read by PIC: Bouncing Charging and discharging of capacitor reduces bouncing behavior Analog Voltage at Input Pin: Digital Value Read by PIC: No Bouncing 4

When is a digital input a logic high () versus logic low (0) Depends on voltage standard used by the digital device Lots of standards exist Logic Low Input: < 0.2 Vdd (0.66V) Logic High Input: > 0.8 Vdd (2.64V) What about between 0.2 and.8 Vdd? All digital inputs have Schmitt Triggers Logic High () Logic Low (0) Vdd.8 Vdd.2 Vdd 0 V Schmitt Trigger Removes hysteresis between transition from low to high and high to low Helps in de-bouncing digital inputs (but does not solve it on its own) Analog Voltage at Input Pin:.8 Vdd Logic High () Vdd.8 Vdd.2 Vdd 0V Digital Value Read by PIC with Schmitt Trigger: Logic Low (0).2 Vdd 0 V 0 5

Software De-bouncing De-bouncing can be done in software using timed waits Simplifies external hardware needs Pseudocode for software de-bounce for button press // wait for button press while (switch == ); // delay for 5 to 0 ms for (i=0; i<some_larger_number; i++); Bad example of software de-bounce as timing using for loops is imprecise. Is there a better way? Directly Controlling LEDs can directly control LED from output ports Write 0 to port: Turns LED on Write to port: Turns LED off Vdd LEDs schematic from 6-bit 28-pin Starter Board 6

Directly Controlling LEDs How much current is drawn by IO? I = V / R = 3.3 / 475 = 6.9 ma How much current can be drawn by the PIC s IO pin? Check the datasheet 25 ma for How much current can be drawn by ALL IO pins of the PIC? Check the datasheet 200 ma LEDs schematic from 6-bit 28-pin Starter Board Configure IO Pins for Each IO Port has at least three registers TRIS : Controls tri-state driver for direction ( -> Input, 0 -> Output) LAT : Output latch for writing value to the port (or reading current value assigned to port) PORT : Value read directly from the port Additional Registers Needed for Some IOs CNPU : Enables weak internal pull-up resistor ADPCFG : Configures ports as analog or digital ODC : Enables open drain collector configuration 7

Directly Controlling LEDs What if we need to to control a 5V digital output? Can use the Open-Drain Collector configuration for the digital outputs ODC registers control configuration ( -> open drain configuration) 5V Use NPN transistor as digital switch NPN in On if base is high () Still limited to current limit of digital IO pin output Directly Controlling LEDs Brightness of LED can be controlled by controlling the current LEDs also have maximum current draw (exceeding this will destroy the LED) Using open collector, what is the smallest value resistor can we use: R = 5V / 25 ma = 200 With 330 : I = 5V / 330 = 5 ma 5V output 8

Directly Controlling LEDs We can use external IC to drive the LEDs Reduce current driven by microcontroller and protects it 74LS244IC Tri-state Buffer/Line Driver/Line Receiver Used to provide power for LEDs Has OE signals that can be used to disable the output OE OE2 74LS244 Directly Controlling LEDs Limitation - Can only drive as many LEDs as available pins Solutions: Latching Scanning Multiplexing OE OE2 74LS244 9

LEDs - Latching Control LED by using a latch hardware Use additional hardware to control when to latch values Similar to memory mapped IO LED Address LED Data OE LE OE LE Latch Latch Address=0 Address= LEDs - Latching Control LED by using a latch hardware Use additional hardware to control when to latch values Similar to memory mapped IO Always writing last LED value! Any problems?? Microcontroller Addr OE LE OE LE Latch Latch Address=0 Address= 0

LEDs - Latching Add enable signal from microcontroller What did we build? Is there another way to implement the address decoding? En Addr OE LE OE LE Latch Latch Address=0 Address= LEDs - Latching Use decoder for addressing LED banks Decoder - Converts input binary number to single high output 2-input decoder: four possible input binary numbers Thus, four outputs, one for each possible input binary number Enable signal Outputs all 0 if e=0 Regular behavior if e= i i0 d0 i i0 d ii0 d2 i0 i e d0 d d2 d3 ii0 d3 i i0

LEDs - Latching Use decoder for addressing LED banks En Addr en d0 i0 d x2 Decoder OE LE OE LE Latch Latch Address=0 Address= LEDs - Scanning Use software executing on the microcontroller to control LEDs row by row, col by col, or bank by bank (depending on organization) Operation Continually scan LEDs fast enough that human eye cannot detect it Similar to refresh rate of TVs and Monitors Enable one column of LEDs by writing 0 to output port controlling desired column Write LEDs value for select row LEDs Multiplexed Similar to scanning but uses decoders to specify the row and columsn Continually scan LEDs fast enough that human eye cannot detect it Similar to refresh rate of TVs and Monitors Enable LED column by outputting column address to column decoder Enable individual LEDs by outputting row address to row decoder Cannot access all LEDs simultaneously 2

How many LEDs can I control using only eight output pins using the following schemes? Latched: Scanned Multiplexed: How many LEDs can I control using only eight output pins using the following schemes? Latched: 64 LEDs Individual latch used for each LED Enable Output, 6 Address Lines, and Data Line Six address lines allow for access to 2 6 latches (or LEDs) Scanned 6 LEDs 4 columns by 4 rows Multiplexed: 256 LEDs 6 columns by 6 rows Enabled by using 4x6 decoder to select both row and columns 3

Mill Game How many pins do we need to connect the 48 LEDs in the following diagram? Mill Game 28 4

7-Segment LEDs Can directly control all seven segments using PIC IOs Or, driver IC can be used to control display using fewer pins 4 pins instead of 7pins Typically uses BCD to represent displayed value Keypads Collection of several keys grouped into a single device Can buy keypads in many different configurations Build your own keypad using individual buttons How can we read dozens of keys on the keypad without requiring dozens on individual input ports on our microprocessor? Hint: It s similar to how we can interface with dozens of outputs using only a few pins 5

Keypad Scanning Similar to scanning for controlling multiple output LEDs Scan the keys one row at a time and read the column lines to see if any key on that row were pressed row 0 row row 2 row 3 col 0 col col 2 col 3 Keypad Scanning Similar to scanning for controlling multiple output LEDs Scan the keys one row at a time and read the column lines to see if any key on that row were pressed row 0 row row 2 row 3 col 0 col col 2 col 3 6

Keypad Scanning Similar to scanning for controlling multiple output LEDs Scan the keys one row at a time and read the column lines to see if any key on that row were pressed 0 row 0 row row 2. Set each row output sequentially to output 0 row 3 col 0 col col 2 col 3 2. Check column inputs to see if key was pressed What if this key is pressed? Keypad Scanning Similar to scanning for controlling multiple output LEDs Scan the keys one row at a time and read the column lines to see if any key on that row were pressed 0 0 row 0 row row 2. Set each row output sequentially to output 0 row 3 col 0 col col 2 col 3 2. Check column inputs to see if key was pressed What if this key is pressed? 7

Keypad Scanning Can you detect if more than one key is pressed? How do you detect if no keys are pressed? row 0 row row 2 row 3 col 0 col col 2 col 3 Mill Game 36 8

Mill Game 8 Columns 3 Rows 9