EEE394 Microprocessor and Microcontroller Laboratory Lab #6

Similar documents
Laboratory Exercise 5 - Analog to Digital Conversion

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING B.ENG (HONS) ELECTRICAL AND ELECTRONIC ENGINEERING EXAMINATION SEMESTER /2016

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING. BEng(Hons) Electrical and Electronics Engineering SEMESTER 1 EXAMINATION 2016/2017

Microcontroller Based Automatic Temperature Control System

Embedded Systems Programming and Architectures

More PIC Programming. Serial and parallel data transfer External busses Analog to digital conversion

MPLAB SIM. MPLAB IDE Software Simulation Engine Microchip Technology Incorporated MPLAB SIM Software Simulation Engine

EasyPIC5 Development System

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING MSC SYSTEMS ENGINEERING AND ENGINEERING MANAGEMENT SEMESTER 2 EXAMINATION 2016/2017

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Week1. EEE305 Microcontroller Key Points

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

Embedded Systems Lab Lab 8 EEPROM

Programming 8-bit PIC Microcontrollers in С

Micro-Controller: PIC16C74 < Part 5: Interrupt >

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

TEVATRON TECHNOLOGIES PVT. LTD Embedded! Robotics! IoT! VLSI Design! Projects! Technical Consultancy! Education! STEM! Software!

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

8051 Training Kit Lab Book

These 3 registers contain enable, priority,

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

Interrupts on PIC18F252 Part 2

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

PIC Discussion By Eng. Tamar Jomaa

MICROPROCESSORS A (17.383) Fall Lecture Outline

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

ECE2049: Embedded Systems in Engineering Design Lab Exercise #3 C Term Making a Time and Temperature Display

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Laboratory 9. Programming a PIC Microcontroller - Part I

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

Interrupts on PIC18F252 Part 2. Interrupts Programming in C Language

Lecture (04) PIC 16F84A programming I

Department of Electronics and Instrumentation Engineering Question Bank

TB033. Using the PIC16F877 To Develop Code For PIC16CXXX Devices INTRODUCTION. Stan D Souza, Rodger Richey Microchip Technology Inc.

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

To be familiar with the USART (RS-232) protocol. To be familiar with one type of internal storage system in PIC (EEPROM).

PIC Microcontroller Introduction

ME 6405 Introduction to Mechatronics

Introduction to Embedded Systems

Linux Kernel Hacking Free Course, 3rd edition. HWMPS: Hardware Monitor & Protection System

Bolt 18F2550 System Hardware Manual

The University of Texas at Arlington Lecture 21_Review

Embedded Systems. Software Development & Education Center. (Design & Development with Various µc)

Processor and compiler dependent

The amount of current drawn and the temperature generated by DC motor are crucial in understanding the performance and reliability of motors.

Design, Development & Implementation of a Temperature Sensor using Zigbee Concepts

Mod-5: PIC 18 Introduction 1. Module 5

Implementation of Temperature Sensor on PICM4520 Microcontroller

Chapter 13. PIC Family Microcontroller

UNIVERSITY OF NAIROBI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING PROJECT 106: POWER SYSTEM FAILURE MONITORING UNIT

HOURS SYLLABUS

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

The Atmel ATmega328P Microcontroller

INDUSTRIAL TRAINING:6 MONTHS PROGRAM TEVATRON TECHNOLOGIES PVT LTD

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

Interrupts and Serial Communication on the PIC18F8520

Small Scale PV Monitoring System Software Design

AN5181. Building a thermometer using the STM8 Nucleo-64 boards. Application note. Introduction

Introducing Microcontrollers System Design

Embedded System Design

ELCT708 MicroLab Session #1 Introduction to Embedded Systems and Microcontrollers. Eng. Salma Hesham

SYSTEM DESIGN SPECIFICATIONS ZIGBEE BASIC SYSTEM

Input/Output Ports and Interfacing

Downloaded from Elcodis.com electronic components distributor

Interrupts. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Images Courtesy of Ramesh Gaonkar and Delmar Learning

HI-TIDE Release Notes for Version 3.13

Laboratory: Introduction to Mechatronics

Microprocessors/Microcontrollers

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

EMBEDDED SYSTEMS COURSE CURRICULUM

A. This Errata sheet represents the known bugs, anomalies and work-arounds for the ADuC812 MicroConverter.

EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

Environmental Data Acquisition Using (ENC28J60)

HC12 Built-In Hardware

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Arduino Uno R3 INTRODUCTION

Team 8: Robert Blake Craig Goliber Alanna Ocampo

Lecture 14. Ali Karimpour Associate Professor Ferdowsi University of Mashhad

Lecture (03) PIC16F84 (2)

Chapter 2. Integration of the distributed data server with the. vital sign meter

IMPROVING PROCESS CONTROL APPLICATIONS BY USING IP COMMUNICATIONS

Embedded Systems and Software

Mid-Range Family Peripheral Configuration with C Programming

CONTENTS. dspicpro4 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

CSE 466 Exam 1 Winter, 2010

Hello, and welcome to this presentation of the STM32 general-purpose IO interface. It covers the general-purpose input and output interface and how

CN310 Microprocessor Systems Design

VA108x0 SPI memory boot options application note

Hello, and welcome to this presentation of the STM32 Touch Sensing Controller (TSC) which enables the designer to simply add touch sensing

Clock and Fuses. Prof. Prabhat Ranjan Dhirubhai Ambani Institute of Information and Communication Technology, Gandhinagar

Microcontroller Introduction

PVK40. User's manual. Feature Rich Development and Educational Kit for 40-pin Microchip PIC microcontrollers

Development Hardware. Target Board and In-circuit Debugger

Speed Control of a DC Motor using Digital Control

