Suleyman Demirel University 20151 CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Advertisements

Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
How to use Arduino By: Andrew Hoffmaster.
ECE 265 – LECTURE 14 Analog Signal Acquisition The A/D converters 5/14/ ECE265.
Data Acquisition Concepts Data Translation, Inc. Basics of Data Acquisition.
Intro to the Arduino Topics: The Arduino Digital IO Analog IO Serial Communication.
Analog/Digital Subsystem
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
Introduction to Arduino Programming January MER-421:Mechatronic System Design.
1 Lab2: A/D Converter. 2 This circuit connects a variable voltage to an A/D port on the AVR mcu. Your software running on the AVR mcu will read the digital.
5-1 Analogue Input/Output Many sensors/transducers produce voltages representing physical data.  To process transducer data in a computer requires conversion.
Analogue Input/Output
Arduino Week 3 Lab ECE 1020 Prof. Ahmadi. Objective Data acquisition (DAQ) is the process of measuring an electrical or physical phenomenon such as voltage,
Digital I/O Connecting to the Outside World
Analog and Digital Measurements living with the lab 14 digital input / output pins 6 analog input pins © 2011 LWTL faculty team.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Basic Circuits – Lab 2 Arduino and Sensors Xmedia Spring 2011.
Arduino Part 1 Topics: Microcontrollers Programming Basics: structure and variables Digital Output Analog to Digital Conversion.
Dean Brock, Rebecca Bruce and Susan Reiser, CCSC SE 2009 Using Arduino Material taken from Todbot blog Bionic Arduino Todbot blog Bionic ArduinoTodbot.
Ballooning Bundle. What is a Microcontroller? Small computer with a processor core, memory and programmable input/output Continuously repeats software.
Digital to Analogue Converter
Typical Microcontroller Purposes
Khaled A. Al-Utaibi  The Push Button  Interfacing Push Buttons to Arduino  Programming Digital Inputs  Working with “Bouncy”
Sparkfun Electronics ATtiny85 Arduino Quick Reference Sheet
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 1 Getting Started to Arduino.
智慧電子應用設計導論(1/3) Arduino MEGA 2560
Analog Capture- Port E. Digital to Analog and Analog to Digital Conversion D/A or DAC and A/D or ADC.
ARDUINO 1. Basics  Comments  /* * Blink * * The basic Arduino example. Turns on an LED on for one second, * then off for one second, and so on... We.
Analog to Digital Converter (ADC)
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Arduino Microcontroller Technical Details : Arduino (UNO R3) micro-controller ATmega 328 CPU (“industry-standard” micro-controller CPU) ?? MHz clock speed.
Microcontroller basics Embedded systems for mortals.
Lecture 9: Introduction to Arduino Topics: Arduino Fundamentals, Bean Date: Mar 22, 2016.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Electronic instrumentation Digitization of Analog Signal in TD
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
Lecture Notes / PPT UNIT III
Arduino Programming. THE ARDUINO IS A MICROCONTROLLER – A LOW COST, LOW PERFORMANCE COMPUTER.
Hacking on Arduino George Patterson
Components of Mechatronic Systems AUE 425 Week 2 Kerem ALTUN October 3, 2016.
Assist. Prof. Rassim Suliyev - SDU 2017
Application Case Study Security Camera Controller
Val Manes Department of Math & Computer Science
Environment Temperature Monitor
Microcontroller basics
AVR ATMEGA 8 MICRO-CONTROLLER
Analog Comparator An analog comparator is available on pins PE2(AIN0), PE3(AIN1) The comparator operates like any other comparator. -when (+) exceeds (-)
Arduino & its hardware interfacing
Microcontroller basics
UCD ElecSoc Robotics Club 2017/2018
Lab 1: Arduino Basics Topics: Arduino Fundamentals, First Circuit
INC 161 , CPE 100 Computer Programming
Arduino - Introduction
Analog Input through POT
The Arduino Microcontroller: Atmel AVR Atmega 328
Introduction to Arduinos
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.
Digital-to-Analog & Analog-to-Digital Conversion
Digital Acquisition of Analog Signals – A Practical Guide
PIC18F458 Analog-to-Digital
EET 2261 Unit 14 INCOMPLETE Analog-to-Digital Conversion (ADC) & Digital-to-Analog Conversion (DAC) Read. Homework #13 and Lab #13 due next week. Quiz.
CSCI1600: Embedded and Real Time Software
Arduino : Introduction & Programming
ADC and DAC Programming in AVR
CSCI1600: Embedded and Real Time Software
CTY SAR FCPS Shawn Lupoli, Elliot Tan
UNIT 5 Analog signals.
Introduction to Arduino
Introduction to Arduinos
Interrupts.
Presentation transcript:

Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS

Suleyman Demirel University ATMEGA328P ARCHITECTURE In-System Programmable (ISP) flash to store programs holds run-time variables store any data 23 general purpose input/output lines three Timer/Counters with compare modes 2-wire Serial Interface Serial Peripheral Interface6-channel 10-bit Analog/ Digital Converter All peripheral devices are controlled via sets of specific registers, each of which is connected to the 8-bit data bus

Suleyman Demirel University 20153

4 General-Purpose Input/Output Basic operation to output a digital signal on pin n of port x is to: 1. write a ‘1’ into DDRx_Bitn, then 2. write either a ‘1’ or ‘0’ into Portx_Bitn. Basic operation to input a digital signal on pin n of port x is to: 1. write a ‘0’ into DDRx_Bitn, then 2. read the value out of Pinx_Bitn.

Suleyman Demirel University INTERNAL PULL-UP RESISTOR Generally, when a port pin is not being used, the microcontroller will default the pins to input, in order to save on power. Floating pin data can lead to strange and unexpected behavior. Very standard method for managing unused input pins is to connect a fairly large resistance between the pin and the power supply.

Suleyman Demirel University PORT B (8-13) I/O REGISTERS pinMode(pin, mode); //Input sample code: pinMode(8, INPUT); //Sets DDRB0 to 0 digitalRead(8); //Reads PINB0 //Output sample code: pinMode(8, OUTPUT); //Sets DDRB0 to 1 digitalWrite(8,HIGH); //Sets PORTB0 to 1

Suleyman Demirel University Analog Signals  Potentiometer - a mechanical knob is used to adjust the resistance between terminals;  Thermistor - a device that changes resistance based on temperature;  Accelerometer - a device that measures the acceleration of gravity in three dimensions and outputs an associated analog value for each dimension (e.g., this is the basis behind the Nintendo Wii video-game controllers);  Ambient light sensor - a device that measure the environmental ambient light intensity and outputs an associated analog value (e.g., many laptop computers will adjust the backlight level based on the surrounding environment light level);  Microphone - a device that converts vibrations (i.e., acoustic- waves) into analog levels.

Suleyman Demirel University Analog Input Port  In order for a microcontroller to operate on the sensor outputs, an Analog-to-Digital Conversion (ADC) circuit must be used  The parallel ADC uses typical values for Vmin and Vmax where the minimum voltage is simply set to ground and Vmax is controlled externally via the user-defined reference voltage VREF.  The resistor network on the left- hand side is designed such that VREF−V2=V2−V1=V1−V0=V0  The analog voltage VA is first converted into a three-bit codeword defined by (c2c1c0), where each bit is the output of a comparator.  4 possible codewords are then passed through an encoder that outputs the final two-bit value (b1b0).

Suleyman Demirel University Analog Input Port  Arduino development board has six 10-bit ADCs, all of which are found on Port C. (A0-A5)  For generic usage of the ADC port functionality, the following steps should be addressed. Register ADCSRA needs to be enabled, started, auto trigger enabled, and an appropriate prescalar selected; Register ADCSRB needs to have the auto trigger source set to free running, so the program can read the converted value of a low-frequency sensor (which is often our application); Register ADMUX needs to have a VREF source selected, right or left justification selected, and the desired ADC channel selected; Register DIDR0 should have the input pin associated with the ADC channel selected in ADMUX disabled.  Once the ADC is initialized, the program can poll the ADC output by reading the 16-bit ADC register which contains the 10-bit result

Suleyman Demirel University Analog Port Registers

Suleyman Demirel University Analog Input Port analogReference(type); Configures the reference voltage used for analog input. The options are: DEFAULT: the default analog reference of 5 volts. INTERNAL: a built-in reference, equal to 1.1 volts on the ATmega168 or ATmega328 and 2.56 volts on the ATmega8 (not available on the Arduino Mega) EXTERNAL: the voltage applied to the AREF pin (0 to 5V only) is used as the reference. analogRead(pin); Reads the value from the specified analog pin. The Arduino Uno board contains a 6 channel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 volts into integer values between 0 and This yields a resolution between readings of: 5 volts / 1024 units or, 4.9 mV per unit. The input range and resolution can be changed using analogReference(). It takes about 100 microseconds to read an analog input, so the maximum reading rate is about 10,000 times a second.

Suleyman Demirel University Reading Analog Value int analogPin = A0; // potentiometer wiper (middle terminal) connected to // analog pin 3 outside leads to ground and +5V int val = 0; // variable to store the value read void setup() { Serial.begin(9600); // setup serial } void loop() { val = analogRead(analogPin); // read the input pin Serial.println(val); // debug value }