INTERFACING WITH INTERRUPTS AND SYNCHRONIZATION TECHNIQUES

Similar documents
Unit-6 PROGRAMMABLE INTERRUPT CONTROLLERS 8259A-PROGRAMMABLE INTERRUPT CONTROLLER (PIC) INTRODUCTION

Hello, and welcome to this presentation of the STM32G0 digital-to-analog converter. This block is used to convert digital signals to analog voltages

Lab 5 Timer Module PWM ReadMeFirst

LM4: The timer unit of the MC9S12DP256B/C

CSCI1600 Lab 4: Sound

Hardware Flags. and the RTI system. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

CSE 3215 Embedded Systems Laboratory Lab 5 Digital Control System

Keytar Hero. Bobby Barnett, Katy Kahla, James Kress, and Josh Tate. Teams 9 and 10 1

EE 308 Spring 2006 FINAL PROJECT: INTERFACING AND MOTOR CONTROL WEEK 1 PORT EXPANSION FOR THE MC9S12

ELCT 912: Advanced Embedded Systems

EE 308 Spring S12 SUBSYSTEMS: PULSE WIDTH MODULATION, A/D CONVERTER, AND SYNCHRONOUS SERIAN INTERFACE

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

Using Z8 Encore! XP MCU for RMS Calculation

Project Final Report: Directional Remote Control

Lab 2.2 Custom slave programmable interface

Triscend E5 Support. Configurable System-on-Chip (CSoC) Triscend Development Tools Update TM

JTAG pins do not have internal pull-ups enabled at power-on reset. JTAG INTEST instruction does not work

STELLARIS ERRATA. Stellaris LM3S8962 RevA2 Errata

AN4507 Application note

Unit level 5 Credit value 15. Introduction. Learning Outcomes

Practical Exercise. STM32F4 Discovery. Alessandro Palla

EIE/ENE 334 Microprocessors

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

COSC 3215 Embedded Systems Laboratory

Microcontrollers and Interfacing

AN0026.0: EFM32 and EZR32 Wireless MCU Series 0 Low Energy Timer

Motor Control. Consider a motor which has a maximum speed of 5000 RPM. The speed vs. duty cycle may look something like this:

Microcontrollers: Lecture 3 Interrupts, Timers. Michele Magno

CprE 288 Introduction to Embedded Systems (Output Compare and PWM) Instructors: Dr. Phillip Jones

DSP BASED SYSTEM FOR SYNCHRONOUS GENERATOR EXCITATION CONTROLL

Analog-to-Digital Converter. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

Utilizing the Trigger Routing Unit for System Level Synchronization

Improving Loop-Gain Performance In Digital Power Supplies With Latest- Generation DSCs

AN0026.1: EFM32 and EFR32 Wireless SOC Series 1 Low Energy Timer

Digital design & Embedded systems

I hope you have completed Part 2 of the Experiment and is ready for Part 3.

EE477 Digital Signal Processing Laboratory Exercise #13

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

Blackfin Online Learning & Development

Web-Enabled Speaker and Equalizer Final Project Report December 9, 2016 E155 Josh Lam and Tommy Berrueta

Programming and Interfacing

VORAGO Timer (TIM) subsystem application note

Experiment 5.A. Basic Wireless Control. ECEN 2270 Electronics Design Laboratory 1

Hardware-In-the-Loop simulator for turboprop and turboshaft engine control units

Course Introduction. Content 20 pages 3 questions. Learning Time 30 minutes

Measuring Distance Using Sound

AN3252 Application note

Figure 1. C805193x/92x Capacitive Touch Sense Development Platform

Time and Frequency Measurements for Oscillator Manufacturers

PWM Demonstration System Document

UNIVERSITY OF VICTORIA FACULTY OF ENGINEERING. SENG 466 Software for Embedded and Mechatronic Systems. Project 1 Report. May 25, 2006.

Module: Arduino as Signal Generator

Electric Bike BLDC Hub Motor Control Using the Z8FMC1600 MCU

