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

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

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

Radio Clock with DCF77

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

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

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

Combo Board.

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

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

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

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

Laboratory 8. Digital Circuits - Counter and LED Display

Lab #11: Register Files

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

Keyboard Controlled Scoreboard

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

Put Your Data Up in Lights Using an LED Display Chip

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

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

Embedded System Training Module ABLab Solutions

Seven Segment Board. User Manual. 1.0, Oct 2011

4.3 8 bit TFT Digital Driver Board Specification

Lab #10: Building Output Ports with the 6811

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

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

Experiment 8 Fall 2012

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

Digital (5hz to 500 Khz) Frequency-Meter

8 X 8 KEYBOARD INTERFACE (WITHOUT INTERRUPT SIGNAL)

University of Illinois at Urbana-Champaign

UNIT V 8051 Microcontroller based Systems Design

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

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

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

Data Sheet. Electronic displays

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

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

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

7 SEGMENT LED DISPLAY KIT

Combinational / Sequential Logic

Marks and Grades Project

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

ET-REMOTE DISTANCE. Manual of ET-REMOTE DISTANCE

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

Chapter 4: Table of Contents. Decoders

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

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

Quad 7-segment display board

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

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

UNIVERSITI TEKNOLOGI MALAYSIA

Digital Electronics II 2016 Imperial College London Page 1 of 8

Chapter 9 MSI Logic Circuits

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

Logic Design. Flip Flops, Registers and Counters

EE 367 Lab Part 1: Sequential Logic

Christmas LED Snowflake Project

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

COMPUTER ENGINEERING PROGRAM

Reaction Game Kit MitchElectronics 2019

ME 515 Mechatronics. Introduction to Digital Electronics

Experiment: FPGA Design with Verilog (Part 4)

Digital IC Tester by Using PIC18F4550

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

Laboratory Exercise 4

S6B CH SEGMENT DRIVER FOR DOT MATRIX LCD

64CH SEGMENT DRIVER FOR DOT MATRIX LCD

T 2 : WR = 0, AD 7 -AD 0 (μp Internal Reg.) T 3 : WR = 1,, M(AB) AD 7 -AD 0 or BDB

PHYS 3322 Modern Laboratory Methods I Digital Devices

Lab #13: FPGA Circuit Realization

Chapter 3. Boolean Algebra and Digital Logic

Inside Digital Design Accompany Lab Manual

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

Design and implementation (in VHDL) of a VGA Display and Light Sensor to run on the Nexys4DDR board Report and Signoff due Week 6 (October 4)

Fixed-Point Calculator

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

CHAPTER 4: Logic Circuits

CHAPTER 4: Logic Circuits

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Task 4_B. Decoder for DCF-77 Radio Clock Receiver

Transcription:

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

PIC interfacing The PIC needs to 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 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 Assume you connected a common cathode display as shown in the figure, to display a 3 you store a B'01001111' in PORTB PIC RB0 RB1 a b RB6 g

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

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

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

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

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

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 to 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 } } }