Friday, February 5, 2021

PIC16F887 Analog-to-Digital Converter (ADC)

Introduction

Analog-to-Digital Converter (ADC) module of a microcontroller converter analog input voltage to digital value representation that microcontroller process with. There are many different types of ADC module inside microcontroller.

ADC module has some parameters:

  1. Resolution : Define the amount of digital number of analog to digital conversion. It could be 8-bit, 10-bit, 12-bit, etc. Larger resolution gives the conversion result more accurate.
  2. Voltage reference: It also effect Resolution. Lower voltage reference of ADC makes an accurate conversion result. It could be 2.5V, 3.3V, or 5V.
  3.  Clock : It could be driven from microcontroller clock source, or its own internal clock. 
  4. Number of Analog Input Channel : It  refers to the amount of input pins of ADC. It usually multiplexed with other digital I/O pins.

The figure below is ADC block diagram of PIC16F887.

PIC16F887 Analog-to-Digital Converter (ADC)
Block diagram of PIC16F887 ADC Module
PIC16F887 has up to 14 analog input channels. They are multiplex within Port A and Port B.

Programming for ADC

ADC module inside PIC16F887 has some registers for programmer to work with. Programmer need to configure,

  1. ADC clock
  2. Analog channel inputs
  3. Result arrangement
  4. Channel selection
  5. Start of conversion
  6. Testing the result and reading the result
  7. Interrupt control (optional)

 These registers are,



PIC16F887 Analog-to-Digital Converter (ADC)
Registers relate to ADC of PIC16F887

Now let start a simple example of using ADC module. This program read analog input on RA0/AN0. Conversion result will display on Port C and Port D.

PIC16F887 Analog-to-Digital Converter (ADC)
Schematic Diagram



 MikroC source code:


Click here to download zip file of this working example.





Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)