EXPERIMENT 2: Elementary Input Output Programming

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

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

Experiment 3: Basic Embedded System Analysis and Design

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

ECE 372 Microcontroller Design

Chapter 11 Sections 1 3 Dr. Iyad Jafar

Distance, Velocity and Acceleration Detection

Introduction to PIC Programming

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

Data Conversion and Lab (17.368) Fall Lecture Outline

Combo Board.

An Enhanced MM MHz Generator

Embedded System Training Module ABLab Solutions

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

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

MECE336 Microprocessors I

ET-REMOTE DISTANCE. Manual of ET-REMOTE DISTANCE

Discrete Logic Replacement Melody Player

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

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

Radio Clock with DCF77

Keyboard Controlled Scoreboard

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

Step What to do Expected result What to do if test fails Component tested 1 Visual inspection. Board is accurately assembled

DX-10 tm Digital Interface User s Guide

Experiment 7 Fall 2012

CoLinkEx JTAG/SWD adapter USER MANUAL

The Micropython Microcontroller

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

USER'S MANUAL. Getting started with ALEXAN ATMEL AT89C2051/AT89C4051 Training Module - 1

Lesson Sequence: S4A (Scratch for Arduino)

TV Synchronism Generation with PIC Microcontroller

Digital IC Tester by Using PIC18F4550

MyFlyDream TeleFlyPro V1.04

EECS145M 2000 Midterm #1 Page 1 Derenzo

APPLICATION NOTE 4312 Getting Started with DeepCover Secure Microcontroller (MAXQ1850) EV KIT and the CrossWorks Compiler for the MAXQ30

RF4432 wireless transceiver module

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

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

ATA8520D Production and EOL Testing. Features. Description ATAN0136 APPLICATION NOTE

UNIT V 8051 Microcontroller based Systems Design

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

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

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

Laboratory Exercise 4

Digital (5hz to 500 Khz) Frequency-Meter

Reaction Game Kit MitchElectronics 2019

CHAPTER 3 EXPERIMENTAL SETUP

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

DESIGN AND DEVELOPMENT OF A MICROCONTROLLER BASED PORTABLE ECG MONITOR

The Haply Development Kit

Entry Level Tool II. Reference Manual. System Level Solutions, Inc. (USA) Murphy Avenue San Martin, CA (408) Version : 1.0.

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

TRIMBLE GPS / 10MHz REFERENCE MONITOR DISPLAY V January 2015

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

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Alice EduPad for Tiva or MSP432 TI ARM Launchpad. User s Guide Version /23/2017

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

Preliminary Design Report. Remote Fencing Scoreboard Gator FenceBox

Laboratory 8. Digital Circuits - Counter and LED Display

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

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)

This module senses temperature and humidity. Output: Temperature and humidity display on serial monitor.

FPGA-BASED EDUCATIONAL LAB PLATFORM

External Hardware Trigger Settings for RICOH Stereo Cameras

The Serial Port is Dead! Long Live the Serial Port! USB Serial Port Breadboard Experiments with the FTDI FT232R

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

Experiment 0: Hello, micro:bit!

Keymaker for MB trucks.

Memec Spartan-II LC User s Guide

L, LTC, LTM, LT are registered trademarks of Linear Technology Corporation. Other product

RF4432F27 wireless transceiver module

Simple PICTIC Commands

AD9884A Evaluation Kit Documentation

Section 24. Programming and Diagnostics

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

DMC550 Technical Reference

Point System (for instructor and TA use only)

LED Array Board.

ECE Design Team 3 Madi Kassymbekov How to use MSP 430 Peripheral Sensors and use of LEDs as sensors

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

Serial Peripheral Interface

Hardware Guide BrightSign, LLC Version:.1 Los Gatos, CA, USA. MODELS: XD Product Line

SAPLING WIRED SYSTEM

DT9834 Series High-Performance Multifunction USB Data Acquisition Modules

IT-100 INSTRUCTION MANUAL

16-CH Color Full Duplex Multiplexer Instruction Manual

Marks and Grades Project

Technology Control Technology

