EEE305 Microcontroller Systems Lecture 9B: GPIO on the Arduino Teaching resources are at www.eej.ulst.ac.ukwww.eej.ulst.ac.uk My office 5B18, telephone.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

Electrical team Arduino tutorial I BY: JOSHUA arduini
Lecture 1 – Arduino Basics
Lab7: Introduction to Arduino
What is Arduino?  Arduino is a ATMEL 168 micro-controller kit designed specially for small projects  User friendly IDE(Integrated Development Environment)
How to use Arduino By: Andrew Hoffmaster.
Slides created by: Professor Ian G. Harris PIC Development Environment MPLAB IDE integrates all of the tools that we will use 1.Project Manager -Groups.
ARM development environment Modified Content Philips LPC2106 ARM chip ARM target board PSPad customised development environment Troubleshooting.
And cheap, yes! River Falls, WI October 30, 2010 Saint Cloud State University, MN.
Arduino Microcontrollers SREEJAA SUNDARARAJU AND R. SCOTT CARSON BME 462.
Railway Foundation Electronic, Electrical and Processor Engineering.
Microcontrollers Lecture L12.2 Section Microcontrollers Microcontrollers vs. Microprocessors Two standard architectures PIC microcontroller 68HC12.
Using PDG with e2studio: Example
EEE305 Microcontroller Systems Lecture 4: The PIC microprocessor and the Microchip C Compilers Teaching resources on on
1 Arduino Board: Arduino UNO Arduino Programing Environment: Arduino 0022
Railway Foundation Electronic, Electrical and Processor Engineering.
EEE305 Microcontroller Systems Lecture 5B: Simple I/O Embedded C using PIC microcontrollers Teaching resources on on
 Main Components:  Sensors  Micro controller  Motor drivers  Chasis.
Khaled A. Al-Utaibi  What is Arduino?  Arduino Boards  Arduino Shields  Arduino Uno Hardware.
Introduction to Arduino Prepared by R. Lamond.  “Arduino is an open-source electronics prototyping platform based on flexible, easy- to-use hardware.
Embedded Programming and Robotics
Welcome to Workshop 88’s Tiny85 Class Please download Tiny core libs from: (for Arduino 1.0, not 1.5!) Unzip and.
Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Arduino John Marcoux Christopher Lesch Thomas Dodge Unless otherwise noted, all information and pictures came from:
Arduino Part 1 Topics: Microcontrollers Programming Basics: structure and variables Digital Output Analog to Digital Conversion.
EEE527 Embedded Systems Lecture 8: Practical Interrupts Ian McCrumRoom 5B18, Tel: voice mail on 6 th ring Web site:
AVR  Modern RISC architecture: Compact and FAST.  Tuned for high level languages.  Consistent architecture across entire line.  Small AVR are subsets.
Silicon Labs ToolStick Development Platform
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Ballooning Bundle. What is a Microcontroller? Small computer with a processor core, memory and programmable input/output Continuously repeats software.
Daniel Pickem and Rowland O’Flaherty 12/04/2012 Mechatronics (ME 6405) Student Lecture On Arduinos *Some slides courtesy of Eoin Brazil
Arduino. What is it? A open-source software suite and single-board microcontroller. Allows easy and affordable prototyping of microcontroller applications.
Introduction to the Arduino
ATMEL AVR 8 bit RISC MICROCONTROLLERS a general comparison.
Chapter 2 Introducing the PIC Mid-Range Family and the 16F84A The aims of this chapter are to introduce: The PIC mid-range family, in overview The overall.
Atmel AVR Jared Bevis January 14, The Power of Your Chips The main power of your chips lies in the programming language/compiler available to you.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
July 7, 2003 Slide 1 of 6 Automation, Robotics and Mechatronics Lab, SUNY at Buffalo Introduction To Programming Chetan Jadhav Talib Bhabharawala Seung-Kook.
Embedded System. What is an Embedded System? Computing systems embedded within electronic devices Hard to define – Nearly any computing system other than.
ATtiny Programming Shield for Arduino TYWu. Reference Programming-Shield-for-Arduino-1/
Main Hardware. Main PC to Board Connection via PX200 Main Hardware.
Lecture 7: Overview Microprocessors / microcontrollers.
Arduino A free development system based on Atmel AVR 8 bit microcontrollers. LB8X Tom.
Microcontrollers, Microcomputers, and Microprocessors
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
NAM S.B MDLAB. Electronic Engineering, Kangwon National University 1.
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Embedded C- Language Lets Learn fundamentals !!. An Embedded system is combination of computer hardware and software, and perhaps additional mechanical.
Electronic instrumentation Digitization of Analog Signal in TD
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
CEng3361/18 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2007 Recitation 01.
Arduino.
Lets Learn fundamentals !!
Getting Started: Building & Programming
INTRODUCTION TO ROBOTICS Part 5: Programming
IoT Milos Hampl.
Dr. Kyung Eun Park Summer 2017
Programming and Debugging with the Dragon and JTAG
Introducing the Arduino boards & some supporting modules
An Arduino Workshop A Microcontroller.
Timer and Interrupts.
Arduino and Design of Embedded Applications
Roller Coaster Design Project
CSCI1600: Embedded and Real Time Software
CSCI1600: Embedded and Real Time Software
Introduction to arduino
Introduction to Arduino IDE and Software
Course Code 114 Introduction to Computer Science
Presented By,  Mamata Yadav (BE Elex & Comm.) Vice R&D Coordinator(HW), PCRT  Payal Shah (BE Elex & Comm.)  Ananta Das (BE Elex & Comm.) R&D Team,PCRT.
Presentation transcript:

EEE305 Microcontroller Systems Lecture 9B: GPIO on the Arduino Teaching resources are at My office 5B18, telephone My

What is an Arduino? A small circuit board containing an ATMEL AVR microprocessor. AVR chips are similar to PICs Typically with a specific physical size and form factor, with the I/o pins arranged in a specific way to support many add on boards (called shields) Typically with a board loader using RS232 or USB so a programmer is not needed Typically capable of running Arduino Software, from a nice simple IDE, in a sanitised language called sketch (based on C and a tiny bit of C++) Everything is opensource and free (boards are cheap). Designed for designers and artists…

Arduino boards Now several variants, often with Italian names reflecting their Origin. See Arduino.cc for info. There are also bigger MEGA boards, and boards with ARM chips, Galileo PC compatible boards and even a PIC version that carries a PIC32 – a very powerful chip. The top two above are the more normal types – Buy from Farnell.co.uk or Maplin

The pins are labelled as shown, irrespective of what actual pins on the physical chip are – that depends on the package, surface mount, Dual in Line (DIL) and whether a 28 pin or 40 pin device. The special software environment uses the connection pins – labelled here beside the black connectors so the software “abstracts” you away from the actual chip. Arduino is meant to be used by non-specialists, artists, hobbists, and children. Nonetheless it is very convenient – even for heavyweight embedded systems. Various power options…you program them by holding down the reset button and releasing as you you download code from the PC – a bootloader Hardware of basic Arduino

The original Connection system was based on a ATMEGA168 from ATMEL but we now typically use different more modern chips. The real pin names are on the chip datasheet but users never read that – the arduino way of doing things is give the users a simple way of achieving rapid results. – even of they may not understand how things works. This works fine usually, and there is a massive online community to help if you are doing something tricky

Standardised hardware was easier to teach with. Also the Software tools were stripped down to something very simple Two buttons on the TOOLBAR, one to compile and one to download. Also a simple serial monitor on the PC allowed use of printf – using the same hardware as the bootloader. Also even the language was made simple – based on C and C++ but all the tricky stuff was abstracted out into a powerful library system. This meant that beginners could get a lot done quickly. Libraries came with examples, there are dozen of examples found under the (simple) menu system. Also every arduino program has a setup section, run once and a loop section, this continually reruns once power is applied, you don’t need a do… while(1). All (99%) Arduinos already have an LED on pin 13 So a user can get the board to do something at once

pinMode( 13, OUTPUT); // sets up PIN 13 digitalWrite(13,HIGH); // puts +5 out on pin 13 You tell the IDE which board and what clock frequency, it works out the right time delay Note that the loop function runs and runs automatically… These programs are called “sketches” and have a.ino extension. Resembles C but you don’t need to tell it abou the standard libraries. Note you MUST have a setup() and a loop() function but don’t need a main()

There are many libraries – you just ensure they are installed in the right place and they become available You access library functions using a dot ‘.’ Each library has different member functions. This resembles object orientated programming. You access library functions using a dot ‘.’ Most people grab an examlple program, guess what things mean and just modify (hack) the code to want they want.

There are 5 tabs on the IDE menu – the Help has “getting started” and “reference” sections

Actually the Arduino IDE is built on top of a complex set of software tools given away free by ATMEL. Known as AVRStudio they are analogous to Microchip’s MPLAB used to program PIC microprocessors. You can write normal C in the Arduino environment and it will work, you may need to #include and other libraries to make it function correctly. Equally valid is to use the AVRStudio direcly, it is based on the industry standard Eclipse IDE and is easily customisable. It containes a compiler, linker and a make utility which helps automate the building and programming of a hex file. Or you can use a good programming editor such as “The Programmers Notepad”. This can be customised to call the compiler and downloader directly. If you do not use a downloader you can get an AVR hardware programmer for under £20. These use a 3x2 connector which you can see on the photograph of the Arduinos in slide 3 and 4.

Interrupts in sketches You might need to read the AVR/ATMEL datasheet carefully to use the timers, but broadly speaking they are similar to the PIC. An Interrupt function in the sketch language initialises the peripheral, uses an “attachinterrupt” function and other similar functions. Note that timer0 is used by the internal delay functions so avoid using it …

There are three timers. Timer0 and timer2 are 8 bit timers, meaning they can store a maximum counter value of 255. Timer1 is a 16 bit timer, meaning it can store a maximum counter value of Once a counter reaches its maximum, it will tick back to zero (this is called overflow). This means at 16MHz, even if we set the compare match register to the max counter value, interrupts will occur every 256/16,000,000 seconds (~16us) for the 8 bit counters, and every 65,536/16,000,000 (~4 ms) seconds for the 16 bit counter. Match-Register/ The prescaler can equal 1, 8, 64, 256, and interrupt frequency (Hz) = (Arduino clock speed 16,000,000Hz) / (prescaler * (compare match register + 1))

Rather than continue with digging up the data, reading the datasheets carefully and using “googled code” we will avoid reinventing the wheel – there is a library we can use. This is the arduino way to get things done but you learn less… look at MsTimer2 is a small and very easy to use library to interface Timer2 with humans. It's called MsTimer2 because it "hardcodes" a resolution of 1 millisecond on timer2.

This function is treated as an ISR, in our miniproject it can output a multiplex pattern to the digit select lines of the 7 segment displays and poll the columns of the keypad We will want a 5millisecond interval, not a 500 millisecond interval… (After downloading the MsTimer2 library from arduino.cc) Unzip it into the libraries folder and restart the IDE