Digital INPUTS/OUTPUTS and interrupts

Slides:



Advertisements
Similar presentations
Khaled A. Al-Utaibi Interfacing an LED The Light Emitting Diode (LED) Applications DC Characteristics & Operation Interfacing to.
Advertisements

Button Input: On/off state change Living with the Lab Gerald Recktenwald Portland State University
EMS1EP Lecture 6 Digital Inputs
Panasonic EVE-KC2F2024B 24 pulses per revolution 6mm diameter flattened output shaft output type: quadrature (incremental) minimum life: 15,000 rotations.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Digital Outputs 7-Segment Display
Group 7 Jhonathan Briceño Reginal Etienne Christian Kruger Felix Martinez Dane Minott Immer S Rivera Ander Sahonero.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Embedded Programming and Robotics
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
PHY 202 (Blum)1 Analog-to-Digital Converter and Multi-vibrators.
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Digital Electronics Board-of-Education : Input. Board of Education - Input This presentation will explain, both from a hardware and software perspective,
Code The Arduino Environment.
12/16/  List the elements of 8255A Programmable Peripheral Interface (PPI)  Explain its various operating modes  Develop a simple program to.
Interrupt On a very basic level, an interrupt is a signal that interrupts the current processor activity. It may be triggered by an external event (change.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Embedded Programming and Robotics Lesson 11 Arduino Interrupts 1.
Embedded systems and sensors 1 Part 2 Interaction technology Lennart Herlaar.
US ADC (Analogue to Digital Conversion) and DAC (Digital to Analogue Conversion) 4 Weeks 3 Credits.
Microcontroller basics Embedded systems for mortals.
GUIDED BY PROFFESOR NILESH DESAI GROUP NO:-8 CHANDRASHIKHA SINGH( ) KURUP SHUBHAM VALSALAN( ) SAURAV SHUBHAM( )
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
40106B Schmitt Trigger (A way of switch De-Bouncing)
Basics of Logic gates - Part 1
Assist. Prof. Rassim Suliyev - SDU 2017
User-Written Functions
Microcontroller basics
8085 Interrupts LAKSHMI.B.E..
Microcontroller basics
Computer Architecture
Callback TYWu.
Interrupts In 8085 and 8086.
3.0 ARDUINO WORKSHOP PRESENTATION FOR STUDENTS IN 4º DEGREE OF COMPULSORY SECONDARY EDUCATION 3.0.
Interrupt.
Lighting LEDs with a RASPBERRY PI
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
How to avoid catching things on fire.
Advisor: Prof. Gandhi Puvvada
ARDUINO     What is an Arduino? Features 14 Digital I/O pins 6 Analogue inputs 6 PWM pins USB serial 16MHz Clock speed 32KB Flash memory 2KB SRAM.
Week 6: Microcontrollers II
Internet-of-Things (IoT)
Interrupts, Tasks and Timers
Advisor: Prof. Gandhi Puvvada
1 Code
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
Interrupts Interrupt is a process where an external device can get the attention of the microprocessor. The process starts from the I/O device The process.
Welcome to Digital Electronics using the Arduino Board
Programmable Interval timer 8253 / 8254
Implementing Switches Using Interrupts
Programmable Interval timer 8253 / 8254
Arduino Part 4 Let there be more light.
Multi-vibrators
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
ECE 352 Digital System Fundamentals
UNIT 7: INFRARED SENSORS
UNIT 5 Analog signals.
Logic Gates AIM: To know the different types of logic gate
COMP3221: Microprocessors and Embedded Systems
UNIT 12 SERIAL INTERFACE.
UNIT 1 First programs.
UNIT 12 COMMUNICATIONS.
UNIT 7: INFRARED SENSORS
The Programmable Peripheral Interface (8255A)
Surjo Dutta and David Friedman
Interrupts.
Presentation transcript:

Digital INPUTS/OUTPUTS and interrupts UNIT 2 Digital INPUTS/OUTPUTS and interrupts

Have a close look at interrupts Aim and Agenda of unit 2 Clarify a few ideas on controlling digital devices and explain what pull-up and pull-down resistors are. Have a close look at interrupts The aim of the presentation The agenda of the presentation Explain what is active high logic levels in digital OUTPUTs Explain differences between PULL-UP and PULL-DOWN resistors Give the basic knowledge about interrupts 2

Digital Outputs AND LOGIC levels We always talk about setting a level “1” (+5 V) every time we want to turn something on and use level “0” (0 V) for turning something off Can’t we do it the other way round? YES!!!! Both level “1” and level “0” are equally representative. The anode has to be positive compared to the cathode to turn on Send a “1” (+5 V) through D4 (pin 7) to the cathode to turn on a LED we have to send a “1” (+5 V) through D4 (pin 7) Send a “0” (0 V) through D4 to the cathode in the circuit as the anode is connected to +5 V through the resistor. 3

Digital Outputs AND LOGIC levels We always talk about setting a level “1” (+5 V) every time we want to turn something on and use level “0” (0 V) for turning something off Can’t we do it the other way round? YES!!!! Both level “1” and level “0” are equally representative. The anode has to be positive compared to the cathode to turn on Send a “1” (+5 V) through D4 (pin 7) to the cathode to turn on a LED we have to send a “1” (+5 V) through D4 (pin 7) Send a “0” (0 V) through D4 to the cathode in the circuit as the anode is connected to +5 V through the resistor. 4

DIGITAL INPUTS; PULL-UP AND PULL-DOWN RESISTORS The most basic and economical digital input peripherals are just simple pushbuttons and switches Pushbutton has been connected to D2 (pin 5) which is apparently configured as an input. When you press the pushbutton D2 pin connects up with GND (0 V) and is therefore at “0” level When you press the pushbutton D2 pin connects up with 5 V and is therefore at “1” level WHAT HAPPENS TO THE PINS IF WE DON’T PRESS EITHER OF THE PUSHBUTTONS IN THE TWO CIRCUITS? 5

DIGITAL INPUTS; PULL-UP AND PULL-DOWN RESISTORS Absolutely none. The D2 remains disconnected in both cases. We say it’s “floating”. Which one wins: level “1” or level “0”? There’s really no definite answer Sometimes the “1” comes out on top and other times the “0” 6

DIGITAL INPUTS; PULL-UP AND PULL-DOWN RESISTORS As the electrics are concerned, the best thing to do is add a resistor to the circuit. Connected to the positive +5 V it’s called a resistor or “PULL-UP” Connected to GND or 0 V, it’s called “PULL-DOWN” 7

pinMode (n, INPUT_PULLUP) DIGITAL INPUTS; PULL-UP AND PULL-DOWN RESISTORS How does Arduino help us? It provides us with the pull-up resistor and this saves you having to install one externally in your circuits. The resistor has been integrated in the Arduino controller. You can configure this option using this function: pinMode (n, INPUT_PULLUP) n represents the input pin you want to link to the corresponding pull-up resistor. 8

INTERRUPTS An interrupt doesn’t necessarily mean that the controller stops altogether; it drops the task it’s doing at that moment and executes another one How do we cause an interrupt? The most common way is for external peripherals to send signals through certain controller pins Arduino UNO has two different interrupt sources or pins: D2/INT0 and D3/INT1 9

INTERRUPTS What happens when the controller receives an interrupt? The controller is executing its usual main program. At some point a peripheral requests and causes an interrupt. The controller suspends the main program and goes on to execute a program to deal with the event, also known as an ISR (Interrupt Service Routine). Once the execution of the interrupt handler is finished, the controller returns to the main program. The execution is renewed from where it left off. 10

attachInterrupt(pin, ISR, modo); INTERRUPTS To manage and use the Arduino UNO interrupts, you’ve got four functions at your disposal Function attachInterrupt() It configures how an interrupt should work. Syntax: attachInterrupt(pin, ISR, modo); pin: In the case of Arduino UNO it could be INT0 (D2) or INT1 (D3) ISR: this is the name of the routine or function that must be executed each time the interrupt happens. mode: This is when the interrupt should be triggered: LOW: when the pin sends through a “0” level. CHANGE: when a change of status in the pin is detected. RISING: when the pin detects a rising edge (“0” -> “1”). FALLING: when the pin detects a falling edge (“1”-> “0”). 11

detachInterrupt(pin); INTERRUPTS Function detachInterrupt() Turns off an interrupt. Syntax: detachInterrupt(pin); pin: In the case of Arduino UNO it could be INT0 (D2) or INT1 (D3) Function interrupts() This turns on the interrupts. Think of it as a kind of general authorization for the interrupts that have been previously configured through attachInterrupt(). Syntax: interrupts(); 12

INTERRUPTS Function noInterrupts() This turns off all the interrupts. Think of it as a kind of general prohibition that prevents all the interrupts from functioning Syntax: noInterrupts(); 13

INTERRUPTS Limitations Advantages delay() and millis() functions don’t work if they’re already in the interrupt service routine You can’t transfer parameters to an interrupt service routine and the ISR can’t return anything either During the execution of the interrupt service routine function, the controller suspends the execution of the main program. Your main program can be doing whatever you like but when the signal reaches it, then, and only then, the controller “responds” to the interrupt and performs the corresponding task. This means is that there’s no down time because the controller is always doing something useful- as if it were doing a couple of tasks at the same time 14

UNIT 2 Digital INPUTS/OUTPUTS and interrupts Thank You