Chapter 11 It’s an Analog World Learning to use the Analog to Digital Converter.

Slides:



Advertisements
Similar presentations
Analog to digital converter
Advertisements

EMS1EP Lecture 8 Pulse Width Modulation (PWM)
Jordan Barry Victor Brzeski
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Digital Thermostat and Data Logger Brandon Wagner and David Southwick.
EET 2261 Unit 14 INCOMPLETE Analog-to-Digital Conversion (ADC) & Digital-to-Analog Conversion (DAC)  Read.  Homework #13 and Lab #13 due next week. 
ECE 265 – LECTURE 14 Analog Signal Acquisition The A/D converters 5/14/ ECE265.
Arnan Sipitakiat Dept. Computer Engineering, Chiang Mai Univeristy.
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
-Done By Haresh Miriyala
Lecture 5: PIC32 development board, Timers ADC and interrupts,
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.
PIC16F bit 8-channel Analog-to-Digital Converter.
Explain the introduction to ADC, ADC characteristics, Programming ADC using PIC18, Introduction to DAC and DAC interfacing with PIC18.
1 Analog-to-Digital Converter (ADC). 2 ADC Features (1/3) ADC conversion rate 1 MHz and 12-bit resolution – 1µs conversion time at 56 MHz – 1.17µs conversion.
ECT 357 Ch 10 Analog to Digital COnversion. Today’s Quote: It’s better to die with a good name than to live with a bad one. It’s better to die with a.
Interfacing ADC to 8051.
Chapter 8 Communication Introduction to serial communication interfaces. Examples of use of the SPI module.
Chapter 12 Capturing Input. Di Jasio - Programming 32-bit Microcontrollers in C Button Inputs.
Engineering 1040: Mechanisms & Electric Circuits Winter 2015 Analog & Digital Signals Analog to Digital Conversion (ADC)
1 Applied Control Systems Technology. 2 Pin configuration Applied Control Systems.
Digital to Analogue Converter
Analog to Digital Converters (ADC) Ben Lester, Mike Steele, Quinn Morrison.
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
Digitization When data acquisition hardware receives an analog signal it converts it to a voltage. An A/D (analog-to-digital) converter then digitizes.
dsPIC DSC –Modul A/D Conversia A/D Registre programare
EEE527 Embedded Systems Lecture 10B:Chapter 11 Analogue to Digital Convertors (ADCs) (version 2: 25/11/13, see after slide 20 Ian McCrumRoom 5B18, Tel:
Renesas Electronics Corporation © 2010 Renesas Electronics America Inc. All rights reserved. RX 12 Bit Analog-to-Digital Converter A Rev /1/10.
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
Chapter 7 - Performance Understanding the PIC32 Clock and learning to optimize the memory interface for maximum performance.
CS224 I/O. Timers Timer1 is 16-bit timer 2^16-1 or 65,535 SYSCLK = 40MHz, Prescalers – 1:1, 1:8, 1:64, and 1:256 – Use T1CONbits.TCKPS=3 for 1:256 scaling.
Chapter 10 Glass Bliss Using the Parallel Master Port to communicate with Alphanumeric LCD displays.
By James Cockrell and Justin Loveless
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
Lecture 11: Liquid Level Control System: A Case Study 1.
Water Flow GROUP A. Analogue input voltage results: Motor Input voltage( V) pin 12 Analogue input voltage (V) Display number
Microcontroller based system design Asst. Prof. Dr. Alper ŞİŞMAN.
Analog to Digital Converter (ADC)
0808/0809 ADC. Block Diagram ADC ADC0808/ADC Bit μP Compatible A/D Converters with 8-Channel Multiplexer The 8-bit A/D converter uses successive.
Microcontrollers JULES CALELLA. Microcontrollers vs Microprocessors  Microprocessors – do not contain RAM, ROM, I/O  Microcontrollers – The whole package.
Microcontroller basics Embedded systems for mortals.
ECE 101 Exploring Electrical Engineering Chapter 7 Data Acquisition Herbert G. Mayer, PSU Status 11/30/2015 Derived with permission from PSU Prof. Phillip.
Electronic instrumentation Digitization of Analog Signal in TD
Portable Power Station University of Wyoming Electrical and Computer Department EE Done By Mohammad S. Almoallem Mahmood S. Almoallem Advised.
Sensing Algorithm using IR Sensor and ADC Soong-sil University. Robotics 기 정 두 원.
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),
CEng3361 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2011 Recitation 06.
Microcontroller basics
Prof. Chung-Ta King Department of Computer Science
Arduino - Introduction
Chapter D – Serial Connections to the RPi and Analog-to-Digital Converters
ADC, DAC, and Sensor Interfacing
ADC, DAC, and Sensor Interfacing
Analog Input through POT
Digital-to-Analog & Analog-to-Digital Conversion
ADC, DAC, and Sensor Interfacing
ADC, DAC, and Sensor Interfacing
Chapter 10 It’s an Analog World
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.
ADC and DAC Programming in AVR
ADC and DAC Data Converter
ADC and Sensor Programming
輸出動作與輸入命令相同.
Prof. Chung-Ta King Department of Computer Science
PIC Analog Input Tom Igoe, NYU-ITP
ADC and DAC Data Converter
PIC Microcontroller ADC interfacing Prof. Ashvini Kulkarni
ECE 3567 Microcontroller Lab
Presentation transcript:

Chapter 11 It’s an Analog World Learning to use the Analog to Digital Converter

Di Jasio - Programming 32-bit Microcontrollers in C Analog to Digital Converter

Di Jasio - Programming 32-bit Microcontrollers in C Reading a Potentiometer

Di Jasio - Programming 32-bit Microcontrollers in C First Conversion int readADC( int ch) { AD1CHSbits.CH0SA = ch; // 1. select analog input AD1CON1bits.SAMP = 1; // 2. start sampling T1CON = 0x8000; TMR1 = 0; // 3. wait for sampling time while (TMR1 < 100); // AD1CON1bits.SAMP = 0; // 4. start the conversion while (!AD1CON1bits.DONE); // 5. wait conversion complete return ADC1BUF0; // 6. read result } // readADC

Di Jasio - Programming 32-bit Microcontrollers in C Automating Sample Timing void initADC( int amask) { AD1PCFG = amask; // select analog input pins AD1CON1 = 0x00E0; // automatic conversion after sampling AD1CSSL = 0; // no scanning required AD1CON2 = 0; // use MUXA, use AVdd & AVss as Vref+/- AD1CON3 = 0x1F3F; // Tsamp = 32 x Tad; AD1CON1bits.ADON = 1; // turn on the ADC } //initADC int readADC( int ch) { AD1CHSbits.CH0SA = ch; // 1. select input channel AD1CON1bits.SAMP = 1; // 2. start sampling while (!AD1CON1bits.DONE); // 3. wait conversion complete return ADC1BUF0; // 4. read conversion result } // readADC

Di Jasio - Programming 32-bit Microcontrollers in C First Example: Pot-Man /* ** Pot-Man.c ** */ // configuration bit settings, Fcy=72MHz, Fpb=36MHz #pragma config POSCMOD=XT, FNOSC=PRIPLL #pragma config FPLLIDIV=DIV_2, FPLLMUL=MUL_18, #pragma config FPLLODIV=DIV_1 #pragma config FPBDIV=DIV_2, FWDTEN=OFF, CP=OFF, BWP=OFF #include main () { int a, r, p, n; // 1. initializations initLCD(); initADC( AINPUTS); // 2. use the first reading to randomize srand( readADC( POT)); // 3. init the hungry Pac p = '<'; // 4. generate the first random food bit position r = rand() % 16; // main loop while( 1) { // 5. select the POT input and convert a = readADC( POT); // 6. reduce the 10-bit result to a 4 bit value (0..15) // (divide by 64 or shift right 6 times a >>= 6; // 7. turn the Pac in the direction of movement if ( a < n) // moving to the left p = '>'; if ( a > n) // moving to the right p = '<'; // 8. when the Pac eats the food, generate more food while (a == r ) r = rand() % 16; // 9. update display clrLCD(); setLCDC( a); putLCD( p); setLCDC( r); putLCD( '*'); // 10. provide timing and relative position Delayms( 200); // limit game speed n = a; // memorize previous position } // main loop } // main

Di Jasio - Programming 32-bit Microcontrollers in C Sensing Temperature TC1047 Output Voltage vs. Temperature characteristicsTemperature Sensor connection on Explorer16 board (DS51589)

Di Jasio - Programming 32-bit Microcontrollers in C Reading Temperature Averaged temperature reading procedure: a = 0; for( j=0; j <10; j++) a += readADC( TSENS); // add up 10 readings i = a / 10; // divide by 10 to average Resolving the temperature/voltage equation for T: T = (Vout mV) / 10 mV/C Where Vout = ADC reading * ADC resolution (3.3 mV/bit) T = (( i * 3.3) - 500) / 10;

Di Jasio - Programming 32-bit Microcontrollers in C Second Example: Temp-Man main () { int a, i, j, n, r, p; // 1. initializations initADC( AINPUTS); // initialize the ADC initLCD(); // 2. use the first reading to randomize srand( readADC( TSENS)); // generate the first random position r = rand() % 16; p = '<'; // 3. compute initial average value a = 0; for ( j=0; j<10; j++) { a += readADC( TSENS); // read temp Delayms( 100); } i = a / 10; // average // main loop while( 1) { // 4. take the average value over 1 second a = 0; for ( j=0; j<10; j++) { a += readADC( TSENS); // read the temperature Delayms( 100); } a /= 10; // average result // 5. compare initial reading, move the Pac a = 7 + (a - i); // 6. keep the result in the value range if ( a > 15) a = 15; if ( a < 0) a = 0; // 7. turn the Pac in the direction of movement if ( a < n) // moving to the left p = '>'; if ( a > n) // moving to the right p = '<'; // 8. as soon as the Pac eats the food, generate new while (a == r ) r = rand() % 16; // 9. update display clrLCD(); setLCDC( r); putLCD( '*'); setLCDC( a); putLCD( p); // 10. remember previous postion n = a; } // main loop } // main