Three-Phase BLDC Sensorless Motor Control Using the MKV4x In Quadcopter Application

Fixed-function (FF) implementation for PSoC 3 and PSoC 5LP devices

XC83x AP Application Note. Microcontrollers. intouch Application Kit - Touch Sliders V1.0,

Low Energy Timer. AN Application Note. Introduction

3.3V regulator. JA H-bridge. Doc: page 1 of 7

F²MC-8FX/16LX/16FX/FR FAMILY BLDC DRIVE WITH THE PPG

Fixed-function (FF) implementation for PSoC 3 and PSoC 5 devices

Standard single-purpose processors: Peripherals

AC Induction Motor (ACIM) Control using a Digital Signal Controller (DSC)

EE 308 Lab Spring 2009

ECE251: Tuesday October 3 0

dspic30f Quadrature Encoder Interface Module

Exercise 3: Sound volume robot

CS 354R: Computer Game Technology

EE 307 Project #1 Whac-A-Mole

Power Factor Correction in Digital World. Abstract. 1 Introduction. 3 Advantages of Digital PFC over traditional Analog PFC.

Designing with STM32F3x

Outlines. Examples. Hardware Interface. What s Embedded Systems? Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

PWM research and implementation on MCS-51

Mechatronics Laboratory Assignment 3 Introduction to I/O with the F28335 Motor Control Processor

Select the single most appropriate response for each question.

UM2068 User manual. Examples kit for STLUX and STNRG digital controllers. Introduction

Electronic Instrumentation ENGR-4300 Fall 2004 Section Experiment 7 Introduction to the 555 Timer, LEDs and Photodiodes

IZ602 LCD DRIVER Main features: Table 1 Pad description Pad No Pad Name Function

EEL 4744C: Microprocessor Applications Lecture 8 Timer Dr. Tao Li

Fall 2015 COMP Operating Systems. Lab #7

Course Introduction. Purpose. Objectives. Content 26 pages 4 questions. Learning Time 40 minutes

Problem Points Check off 1 / 15 /2 2 / 20 /2 3a / 10 /2 3b / 25 /2 3c / 20 /2 /90 /10 Total /100

Reading Assignment. Timer. Introduction. Timer Overview. Programming HC12 Timer. An Overview of HC12 Timer. EEL 4744C: Microprocessor Applications

Ultra-Low Duty Cycle MAC with Scheduled Channel Polling

Lab 1.1 PWM Hardware Design

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Evaluation of CPU Frequency Transition Latency

Digital-to-Analog Converter. Lab 3 Final Report

AN3332 Application note

CHAPTER III THE FPGA IMPLEMENTATION OF PULSE WIDTH MODULATION

Vocal Command Recognition Using Parallel Processing of Multiple Confidence-Weighted Algorithms in an FPGA

Brian Hanna Meteor IP 2007 Microcontroller

Portland State University MICROCONTROLLERS

Class #6: Experiment The 555-Timer & Pulse Width Modulation

Data Analysis and Numerical Occurrence

The physics of capacitive touch technology

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

Motor Control using NXP s LPC2900

ArbStudio Triggers. Using Both Input & Output Trigger With ArbStudio APPLICATION BRIEF LAB912

Using the HCS08 TPM Module In Motor Control Applications

Debugging a Boundary-Scan I 2 C Script Test with the BusPro - I and I2C Exerciser Software: A Case Study

Transcription:

Faculty of Engineering INTERFACING WITH INTERRUPTS AND SYNCHRONIZATION TECHNIQUES Lab 1 Prepared by Kevin Premrl & Pavel Shering ID # 20517153 20523043 3a Mechatronics Engineering June 8, 2016

