How to use the CCS compiler with the ADC port

Slides:



Advertisements
Similar presentations
PRINCIPALES FUNCIONES Y DIRECTIVAS
Advertisements

Boolean Algebra Variables: only 2 values (0,1)
Processor Register Set of M16C
Analog to digital converter
Inside the binary adder. Electro-mechanical relay A solid state relay is a switch that is controlled by a current. When current flows from A to B, the.
Electronics Design Lab TUTORIAL PIC Microcontrollers Francesco Tenore 2/10/2006.
Rowan Hall 238A April 02, 2006 Sophomore Clinic ENGR , CRN Introduction to PIC Programming in C.
Analog Representations of Sound Magnified phonograph grooves, viewed from above: When viewed from the side, channel 1 goes up and down, and channel 2 goes.
Graphs, Planar graphs Graph coloring
Functions of Combinational Logic
The simple built-in data types of the C language such as int, float, - are not sufficient to represent complex data such as lists, tables, vectors, and.
Intermediate Electronics and Lilypad Where Electronics Meet Textiles Workshop with Lynne Bruning and Troy Robert Nachtigall Sponsored by Spark Fun and.
Anurag Dwivedi & Rudra Pratap Suman.  Open Source electronic prototyping platform based on flexible easy to use hardware and software.
Analogue to Digital Conversion By Cap’n Tim Johnson, PE Prepared 11/12/2013.
Analog/Digital Subsystem
Khaled A. Al-Utaibi  Digital Vs Analog Signals  Converting an Analog Signal to a Digital One  Reading Analog Sensors with the.
Mark Neil - Microprocessor Course 1 Digital to Analog Converters.
Lecture 5: PIC32 development board, Timers ADC and interrupts,
PIC16F bit 8-channel Analog-to-Digital Converter.
Slides created by: Professor Ian G. Harris Inputs and Outputs PIC Vcc RA3 RA4 RA5  Make an LED toggle state when button is pressed  Need to read RA3,
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.
EE396 Project Micromouse Team: Ocha. Team Members Kanoa Jou (Programmer) Ryan Sato (Hardware) KiWoon Ahn (Recorder) Alan Do (Programmer)
Railway Foundation Electronic, Electrical and Processor Engineering.
Learning Outcomes  Know the basic components of a network  Know data transmission methods, including types of signals, modulation, demodulation, and.
Railway Foundation Electronic, Electrical and Processor Engineering.
Core 3: Communication Systems. Encoding and decoding analog and digital signals…  Encoding involves converting data from its original form into another.
Eejit’s guide to using a LCD alphanumeric display with the CCS C compiler 1.Hardware connection 2.The LCD.C include file 3.An example.
MDIA 308 Digital technologies. Converting analog to digital ADC – analog to digital conversion An analog voltage is converted in binary code Binary =
Embedded Systems Design
How to use the CCS compiler with the serial port.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
September, 2007ENGR Low-Level Robot Control Mechatronics: Motors, sensors & embedded controls.
Clock Options and Sleep Modes. Clock Sources Flash Fuse bits can be programmed to choose one of the following Clock sources: 1. External RC Osc. f = 1/(3RC).
Introduction to PIC-C. Required Software PIC-C Compiler Firmware Downloader Driver for the USB->Serial Adapter.
Digital to Analogue Converter
Control Angle via Button Pushes One button increases angle. Other decreases angle. Both light LED.
RS232 #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7
Advanced uC Session Speaker : Chiraag Juvekar Jan 13, 2011 Speaker : Chiraag Juvekar Jan 13, 2011.
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:
Suleyman Demirel University CSS340 Microprocessor Systems – Lecture 2 ATMEGA328P ARCHITECTURE ANALOG INPUTS.
SMV ELECTRIC TUTORIALS Nicolo Maganzini, Geronimo Fiilippini, Aditya Kuroodi 2015.
Analog to Digital Converter (ADC). Analog to Digital Converters  Microcontroller understands only digital language.  To convert the analog output from.
Analog to Digital Conversion - ADC Mark Neil - Microprocessor Course 1 Device Drivers – Measuring Voltages.
Lab 1 Summary.
Fundamentals of Audio Production. Chapter 3 1 Fundamentals of Audio Production Chapter Three: Digital Audio.
Mark Neil - Microprocessor Course 1 Digital to Analog Converters.
Grounding ADCs & DACs Data Converters (ADCs and DACs) are accurate and sensitive analog devices whose analog ports are vulnerable to unwanted noise (most.
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.
Components of a typical full-featured microcontroller.
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),
 Mini-Computer ◦ Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output)  Low-Cost.
