Laboratory: Introduction to Mechatronics

Similar documents
Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 1.

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Lecture (02) PIC16F84 (I)

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

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

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

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

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

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

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

DERTS Design Requirements (1): Microcontroller Architecture & Programming

8051 Microcontroller

Chapter 11: Interrupt On Change

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

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

Microcomputer Architecture and Programming

EC4205 Microprocessor and Microcontroller

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

SH69P48A EVB. Application Notes for SH69P48A EVB SH69V48A JP2 J4(ICE_J4) S1 IDD TEST JP1 74HC273 JP4 JP3 74HC273 JP6 STKOVE JP7 SW1 J5(ICE_J5)

Lecture (04) PIC 16F84A programming I

The University of Texas at Arlington Lecture 5

SH69P55A EVB. Application Note for SH69P55A EVB SH69P55A EVB SH69V55A

Laboratory 10. Programming a PIC Microcontroller - Part II

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

Lecture (03) PIC16F84 (2)

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

Introduction to ARM LPC2148 Microcontroller

8051 Microcontroller

Micro II and Embedded Systems

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

Laboratory 9. Programming a PIC Microcontroller - Part I

_ V Intel 8085 Family In-Circuit Emulation. Contents. Technical Notes

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

Z8 Encore! XP F1680 Series 8-Bit Flash Solution with Extended Peripherals

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

Lecture 1. Course Overview and The 8051 Architecture

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

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

Embedded System Design

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

Microchip 18F4550 Interface, Signal conditioning, USB, USB- RS-232, 16x2 LCD Interface

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

Chapter 2 Sections 1 8 Dr. Iyad Jafar

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Hello, and welcome to this presentation of the STM32 Reset and Clock Controller.

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

ME 6405 Introduction to Mechatronics

Microcontroller Overview

Programming 8-bit PIC Microcontrollers in С

I/O Ports with Interrupt-on-Change (IOC)

Embedded Systems Programming and Architectures

8051 Microcontroller Interrupts

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

AKKON USB CONTROLLER BOARD

Fig 1. Block diagram of a microcomputer

ME 515 Mechatronics. A microprocessor

Bolt 18F2550 System Hardware Manual

Module 2. Embedded Processors and Memory. Version 2 EE IIT, Kharagpur 1

PIC 16F84A programming (II)

Department of Electronics and Instrumentation Engineering Question Bank

These 3 registers contain enable, priority,

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system.

Table of Contents COMPANY PROFILE 1-1 SECTION 1. INTRODUCTION 1-1

3. The MC6802 MICROPROCESSOR

Development Hardware. Target Board and In-circuit Debugger

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

SH69P21 EVB. Application Note for SH69P21 EVB SH69P21 EVB SH69P21

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

Goal: We want to build an autonomous vehicle (robot)

INTERFACING HARDWARE WITH MICROCONTROLLER

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

1. About this document General information Board layout Testing this product Circuit description...

EMBEDDED SYSTEMS COURSE CURRICULUM

Mod-5: PIC 18 Introduction 1. Module 5

EEE394 Microprocessor and Microcontroller Laboratory Lab #6

PIC 28 Pin Board Documentation. Update Version 5.0

PIC Microcontroller Introduction

CHAPTER 1 - World of microcontrollers

Section 8. Reset HIGHLIGHTS. Reset. This section of the manual contains the following major topics:

Introduction to the SX Microcontroller

Sencer Yeralan and Helen Emery Gainesville, Florida January 2000

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

CEIBO FE-51RD2 Development System

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

History and Basic Processor Architecture

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

DEV-1 HamStack Development Board

Flow Charts and Assembler Programs

Input/Output Ports and Interfacing

Manual of Board ET-PIC STAMP 18F8722-K22 ET-PIC STAMP 18F8722-K22

3.1 Description of Microprocessor. 3.2 History of Microprocessor

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

Introduction to Microcontroller Apps for Amateur Radio Projects Using the HamStack Platform.

Computer Hardware Requirements for Real-Time Applications

AX-12. PIC12F675 microcontroller Activity board

Interconnects, Memory, GPIO


Transcription:

Laboratory: Introduction to Mechatronics Instructor TA: Edgar Martinez Soberanes (eem370@mail.usask.ca) 2017-02-9 Lab 3. LED Control and Interruptions.

Lab Sessions Lab 1. Introduction to the equipment and tools to be used in the lab, which include the development board (PICDEM 2 Plus),the microcontroller (PIC 16F1937), and the USB Oscilloscope (Analog Discovery). Lab 2. Experiment 2: Transistor Operation, Experiment 3: Passive filters, and an Op-Amp circuit experiment. Lab 3. Experiment 7: LED Control and Interruptions. Lab 4. Experiment 10: Stepper Motor Motion Control. Lab 5. Experiment 11: DC Motor Speed Control Using PWM. Lab 6. Experiment 12: Closed Loop DC Motor Position Control. 2

Lab 1. Outline Objective. Lecture o o o o o Introduction. Oscillator Module. Input/output Ports. Interrupts Programing on MPLAB X Time for the experiments. 3