1 Phase I 1.1 Software Design The flow chart (Figure 1 on page 3) illustrates the software design for Phase I portion of the lab requirement. The program starts off with initializations of two timers that are controlled separately by two buttons. The program then does nothing until an interrupt occurs, timer interrupt or button interrupt. 1.2 Synchronization Method The two synchronization methods used for Phase I were tight polling and interrupts. Tight polling technique uses constant checking of the peripheral states to determine the whether a state has changed or not. For example of a button press, the program constantly checks if that button is pressed, in a loop and sets a flag to acknowledge it if the button state was indeed changed. Interrupt technique uses the IRQ to recognize the button press, which allows the CPU to be free to perform other tasks. For the same example of the button press, the program could be running calculations or other background tasks, however when the button is pressed the state of the program is saved along with the program counter and other registers, to perform the ISR for that button press, in Phase I that is to start the timer as illustrated in Figure 1. When the ISR is finished the state of the program is restored back to continuing the processes that we done before the interrupt. Table 1 summarizes the main differences between the two synchronization methods. Table 1: Tight Polling vs Interrupt Synchronization Occasional Interrupt Efficiency depends depends Ease of Implementation simple hard Ease of Debugging simple hard As seen from the Table 1, occasional synchronization is easier to implement and easier to debug due to the fact that no workaround for printf statements 1

required. Additionally, the implementation is simply a while loop with peripheral state checks. Interrupts, however require workaround for printf as printf is also an interrupt. As well as the implementation is not intuitive, as an ISR setup and register manipulation is required. Although the main difference between the two is efficiency as that depends in the application. Interrupt technique is better for asynchronous, urgent and infrequent tasks which do not create a ton of overhead as not buffer is required to service lots of interrupts in a small window of time. Tight polling is better for synchronous, non urgent frequent tasks but uses a lot of CPU cycles which drives power consumption. In this project, the interrupt technique is chosen as it is easier to implement the timing design with timer interrupts. Thus, the buttons that are asynchronous, infrequent, and urgent, are chosen to be implemented as interrupts. 1.3 Debugging During Phase I, one problem that occurred was a one second delay for LED and 7 segment display to start illustrating the state of the DIP switches after any button is pressed. This was a concern because each button sequence should take 8 seconds for the full cycle, while the current implementation was taking 9 seconds. It was discovered while testing the reset of the cycle when the button is pressed again to make sure that the new DIP switch state is displayed. The specific test involved setting up the switches such that the first is different state and the button is pressed the second time when the LED or 7 segment display shows the second DIP switch state. This should immediately reset to the first state of the DIP switches, but the test failed. To find the route cause the debugger in the IDE was used to step through the program to determine the flow of events, and the problem was determined to be in the implementation of button and timer interrupt, as the button would save the state of the DIP switches and start the corresponding timer, instead of showing the first state and then starting the timer. 2

Figure 1: Phase I software design 3

2 Phase II 2.1 Software Specification Phase II implementations of occasional and interrupt synchronization techniques are described in the flow charts below (Figures 2a and 2b). (a) Interrupt (b) Occasional Figure 2: Phase II software design implementation 2.2 Experimental Results and Analysis The two synchronization methods are tested by varying the pulse period, duty cycle, and granularity of the background task. The objective is to analyze these variables with respect to latency and number of missed tasks for the both techniques. All plots in this section are based on data from an average of 5 samples per combination of variables to have statistical determination. Each of these plots had one variable held constant in order to find the relationship between 4

the other two. The constant granularity, period, and duty cycle used are 81, 5, and 6, respectively. The number of missed pulses is seen in Figure 3a and Figure 3b. The number of missed cycles were tested against the period and duty cycle for both interrupt and occasional polling techniques. (a) Interrupt (b) Occasional Figure 3: Period and Duty Cycle vs Missed Pulses Figure 3a and Figure 3b both share similar trends as to the interaction of period and duty cycle. As period is increased, the number of missed pulses decreases. Also, as duty cycle increases, the number of missed pulses decreases. This effect is very small for the interrupt technique. However, for occasional, the decrease in duty cycle minimizes the window for detection of pulses, thus making it easier to miss a pulse. This is seen in Figure 4a and Figure 4b. As period increases, it becomes harder to miss a pulse because the pulses become more distinct and they do not come as often. (a) Small Duty Cycle (b) Large Duty Cycle Figure 4: Occasional Synchronization EGM Pulse (Top) and Response Pulse (Bottom) The effect of period and duty cycle against latency is seen in Figure 5a and Figure 5b. In interrupt technique, the period had the largest effect on the latency. However, occasional polling technique only duty cycle has a significant effect on the latency. The period seems to affect the latency of the interrupt 5

