Analog input and output

Similar documents
Digital input and output

Due date: Sunday, December 5 (midnight) Reading: HH section (pgs ), mbed tour

Interfacing Analog to Digital Data Converters. A/D D/A Converter 1

NC Eng Systems. Block Diagrams. Learning Outcome 1. MjD

MIE 402: WORKSHOP ON DATA ACQUISITION AND SIGNAL PROCESSING Spring 2003

Lab 2: A/D, D/A, and Sampling Theorem

Analogue Inputs Resolution Assignment

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR NPTEL ONLINE CERTIFICATION COURSE. On Industrial Automation and Control

Re: ENSC 370 Project Physiological Signal Data Logger Functional Specifications

Workshop III: Analog and Sensors

The Micropython Microcontroller

Alice EduPad Board. User s Guide Version /11/2017

Digital Systems Principles and Applications. Chapter 1 Objectives

Session 1 Introduction to Data Acquisition and Real-Time Control

Fig. 1 Analog pins of Arduino Mega

Choosing an Oscilloscope

RAPID SOC PROOF-OF-CONCEPT FOR ZERO COST JEFF MILLER, PRODUCT MARKETING AND STRATEGY, MENTOR GRAPHICS PHIL BURR, SENIOR PRODUCT MANAGER, ARM

A/D and D/A convertor 0(4) 24 ma DC, 16 bits

successive approximation register (SAR) Q digital estimate

Ocean Sensor Systems, Inc. Wave Staff III, OSSI With 0-5V & RS232 Output and A Self Grounding Coaxial Staff

ORM0022 EHPC210 Universal Controller Operation Manual Revision 1. EHPC210 Universal Controller. Operation Manual

Operating Instructions

Amplification. Most common signal conditioning

PRELIMINARY INFORMATION. Professional Signal Generation and Monitoring Options for RIFEforLIFE Research Equipment

Implementing a Rudimentary Oscilloscope

NanoGiant Oscilloscope/Function-Generator Program. Getting Started

Experiment 9 Analog/Digital Conversion

ELCT706 MicroLab Session #3 7-segment LEDs and Analog to Digital Conversion. Eng. Salma Hesham

Table of Contents Introduction

Troubleshooting. 1. Symptom: Status indicator (Red LED) on SSR is constant on. 2. Symptom: Output indicator (Yellow LED) on SSR is flashing.

GALILEO Timing Receiver

What to look for when choosing an oscilloscope

SignalTap Plus System Analyzer

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

SCALE & WEIGHT DISPLAYS

Ocean Sensor Systems, Inc. Wave Staff, OSSI F, Water Level Sensor With 0-5V, RS232 & Alarm Outputs, 1 to 20 Meter Staff

Experiment 2: Sampling and Quantization

Oscilloscopes, logic analyzers ScopeLogicDAQ

Log-detector. Sweeper setup using oscilloscope as XY display

LABORATORY 14: ANALOG TO DIGITAL CONVERSION USING ADC0809

Digital Effects Pedal Description Ross Jongeward 10 December 2014

B I O E N / Biological Signals & Data Acquisition

Digital Fundamentals. Introduction to Digital Signal Processing

Using SignalTap II in the Quartus II Software

Standard RS232 RS ma

Note 5. Digital Electronic Devices

9/23/2014. Andrew Costin, Tom Syster, Ryan Cramer Advisor: Professor Hack Instructor: Professor Lin May 5 th, 2014

THE NOISE PERFORMANCE OF EVALUATION BOARDS FOR A UNIVERSAL TRANSDUCER INTERFACE WITH USB CONNECTION

Technology Control Technology

Specifications. End-Point Linearity - ±5% F.S., when used with HACO SCR-speed control

International Islamic University Chittagong (IIUC) Department of Electrical and Electronic Engineering (EEE)

SUBSYSTEMS FOR DATA ACQUISITION #39. Analog-to-Digital Converter (ADC) Function Card