Data Acquisition Using LabVIEW

Manual Version Ver 1.0

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Section 24. Programming and Diagnostics

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 65 MSPS DUAL ADC

AL330B-DMB-A0 Digital LCD Display SOC Demo Board

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

2070 PROFINET MODULE

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

NS8050U MICROWIRE PLUSTM Interface

Transcription:

EXPERIMENT 2: Elementary Input Output Programming Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing with digital inputs and outputs such as switches, LEDs and 7-segment. Introduction Overview of the PIC18F4550 Parallel Ports. A PIC18F4550 microcontroller has 5 I/O ports known as port A, B, C, D and E. The pins of an I/O port are often multifunctional with one or more peripheral functions e.g. interrupt, timer, analog to digital and etc. In general, when a peripheral function is enabled, that pin may not be used as an I/O pin. Note: Please refer to PIC18F4550 datasheet in moodle appendix for detailed functions of each port and its pins. Each I/O port has three register for its operation. These register are: TRIS register (data direction register) PORT register (reads the voltage levels on the pins device) LAT register (output latch) The register names for each port can be derived by adding the port name to these general register names. For example, port A has TRISA, PORTA and LATA registers. Reading and Writing the I/O Ports Data direction needs to be set before the I/O operation. In order to configure an I/O pin for input, set the associated bit in the TRIS register to 1. To configure an I/O pin for output, set the associated bit in the TRIS register to 0. Digital Switch Input Switch is a commonly used component to give digital signal. PTK40A offers 4 commonly used push buttons; one is designated for Reset purpose and other 3 as programmable digital pin. It is being connected in pulled high configuration; the input signal is initially set to 5V (high). When the switch is pressed, the input signal becomes 0V (low). The opposite condition happened to the pulled low configuration. Microcontroller can be programmed to read the status of input pin and determine action based on the status. Besides switches, digital sensors also provide digital signal to microcontroller which serve the same function as switches. EEEB371 E2-1

Figure 2.1 Connection of push buttons on PTK40A Training Kit From Figure 2.1, SW1, SW2 and SW3 are being shared with KC1, KC2 and KC3 pins of keypad respectively. Please do not press any key on the keypad while using the push button switches. Switches is being pull-up to 5V through resistor, thus if pressed, the corresponding pin is pulled to Gnd. In program, please check for logic low (0V) if a press is needed. Digital LED Output LED is the most basic and commonly used output device in electronic circuit board. It is an indicator to display the logic status (High or Low) of a specific pin. Like any other output devices, LED can be active-high or active-low as shown in Figure 2.2 below. In PTK40A, most output pins of PIC are connected to an LED as indicator and connected in active high configuration. EEEB371 E2-2

Figure 2.2 Connection of LEDs on PTK40A Training Kit Digital Buzzer Output Similar to LED, buzzer is a simple output component that can be used as sound indicator. The buzzer will buzz continuously when power is provided (5V) and will turn off when the power is being cut off (0V). In other words, this is an active high configuration. Refer to Figure 2.3 for the connection of buzzer with PIC Microcontroller. Figure 2.3 Connection of Buzzer to RC2 on PTK40A Training Kit EEEB371 E2-3

For hardware configuration, set mini jumper on JP10 to activate buzzer as per Figure 2.4. Figure 2.4 Hardware configuration for Buzzer 7-Segment Display 7-segment is a component that consists seven segments of lights which would display the number from 0 to 9. For normal application, it can be connected as shown at figure 2.4 PTK40A uses common cathode 7-segment. Microcontroller can display any number (0-9) by activating the correct segment via providing 5V similar to the LED in previous section; of course the resistor is needed in between. For example, microcontroller can switch on the segment a, b, c, d, g and switch off segment f, e to display the number 3. However, to save the usage of the I/O pins of MCU and to simplify the control commands the 7-segment is connected with a decoder unit. In PTK40A, 2 CD4511 (BCD decoder) are used to decode 2 units of 7-segment. With that we are able to control 2 units of 7-segment with 6 output pins from microcontroller. Note that RE0 is used to enable (low enable) the first 7-Segment and RE1 is used to enable (low enable) the second 7-Segment. Both BCD decoders are sharing pins RD0-RD3. Figure 2.5 Connection of 7-Segment on PTK40A Training Kit EEEB371 E2-4

