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

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

Experiment 3: Basic Embedded System Analysis and Design

EXPERIMENT 2: Elementary Input Output Programming

Model Solution and marking scheme for Examination Paper EEE305J1: Microcontroller Systems 2004/5 General Observations

MECE336 Microprocessors I

Distance, Velocity and Acceleration Detection

An Enhanced MM MHz Generator

Introduction to PIC Programming

Four Channel Digital Voltmeter with Display and Keyboard. Hardware RB0 RB1 RB2 RB3 RB4 RB5 RB6 RB7 RA0 RA1 RA2 RA3 PIC16C71

Chapter 11 Sections 1 3 Dr. Iyad Jafar

Discrete Logic Replacement Melody Player

ECE 372 Microcontroller Design

Radio Clock with DCF77

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

VikiLABS. a g. c dp. Working with 7-segment displays. 1 Single digit displays. July 14, 2017

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

EKT 222 MICROPRESSOR SYSTEM. LAB 4 Extra : INTERFACING WITH OTHER I/O DEVICES

Combo Board.

Module 4: Traffic Signal Design Lesson 1: Traffic Signal (Arduino) Control System Laboratory Exercise Grade 6-8

International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE)

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

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

Keyboard Controlled Scoreboard

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

PRACTICAL WORK BOOK For Academic Session Semester. DIGITAL LOGIC DESIGN (TC-203) For SE (TC)

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

Laboratory 8. Digital Circuits - Counter and LED Display

Embedded System Training Module ABLab Solutions

Lab #11: Register Files

Put Your Data Up in Lights Using an LED Display Chip

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

INTERNATIONAL JOURNAL OF ELECTRONICS AND COMMUNICATION ENGINEERING & TECHNOLOGY (IJECET) APPLIANCE SWITCHING USING EYE MOVEMENT FOR PARALYZED PEOPLE

ELCT706 MicroLab Session #3 7-segment LEDs and Analog to Digital Conversion. Eng. Salma Hesham

Digital (5hz to 500 Khz) Frequency-Meter

Experiment 7 Fall 2012

Technology Control Technology

NAND/NOR Implementation of Logic Functions

Chapter 3: Sequential Logic Systems

CSE221- Logic Design, Spring 2003

Lesson 12. Advanced Digital Integrated Circuits Flip-Flops, Counters, Decoders, Displays

Theory Lecture Day Topic Practical Day. Week. number systems and their inter-conversion Decimal, Binary. 3rd. 1st. 1st

UNIT V 8051 Microcontroller based Systems Design

Physics 217A LAB 4 Spring 2016 Shift Registers Tri-State Bus. Part I

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

Seven Segment Board. User Manual. 1.0, Oct 2011

4.3 8 bit TFT Digital Driver Board Specification

All rights reserved. We advise readers to check that all parts are still available before commencing any project.

Lab #10: Building Output Ports with the 6811

Reaction Game Kit MitchElectronics 2019

bit TFT Digital Driver Board Specification

ECE Lab 5. MSI Circuits - Four-Bit Adder/Subtractor with Decimal Output

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

Experiment 8 Fall 2012

MICROCHIP. STEMSEL LCD Project 6 : Clock. Problem Design a program that displays a clock on the LCD.

Christmas LED Snowflake Project

8 X 8 KEYBOARD INTERFACE (WITHOUT INTERRUPT SIGNAL)

University of Illinois at Urbana-Champaign

UNIVERSITI TEKNOLOGI MALAYSIA

Experiment (6) 2- to 4 Decoder. Figure 8.1 Block Diagram of 2-to-4 Decoder 0 X X

Data Sheet. Electronic displays

Lecture (04) Arduino Microcontroller Programming and interfacing. By: Dr. Ahmed ElShafee

Digital IC Tester by Using PIC18F4550

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

STEMSEL LCD Project 8 : Vending Machine MICROCHIP. Figure 1: Inputs and Outputs

EE 367 Lab Part 1: Sequential Logic

DM Segment Decoder/Driver/Latch with Constant Current Source Outputs

7 SEGMENT LED DISPLAY KIT