Transcription:

Exp. No #6 Date: INTERRUPTS AND ADC IN PIC MICROCONTROLLER OBJECTIVE The purpose of the experiment is to configure external interrupt and the ADC in PIC microcontrollers. (i) To flip the LED connected to port using interrupt (ii) To convert analog signal to digital signal using ADC module in PIC. (iii) To display the analog voltage in LCD. PRE-LAB Complete the following study before starting the lab PIC16F877A Interrupts and ADC module PIC16Fxx reference manual THEORY INTERRUPTS An interrupt suspends the execution of the main program and a jump is executed to an interrupt service subroutine that takes some action in response to the interrupting condition and then returns control of the MCU back to the main program. The interrupt capable resources within the Microcontroller (MCU) can be divided into the two broad categories, those generated by external devices that are monitored by the MCU and internal resources. The external devices might include switches or sensors that are connected to I/O port pins, ADCs, or the comparator. The internal resources that can generate interrupts include TMRO and TMRI timer resources and write operations to internal Electrically Erasable Programmable Read-Only Memory (EEPROM.) PIC16F877 has many sources of interrupt. These sources generally include one interrupt source for each peripheral module, The current interrupts include INT Pin Interrupt (external interrupt), TMR0 Overflow Interrupt, PORTB Change Interrupt (pins RB7:RB4), Comparator Change Interrupt, Parallel Slave Port Interrupt, USART Interrupts, Receive Interrupt, Transmit Interrupt, A/D Conversion Complete Interrupt, LCD Interrupt, Timer1 Overflow Interrupt, Timer2 Overflow Interrupt, CCP Interrupt. One register used in the control and status of the interrupt is INTCON. Additionally, if the device has peripheral interrupts, then it will have registers to enable the peripheral interrupts and registers to hold the interrupt flag bits. These registers are named as PIR and PIE. Page 58

A/D CONVERTER The analog-to-digital (A/D) converter module has up to eight analog inputs for a device. The converter then generates a digital result of this analog level via successive approximation. This A/D conversion, of the analog input signal, results in a corresponding 10-bit digital number. The analog reference voltages (positive and negative supply) are software selectable to either the device s supply voltages (AV DD, AVss) or the voltage level on the AN3/V REF + and AN2/V REF pins. The A/D module has four registers. These registers are: A/D Result High Register (ADRESH), A/D Result Low Register (ADRESL), A/D Control Register0 (ADCON0), A/D Control Register1 (ADCON1). The ADCON0 register controls the operation of the A/D module. The ADCON1 register configures the functions of the port pins. Page 59

Page 60

A/D Result Registers The ADRESH : ADRESL register pair is the location where the 10-bit A/D result is loaded at the completion of the A/D conversion. This register pair is 16-bits wide. The A/D module gives the flexibility to left or right justify the 10-bit result in the 16-bit result register. The A/D Format Select bit (ADFM) controls this justification. The following steps should be followed for doing an A/D conversion: 1. Configure the A/D module: Configure analog pins / voltage reference/ and digital I/O (ADCON1) Select A/D input channel (ADCON0) Select A/D conversion clock (ADCON0) Turn on A/D module (ADCON0) 2. Configure A/D interrupt (if desired): Clear the ADIF bit Set the ADIE bit Set the GIE bit 3. Wait the required acquisition time. 4. Start conversion: Set the GO/DONE bit (ADCON0) 5. Wait for A/D conversion to complete, by either: Polling for the GO/DONE bit to be cleared or ADIF bit to be set OR Waiting for the A/D interrupt 6. Read A/D Result register pair (ADRESH:ADRESL), clear the ADIF bit, if required. 7. For next conversion, go to step 1 or step 2 as required. Acquisition time is the time that the A/D module s holding capacitor is connected to the external voltage level. Then there is the conversion time of 12 T AD, which is started when the GO bit is set. The sum of these two times is the sampling time. There is a minimum acquisition time to ensure that the holding capacitor is charged to a level that will give the desired accuracy for the A/D conversion. Page 61

TASK #1 Consider two LED s connected to any of the ports. Write a program to flash LED1 for every 1sec and flip the digital output of LED2 using interrupt with the switch connected to the interrupt pin. Consider an interrupt to flip LED2 every time a rising edge is detected on the interrupt pin. Meanwhile, LED1 will continue to flash. Circuit Design Current Limiting Resistor Let I = LED forward current in Amps (from LED datasheet), V f = LED forward voltage drop in Volts (from LED datasheet) and V = microcontroller output pin voltage. R = V V f / I = Design Implementation GPIO and interrupt selection Algorithm / Program flow Page 62

Source code #1 Testing and Verification (i) Check the output using Logic Analyzer in MPLAB IDE / implement the circuit in PROTEUS. (ii) Implement the circuit in development board and verify the task. Discussion & Inference Page 63

TASK #2 Write a simple program in C language to convert analog voltage connected to ADC pin to digital signal using ADC module in PIC. Use 8 LEDs to flash the converted values. Circuit Design Algorithm / Program flow Page 64

Source code #2 Testing and Verification Implement the circuit in PROTEUS and verify the task. Discussion & Inference Page 65

ADDITIONAL TASK (Optional) Write a simple program in C language to measure temperature using LM35 and display in LCD. Circuit Design Source code Page 66

Testing and Verification Discussion & Inference Page 67

UNDERSTANDING & LEARNING Prepared by: Name: Reg. No.: Experiment Date: ASSESSMENT Report Submission Date: Submission Delay:... Student Task Max.Marks Graded Marks Pre-lab Preparation 10 Program flow / logic 10 Design / Implementation 10 Signature Post-lab / Viva-voce 10 Total 40 Page 68