technique in a non-linear manner. The peak can be explained by the period aligning more or less with the constant background task time, resulting in a response latency corresponding to the alignment. (a) Interrupt (b) Occasional Figure 5: Period and Duty Cycle vs Latency Granularity is analyzed to see how it affects the latency and of synchronization techniques. The effect of granularity on latency is seen in Figure 6a and Figure 6b. Figure 6a illustrates that granularity has little to no effect on the latency of the interrupt technique. This is because background tasks are interrupted when a pulse is created so the granularity is not relevant to the latency. In the occasional polling technique, the latency tends to oscillate as the granularity is changed. This is because the background tasks take a constant amount of time, as determined by the granularity. Different values of granularity will align the occasional pulse checks with the pulses better than other values. This is made clear in Figure 7, as the latency peak varies with both the period and the granularity. Granularity is also compared against the number of missed pulses for both techniques (Figures 8a and 8b). Figure 8a illustrates that granularity has no effect on the number of missed pulses for the interrupt synchronization technique. This is because the background task gets interrupted when a pulse arrives so the granularity does not matter. For occasional polling, however, the granularity makes a large difference. Since occasional polling only checks for pulses between tasks, the length of the task determines whether a pulse will be missed or not. If the length of a task aligns better with the pulse period, then the number of missed pulses will go down significantly. This relationship 6

(a) Interrupt (b) Occasional Figure 6: Duty Cycle and Granularity vs Latency Figure 7: Period and Granularity vs Latency for Occasional is made clear in Figure 9, as the peak of missed pulses varies both with the period and the granularity. 2.3 Conclusions The criteria used to compare the synchronization techniques was minimizing latency and number of missed pulses. In this, the interrupt technique performed significantly better than the occasional polling technique in terms of both latency and number of missed pulses. This makes sense, as the interrupt technique is designed to respond to pulses immediately, whereas the occasional polling technique will only check in between tasks. For the interrupt technique, the duty cycle was found to have a very in- 7

(a) Interrupt (b) Occasional Figure 8: Duty Cycle and Granularity vs Missed Pulses Figure 9: Period and Granularity vs Missed Pulses for Occasional significant effect on both the latency and the number of missed pulses. The granularity also had no discernible effect on the latency on the number of missed pulses either which makes interrupt technique so valuable. The period had the greatest effect on the number of missed pulses and the latency. The higher the period, the better the results for latency and missed pulses. 8

3 Contribution and Reflection Kevin s contribution to the lab was figuring out how to get the button interrupt service routine to work. He also figured out how to do a lot of interfacing with the Altera board. Getting the lights to flash in the correct order was done using a technique that he conceived of. Also discussed with Pavel on the best programming approaches for most aspects of the lab. Data collection and analysis for phase 2 was done by Kevin. He also created plots comparing period, duty cycle, granularity, missed pulses and latency in MATLAB. The most important learning outcome from Kevin s lab experience was learning about interrupt service routines and the interaction between period, duty cycle, and granularity in terms of the reliability of an interrupt service routine. Pavel s contribution involved the software design of part one that was reviewed and revised with Kevin. Along with timer set up and integration for phase I. He also worked on debugging the project due to moving it from N: to C: drives as well as kept updated version control through git. Pavel in collaboration with Kevin for design approach completed the code for phase II which was used for data collection and analysis by Kevin. Pavel learned how to interface with the Altera Library, and make changes to FPGA hardware for specific design decisions, for example interrupt edge detection for EGM pulses set to any. As well as the different implementation techniques for design based synchronization methods. 9