Analogue output module DAO 081

VBOX 3i. 100Hz GPS Data Logger (VB3i-V3) Features

Tutorial on Technical and Performance Benefits of AD719x Family

Converters: Analogue to Digital

Use xtimecomposer and xscope to trace data in real-time

Low-speed serial buses are used in wide variety of electronics products. Various low-speed buses exist in different

Troubleshooting Analog to Digital Converter Offset using a Mixed Signal Oscilloscope APPLICATION NOTE

ECE 372 Microcontroller Design

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Synchronizing Multiple ADC08xxxx Giga-Sample ADCs

Complete 10-Bit/12-Bit, 25 MHz CCD Signal Processor AD9943/AD9944

Data Conversion and Lab (17.368) Fall Lecture Outline

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Integrated Circuit for Musical Instrument Tuners

DSM GHz Linear Chirping Source

TV Character Generator

-SQA-SCOTTISH QUALIFICATIONS AUTHORITY HIGHER NATIONAL UNIT SPECIFICATION GENERAL INFORMATION

Combo Board.

DMC550 Technical Reference

VBOX III 100Hz GPS Speed Sensor. User Guide. Page 1 of 21. VBOX III SPS User Guide

Digital Electronics II 2016 Imperial College London Page 1 of 8

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Analog to Digital Converter

EDL8 Race Dash Manual Engine Management Systems

AD9884A Evaluation Kit Documentation

V6118 EM MICROELECTRONIC - MARIN SA. 2, 4 and 8 Mutiplex LCD Driver

INF4420 Project Spring Successive Approximation Register (SAR) Analog-to-Digital Converter (ADC)

Sample. Data Acquisition and Signal Conditioning. Course Manual. Course Software Version 2011 February 2012 Edition Part Number P-01

Integration of Virtual Instrumentation into a Compressed Electricity and Electronic Curriculum

Vorne Industries. 87/719 Analog Input Module User's Manual Industrial Drive Itasca, IL (630) Telefax (630)

MTL Software. Overview

INTRODUCTION TERMINAL LAYOUTS FX2N-4AD SPECIAL FUNCTION BLOCK USER S GUIDE

Digital 4 Q - Servo amplifier for brushless DC Servo motors (Trapeze)

PACSystems* RX3i Thermocouple Input Module, 12 Channels, IC695ALG412-CB

EASY-MCS. Multichannel Scaler. Profiling Counting Rates up to 150 MHz with 15 ppm Time Resolution.

SYSTEM DESCRIPTION 2.1 MAIN DISPLAY SCREEN 2.2 SYSTEM DIAGNOSTIC MENU 2.6 SETTING AND OPERATING INSTRUCTIONS 2.10 TO SET DEFAULT PARAMETERS 2.

Theory and Practice of Tangible User Interfaces. Thursday Week 3: Analog Input. week. Sensor 1: Potentiometers. Analog input

Measure the value of water flow using water flow sensor and DC water pump 12 V interfacing with Arduino uno

IV 251. Signal Converter SSI => Analogue and SSI => Serial. Operating Instructions. control motion interface

Microcontrollers and Interfacing week 7 exercises

Data Converter Overview: DACs and ADCs. Dr. Paul Hasler and Dr. Philip Allen

Complete 12-Bit 40 MHz CCD Signal Processor AD9945

PCM ENCODING PREPARATION... 2 PCM the PCM ENCODER module... 4

LX3V-4AD User manual Website: Technical Support: Skype: Phone: QQ Group: Technical forum:

ME EN 363 ELEMENTARY INSTRUMENTATION Lab: Basic Lab Instruments and Data Acquisition

NI-DAQmx Device Considerations

SmartSwitch TM. Wide View Compact LCD 64 x 32 Pushbutton DISTINCTIVE CHARACTERISTICS PART NUMBER & DESCRIPTION

SPECTRO Series SPECTRO-3-30-UV-ANA. Design. SPECTRO-3 Series True Color Sensors. Product name:

MIXED-SIGNAL AND DSP DESIGN TECHNIQUES

Transcription:

Analog input and output DRAFT VERSION - This is part of a course slide set, currently under development at: http://mbed.org/cookbook/course-notes We welcome your feedback in the comments section of the course notes cookbook page. Tell us if these slides are useful, if you would use them to help run lessons, workshops or training, and how you d improve them. Written by R. Toulson (Anglia Ruskin University) and T. Wilmshurst (University of Derby), (c) ARM 2011 An accompanying textbook is also being considered if there is interest 1

Analog input and output Introduction to analog signals and data Concepts of analog-to-digital conversion Analog inputs on the mbed Reading and logging data from analog inputs Concepts of digital-to-analog conversion Analog output with the mbed Generating output waveforms 2

Introduction to analog data Microcontrollers are often required to interface with analog signals They must be able to convert input analog signals, for example from microphone or temperature sensor, to digital data They must also be able to convert digital signals to analog form, for example if driving a loudspeaker or dc motor We will first consider conversion from analog-to-digital, before later looking at digital-to-analog conversion 3

Concepts of analog-to-digital conversion An analog-to-digital convertor (ADC) is an electronic circuit whose digital output is proportional to its analog input Effectively it "measures" the input voltage, and gives a binary output number proportional to its size The input range of the ADC is usually determined by the value of a voltage reference 4

Concepts of analog-to-digital conversion The conversion is started by a digital input, called here SC Voltage Reference + It takes finite time, and the ADC signals with the EOC line when the conversion is complete Analogue Input + - Analogue to Digital Converter Digital Output (n bits) The resulting data can then be enabled onto a data bus using the OE line SC EOC OE (Start Convert) (End of (Output Enable) Conversion) Example Control Lines 5