Val Manes Department of Math & Computer Science
Interfacing of LCD with µP
Chapter D – Serial Connections to the RPi and Analog-to-Digital Converters
ECET 365 Competitive Success/snaptutorial.com
ECET 365 Education for Service-- snaptutorial.com.
ECET 365 Teaching Effectively-- snaptutorial.com.
Introduction to Microprocessors and Microcontrollers
IoT Programming the Particle Photon.
CSE 171 Lab 11 Digital Voltmeter.
Digital Control Systems Waseem Gulsher
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.
Arduino : Introduction & Programming
ADC and DAC Programming in AVR
Pondicherry Engineering College
Robotics System Lecture 11_12: DC Motor
UNIT 5 Analog signals.
PIC Microcontroller ADC interfacing Prof. Ashvini Kulkarni
Presentation transcript:

How to use the CCS compiler with the ADC port

Setting up and initialization Tell the compiler to use the ADC port as either 8- or 10-bit; e.g. #device ADC=8 Hint: Do not leave spaces around the = sign! Inside the main() function, after any variables have been declared: Use the setup_adc() function to set up the ADC clock. For instance to use the system clock frequency divided by eight: setup_adc(ADC_CLOCK_DIV_8); Hint: The magic incantations for the various functions are listed in the PIC header file; e.g. 16f877.h which you can view in the folder Program files\picc\devices. These incantations are usually in capital lettering. See also the appendix in Slide 5

Set which pins are to be analog and which are to be digital using the setup_adc_ports() function. For instance if you want pins RA0, RA1 and RA3 to be analog (Channels AN0, AN1 and AN3) and all other pins in Ports A & E to be digital (and to use the power supply for the reference voltages) then: setup_adc_ports(AN0_AN1_AN3); Hint: All the options from the header file are listed in Slide 5. Set up which channel you want to do the conversion. For instance, to convert an analog voltage at pin RA1 (i.e. Channel 1): set_adc_channel(1); HINT: If you are only ever going to use one channel then put this function along with the other setup functions near the start of the main() function, otherwise put it before starting a conversion.

Using the ADC module Say you want to read an analog value into a variable. If we have a variable called, say, value then simply use the function read_adc(); e.g.: int value; /* Various setting up functions etc */ value = read_adc(); Hint: If the ADC has been set up for 8-bit then value should be int, if for 10-bit then it should be long int. Hint: Somewhere the channel number should be set up using the set_adc_channel(x) function.

Appendix: Extract from header file 16f877.h ////////////////////////////////////////////////////////////////// ADC // ADC Functions: SETUP_ADC(), SETUP_ADC_PORTS() (aka SETUP_PORT_A), // SET_ADC_CHANNEL(), READ_ADC() // Constants used for SETUP_ADC() are: #define ADC_OFF 0 // ADC Off #define ADC_CLOCK_DIV_2 0x100 #define ADC_CLOCK_DIV_8 0x40 #define ADC_CLOCK_DIV_32 0x80 #define ADC_CLOCK_INTERNAL 0xc0 // Internal 2-6us // Constants used in SETUP_ADC_PORTS() are: #define NO_ANALOGS 7 // None #define ALL_ANALOG 0 // A0 A1 A2 A3 A5 E0 E1 E2 #define AN0_AN1_AN2_AN4_AN5_AN6_AN7_VSS_VREF 1 // A0 A1 A2 A5 E0 E1 E2 VRefh=A3 #define AN0_AN1_AN2_AN3_AN4 2 // A0 A1 A2 A3 A5 #define AN0_AN1_AN2_AN4_VSS_VREF 3 // A0 A1 A2 A5 VRefh=A3 #define AN0_AN1_AN3 4 // A0 A1 A3 #define AN0_AN1_VSS_VREF 5 // A0 A1 VRefh=A3 #define AN0_AN1_AN4_AN5_AN6_AN7_VREF_VREF 0x08 // A0 A1 A5 E0 E1 E2 VRefh=A3 VRefl=A2 #define AN0_AN1_AN2_AN3_AN4_AN5 0x09 // A0 A1 A2 A3 A5 E0 #define AN0_AN1_AN2_AN4_AN5_VSS_VREF 0x0A // A0 A1 A2 A5 E0 VRefh=A3 #define AN0_AN1_AN4_AN5_VREF_VREF 0x0B // A0 A1 A5 E0 VRefh=A3 VRefl=A2 #define AN0_AN1_AN4_VREF_VREF 0x0C // A0 A1 A5 VRefh=A3 VRefl=A2 #define AN0_AN1_VREF_VREF 0x0D // A0 A1 VRefh=A3 VRefl=A2 #define AN0 0x0E // A0 #define AN0_VREF_VREF 0x0F // A0 VRefh=A3 VRefl=A2