Objective Objectives o Learn how to program the PIC 16F1937 using MPLAB X. o Design a program to control 4 LEDs using the microcontroller (PIC) and implement it in the PICDEM 2 Plus board. o Design a program with an Interrupt Service Routine and implemented in the PICDEM 2 Plus board. 4

Introduction Microcomputer systems Every computer, no matter how simple or complex, has at its heart two things: a CPU and some memory. Together, these two things are what make it possible for your computer to run programs. 5

A microcontroller is a simplified version of a similar architecture, placed on one chip. 6

Block Diagram 7

Data Memory (RAM) o Memory: 512 bbbbbbbbbb o Divided in 32 banks with 128 bytes in a bank. 12 core registers 20 Special Function Registers (SFR) Up to 80 bytes of General Purpose RAM (GPR) 16 bytes of common RAM 8

Oscillator Module Clock sources can be external or internal. o External clock sources: Quartz crystal resonator,s ceramic resonators, and RC circuits. o Internal clock sources: Two internal oscillators, with a choice of speeds selectable via software. 9

Clock source modes are selected by the FOSC <2:0> bits in the configuration Word 1. The FOSC bits determine the type of oscillator that will be used when the PIC is first powered. The oscillator module can be configured as: 1. ECL External Clock Low-Power mode (0 MHz to 0.5 MHz) 2. ECM External Clock Medium-Power mode(0.5 MHz to 4 MHz) 3. ECH External Clock High-Power mode(4 MHz to 32 MHz) 4. LP 32 khz Low-Power Crystal mode. 5. XT Medium Gain Crystal or Ceramic ResonatorOscillator mode (up to 4 MHz) 6. HS High Gain Crystal or Ceramic Resonatormode (4 MHz to 20 MHz) 7. RC External Resistor-Capacitor (RC). 8. INTOSC Internal oscillator (31 khz to 32 MHz). 10

11

The system clock speed can be selected via software by setting up the bits IRCF<3:0> of the OSCCON register. One of the following frequencies can be selected: o 32 MHz (requires 4X PLL) o 16 MHz o 8 MHz o 4 MHz o 2 MHz o 1 MHz o 500 khz (Default after Reset) o 250 khz o 125 khz o 62.5 khz o 31.25 khz o 31 khz (LFINTOSC) 12

13

Summary To set up the clock of the PIC we need to set some bits of the CONFIG1 Register and the OSCCON Register. 1. CONFIG1: FOSC bits (Choose type of clock Internal/external) 2. OSCCON: IRFC bits (Choose oscillation frequency) 14

Input/output Ports 5 ports (A,B,C,D, and E). Each port has different characteristics and number of pins. Ports are bidirectional (Input/Output). Multi-functional. Some pins are multiplexed with an alternate function. When a peripheral is enable, that pin may not work as a general input/output. 15

16 Each port has three standard registers for its operation: o TRISx registers (data direction) o PORTx registers (reads the levels on the pins) o LATx registers (output latch) Some ports may also have one or more of the following registers: o ANSELx (analog select) o WPUx (weak pull-up) o INLVLx (input level control)

Example Port A TRISA register (PORTA Data Direction Register): o Bit = 1 (pin on port A = Input) o Bit = 0 (pin on port A = Output) PORTA reads the status of the pins. o Example: x = PORTA LATA puts the content of the output latch on the port A. o Example: LATA = 0; Make all the pins of port A equal to 0 V. Note: Writes to PORTA are actually written to corresponding LATA register. Reads from PORTA register is return of actual I/O pin values. 17

18

Interrupts The interrupt feature allows certain events to pre-empt normal program flow. The following events happen when an interrupt event occurs while the GIE bit is set: o o o o o Current prefetched instruction is flushed GIE bit is cleared Current Program Counter (PC) is pushed onto the stack Critical registers are automatically saved to the shadow registers PC is loaded with the interrupt vector 0004h 19

Interrupts are disabled upon any device Reset. They are enabled by setting the following bits: o GIE bit of the INTCON register o Interrupt Enable bit(s) for the specific interrupt event(s) o PEIE bit of the INTCON register (if the Interrupt Enable bit of the interrupt event is contained in the PIE1, PIE2 and PIE3 registers) 20

21

22 Interrupt-On-Change (IOC) Port B pins can be operated as Interrupts-On-Change pins. An interrupt can be generated by detecting a signal that has either a rising edge or falling edge. To enable the IOC pins the IOCIE bit of the INTCON register must be set.

Individual Configuration IOCBPx bit in the IOCBP register has to be set to detect a rising edge. IOCBNx bit in the IOCBN register has to be set to detect a rising edge. The IOCBFx bits located in the IOCBF register are status flags that correspond to the interrupt-on-change pins of port B. 23

24 Programing on MPLAB X MPLAB X Interface. Programing on C language. Compiler XC8 Programing the PIC via PicKit 3 Programer

Assembly VS C Language // Initializing Port A TRISA = 0b00111000 LATA = 0x00 25

Programing the PIC 26

Thanks 27