Procedure 1. For this experiment, you are required to complete a program to fulfill your given task. TASK 1: The task is to control the LEDs using SW1 (RB0) and SW2 (RB1). When SW1 is pressed, LEDs RD0-RD7 should rotate from left to right with 1 second interval and when SW2 is pressed, LEDs RD0-RD7 should blink with 1 second interval. The LEDs should perform the specified tasks as long as each one of those switches is pressed. 2. Write and complete the program below using MPLAB ;Put ID No and name of students #include<p18f4550.inc> ;include assembler directives here ;include makro here org 0x00 goto start org 0x08 org 0x18 ;main program start SETF TRISB,A ;configure portb as input CLRF TRISD,A ;configure portd as output CLRF PORTD,A ;initialize portd to turn OFF AGAIN BTFSS PORTB,0 ;check SW1 condition BRA FIRST BTFSC PORTB,1 ;check SW2 condition SETF PORTD,A ;execute if SW2 is pressed CLRF PORTD,A FIRST BSF PORTD,7,A ;execute if SW1 is pressed MOVLW 0x07 MOVWF PRODL,A LOOP RRNCF PORTD,F,A DECFSZ PRODL,F,A BRA LOOP CLRF PORTD,A NOP DELAY1S ;1sec delay for 20Mhz RETURN END 3. Execute and test your program on the board. Press the switches randomly. Write your observation in the worksheet. EEEB371 E2-5

4. TASK 2: The next task is to turn ON and OFF the buzzer 5 times with 1 second interval when SW3 is pressed. Write, complete and execute the program below. Write your observation. ;Put ID No and name of students #include<p18f4550.inc> ;include assembler directives here ;include makro here org 0x00 goto start org 0x08 org 0x18 ;main program start SETF TRISB,A ;configure portb as input BCF TRISC,2,A ;configure RC2 as output BCF PORTC,2,A ;initialize RC2 to turn OFF AGAIN BTFSC PORTB,2 ;check SW3 condition ;to turn ON & OFF ;the buzzer 5 times ;when SW3 is pressed NOP DELAY1S ;1sec delay for 20Mhz RETURN END 5. Draw the flowchart of the program for the program above. EEEB371 E2-6

6. TASK 3: The subsequent task is to display number 1 until 9 on the 7-Segment with 1 second interval between each number display when SW1 is pressed. Write, complete and execute the program below. Write your observation. ;Put ID No and name of students #include<p18f4550.inc> ;include assembler directives here ;include makro here org 0x00 goto start org 0x08 org 0x18 ;main program start SETF TRISB,A ;configure portb as input CLRF TRISE,A ;configure porte as output CLRF TRISD,A ;configure portd as output CLRF PORTD,A ;initialize portd to turn OFF CLRF PRODH,A ;initialize PRODH to hold the value of number to be displayed BSF PORTE,0,A ;disable first 7 segment and enable the second 7 segment AGAIN BTFSC PORTB,0 ;check SW1 condition MOVLW 0x0A ;execute task when SW1 is pressed MOVWF PRODL,A LOOP MOVFF PRODH,PORTD INCF PRODH,F,A DECFSZ PRODL,F,A BRA LOOP CLRF PRODH,A CLRF PORTD,A NOP DELAY1S ;1sec delay for 20Mhz RETURN END 7. TASK 4: The final task to write a complete program which will display number 0 until 9 with 1 second interval between each number display when SW2 is pressed and upon reaching number 9, the buzzer will ON and OFF 3 times with 1 second interval between each beep. Write your observation. Copy and Paste LST file to Word Doc and print. Make sure that the LST file is properly commented. 8. Turn off the PTK40A power supply, and rearrange the USB cable back into the Training Kit. Exit from MPLAB and PICKit 2 programmer. Shutdown your PC and rearrange your workstation before you leave. EEEB371 E2-7