Combinational / Sequential Logic

Marks and Grades Project

CPSC 121: Models of Computation. Module 1: Propositional Logic

ET-REMOTE DISTANCE. Manual of ET-REMOTE DISTANCE

One Shot, Two Shot, Red Shot, Blue Shot. Build Instructions

Chapter 3. Boolean Algebra and Digital Logic

8 PIN PIC PROGRAMMABLE BOARD (DEVELOPMENT BOARD & PROJECT BOARD)

LCD Direct Drive Using HPC

Chapter 4: Table of Contents. Decoders

Lab #12: 4-Bit Arithmetic Logic Unit (ALU)

Vtronix Incorporated. Simon Fraser University Burnaby, BC V5A 1S6 April 19, 1999

Advanced Devices. Registers Counters Multiplexers Decoders Adders. CSC258 Lecture Slides Steve Engels, 2006 Slide 1 of 20

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

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

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

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

Quad 7-segment display board

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

Digital Electronics II 2016 Imperial College London Page 1 of 8

Lesson Sequence: S4A (Scratch for Arduino)

Chapter 9 MSI Logic Circuits

Tutorial Introduction

Logic Design. Flip Flops, Registers and Counters

The Micropython Microcontroller

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

COMPUTER ENGINEERING PROGRAM

Embedded Systems Lab. Dynamic Traffic and Street Lights Controller with Non-Motorized User Detection

CHAPTER 16 UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL

Introduction to Digital Electronics

Experiment: FPGA Design with Verilog (Part 4)

ME 515 Mechatronics. Introduction to Digital Electronics

EE 357 Lab 4 Stopwatch

DM Segment Decoder/Driver/Latch with Constant Current Source Outputs

Transcription:

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

PIC interfacing In any embedded system, the microcontroller should be connected to other devices such as: LEDs Switches Keypad 7-Segment displays LCD Motor etc...

7-segment display

7-Segment display A device that has 7 LEDs used to display a single decimal digit Each LED has two pins Two types of 7-Segment displays: Common Anode: all anode pins are connected Common Cathode: all cathode pins are connected

7-Segment display

Example Assume you want to display a 3 on a common cathode 7- segment display: GND 1 1 1 1 0 0 1 0

7-Segment display Assume you connected a common cathode display as shown in the figure, what should be stored in PORTB to show the number 3 PIC RB0 RB1 a b RB6 g common

Example Write a program that will count through the numbers from 0 to 9, and display the numbers on a common cathode 7-segment display that is connected to PORTB PIC RB0 RB1 a b RB6 g common

7-Segment display Write a table showing the required inputs to display all digits from 0 to 9, assuming you are using a common cathode display

7-Segment display Basic structure of the program: #include "p16f84a.inc" ; variable definition ORG 0x000 ; main program ; initailization (input/output) ; lookup table ; delay subroutine END

7-Segment display To store the table you can use a lookup table table MOVF X, 0 ADDWF PCL, 1 RETLW B'00111111' RETLW B'00000110' RETLW B'01011011' RETLW B'01001111' RETLW B'01100110' RETLW B'01101101' RETLW B'01111101' RETLW B'00000111' RETLW B'01111111' RETLW B'01101111'

7-Segment display To count through the numbers, you use a loop CLRF X loop CALL table MOVWF PORTB CALL delay INCF X, 1 MOVLW D'10' ; make sure that x is less than 10 XORWF X, 0 ; if X == 10, then X = 0 BTFSC STATUS, Z CLRF X GOTO loop

7 Segment display Instead of a lookup table, you can use an external decoder (BCD to 7-segment) instead of using a lookup table PIC RB0 RB1 RB2 RB3 BCD to 7 segment decoder a b g

7 Segment display Program to count through the numbers 0 9 Much easier program, but you need to add a decoder CLRF X loop MOVF X, 0 MOVWF PORTB CALL delay INCF X, 1 MOVLW D'10' ; make sure that x is less than 10 XORWF X, 0 ; if X == 10, set X = 0 BTFSC STATUS, Z CLRF X GOTO loop