Concepts of analog-to-digital conversion The `staircase visible in a 3-bit ADC Digital Output 111 110 101 100 011 010 001 000 0 V max Analogue Input 6

Concepts of analog-to-digital Resolution and quantisation conversion By converting an analog signal to digital, we are effectively approximating it, as any one digital output value has to represent a very small range of analog input voltages, i.e. the width of any of the steps on the staircase n. If we want to convert an analog signal that has a range 0-3.3 V to an 8-bit digital signal, then there are 256 (i.e. 2 8 ) distinct output values. Each step has a width of 3.3/256 = 12.89 mv, and the worst case quantisation error is 6.45mV. The mbed uses a 12-bit ADC. This leads to a step width of 3.3/2 12, or 0.8 mv; the worst case quantisation error is therefore 0.4 mv. 7

Concepts of analog-to-digital Sampling frequency conversion When converting an analog signal to digital, we repeatedly take a sample and quantise this to the accuracy defined by the resolution of our ADC. The more samples taken, the more accurate the digital data will be. Samples are normally taken at fixed periods (i.e., every 0.2ms) and define the rate of sampling by the sampling frequency (the number of samples taken per second). 8

Concepts of analog-to-digital Sampling frequency conversion The sample frequency needs to be chosen with respect to the rate of which the sampled data is changing. If the sample frequency is too low then rapid changes in the analog signal may not be obvious in the resulting digital data. For this reason the Nyquist sampling criterion states that the sampling frequency must be at least double that of the highest frequency of interest. 9

Concepts of analog-to-digital conversion Digital sampling of an analog signal 10

Analog inputs on the mbed The mbed has up to six analog inputs, on pins 15 to 20 11

Analog-to-digital conversion on the mbed The library functions are shown in the table below AnalogIn Functions AnalogIn read read_u16 operator float An analog input, used for reading the voltage on a pin Usage Create an AnalogIn, connected to the specified pin Read the input voltage, represented as a float in the range [0.0, 1.0] Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] operator float An operator shorthand for read() 12

Reading and logging data from analog inputs Exercise 1: Attach a potentiometer output to mbed pin 20. Start a new mbed project and enter the code below. This code will continuously display the analog input value when used with a host PC terminal application. //Reads input through the ADC, and transfers to PC terminal #include "mbed.h" Serial pc(usbtx, USBRX); AnalogIn Ain(p20); float ADCdata; int main() { pc.printf("adc Data Values... \n\r"); while (1) { ADCdata=Ain; pc.printf("%f \n\r",adcdata); wait (0.5); } } 13

Reading data from analog inputs Exercise 2: Using the four onboard mbed LEDs, write a program that will use a potentiometer input on pin 20 to continuously control how many LEDs are on. Use the following chart to define the LED control: Analog input value x LED1 LED2 LED3 LED4 x <= 0.2 0 0 0 0 0.2 < x <= 0.4 1 0 0 0 0.4 < x <= 0.6 1 1 0 0 0.6 < x <= 0.8 1 1 1 0 0.8 < x <= 1.0 1 1 1 1 14

Concepts of digital-to-analog conversion We can represent the digital-to-analog convertor (DAC) as a block diagram with a digital input, D, and an analog output, v o The output range of the DAC, v r, is the difference between the maximum and minimum output voltages, i.e. v r = v max - v min The particular output range is usually defined by a fixed voltage reference supplied to the DAC Digital control lines allow a microcontroller to setup and communicate with the DAC 15

Concepts of digital-to-analog conversion D (n-bit Digital input) + Digital to Analogue Converter Voltage Reference + - V O (Analog Output) For each digital value input to the DAC, there is a corresponding analog output value given by Control Lines 16

Concepts of digital-to-analog conversion The mbed s LPC1768 chip has a 10-bit DAC (i.e. n=10) The mbed uses its own 3.3 V power supply as voltage reference There will therefore be 2 n steps in the mbed DAC output characteristic, i.e. 1024 The step size, or resolution, is therefore be 3.3/1024, i.e. 3.2mV per bit 17

Digital-to-analog conversion on the mbed The mbed has a single analog output on pin 18 18

Digital to analog conversion on the mbed The library functions are shown in the table below AnalogOut Functions AnalogOut write write_u16 read operator= operator float() An analog output, used for setting the voltage on a pin Usage Create an AnalogOut connected to the specified pin Set the output voltage, specified as a percentage (float) Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF] Return the current output voltage setting, measured as a percentage (float) An operator shorthand for write() An operator shorthand for read() 19

Analog output with the mbed The mbed analog output on pin 18 is configured by the following declaration: AnalogOut Aout(p18); By default, the analog object takes a floating point number between 0.0 and 1.0 and outputs this to pin 18 The actual output voltage on pin 18 is between 0V and 3.3V, so the floating point number that is output as a voltage is scaled by a factor of 3.3 20

Analog output with the mbed Exercise 3: compile the program shown below and, using an oscilloscope, familiarise yourself with the analog output. #include "mbed.h" int main() { AnalogOut Aout(p18); while(1) { Aout=0.25; // 0.25*3.3V = 0.825V wait(1); Aout=0.5; // 0.5*3.3V = 1.65V wait(1); Aout=0.75; // 0.75*3.3V = 2.475V wait(1); } } 21

Analog output with the mbed Exercise 4: Now make a sawtooth wave and view it on an oscilloscope. Create a new program and enter the following code //Sawtooth waveform on DAC output to view on oscilloscope #include "mbed.h" AnalogOut Aout(p18); float i; int main() { while(1) { for (i=0;i<1;i=i+0.1) { Aout=i; wait(0.001); } } } 22

Analog output with the mbed Exercise 5: Modify your code to create a smoother sawtooth wave, by implementing finer steps in the for loop: Exercise 6: Create a smooth triangular wave by implementing a second loop to count down also: 23

Summary Introduction to analog signals and data Concepts of analog-to-digital conversion Analog inputs on the mbed Reading and logging data from analog inputs Concepts of digital-to-analog conversion Analog output with the mbed Generating output waveforms 24