Exercise Assume that you have a push button and a common anode 7 segment display. The display starts at 0 and is incremented each time the button is pushed. Draw the circuit diagram in detail Write the flow chart of the program Write the program in assembly

Exercise Circuit diagram Circuit diagram:

Exercise Flow chart Start x=0 false true x = x+1 true x = 0 false display x

Exercise - Table Table: ; look up table for a common anode 7 segment display table ADDWF PCL, 1 RETLW 0x40 RETLW 0x79 RETLW 0x24 RETLW 0x30 RETLW 0x19 RETLW 0x12 RETLW 0x02 RETLW 0x78 RETLW 0x00 RETLW 0x10

Exercise - Code ; Include register definition file #include "p16f84a.inc" ; VARIABLES x EQU 0x0C ; input/output selection BSF STATUS, RP0 CLRF TRISB BSF TRISA, 0 BCF STATUS, RP0 CLRF x ; check if button is pushed loop BTFSS PORTA,0 CALL next_x ; put the value of x on ; the 7 segment display MOVF x, 0 CALL table MOVWF PORTB next_x INCF x, 1 ; increment x L1 ; if x == 10, then x = 0 MOVLW D'10' XORWF x, 0 BTFSC STATUS, Z CLRF x ; wait until RA0 = 1 BTFSS PORTA,0 GOTO L1 RETURN GOTO loop

Problem What if you need to connect 4 digits? directly, you need 4*7 = 28 pins using a decoder 4*4= 16 pins The number of pins is large Solutions: PIC with more outputs Use a Latch/register to store an output Use persistence of vision (POV)

Multiple 7-Segment displays Latch is a register that stores a value, when enabled, the input is transferred to the output when disabled, the output does not change, and stays as the previous output Input Latch Output Enable

Multiple 7-Segment displays PIC PORTB 8 Latch 8 RA1 RA0 Enable 8 Latch 8 Enable

Multiple 7-Segment displays How many outputs are used? 8 for a digit (PORTB) 2 for control (PORTA) Total: 10 outputs How many outputs if you want to connect 4 digits 8 for digit 4 for control Total: 12 outputs

Multiple 7-Segment displays Algorithm: Disable all latches Display digit 1 Enable latch 1 Disable latch 1 Display digit 2 Enable latch 2... repeat for remaining digits

Multiple 7-Segment displays Another method: Persistence of vision If an LED is turned on and off more than 25 times in a second, your eye will see it as always on. Same idea as the television: A frame is drawn 25 times per second, so you see the TV images as a moving picture (video)

Multiple 7-Segment displays Using the concept of Persistence of vision, circuit diagram: PIC PORTB 8 common

Multiple 7-Segment displays Algorithm to display a 4 digit number: Start: disable all digits (CLRF PORTA) put digit 1 on PORTB enable digit 1 (BSF PORTA, 0) call delay disable digit 1 (BCF PORTA, 0) put digit 2 on PORTB enable digit 2 (BSF PORTA, 1) call delay disable digit 2 (BCF PORTA, 1) repeat for digits 3 and 4... goto start

Problem Assembly programs: hard to write hard to debug user must be an expert in Assembly Most of you are not computer engineering students and don't need to be an expert in Assembly... So, Why use assembly?? efficient programs smaller program size complete control of the MCU

High level language A simpler option for non-computer engineers: write your program in a high level language C, Basic, Java, etc use a compiler to translate from C to PIC machine language some available compilers: mikroc, microchip C compiler,

Example Build a circuit that counts through the numbers from 0 to 9 and display the result on a 7 segment display, use a BCD to 7-segment decoder to connect the display BCD to 7-Segment decoder is connected to RB0, RB1, RB2, RB3 decoder output is connected to the 7-segment display

Example circuit diagram:

Example Program: void main() { int i = 0; // counter TRISB = 0; // set PORTB as output PORTB = 0; // output a zero while ( 1 ) { // loop to display numbers from 0 to 9 for ( i = 0; i <= 9; i++) { PORTB = i; // display the number Delay_ms(1000); // delay for 1 second } } }