How to work with inbuilt ADC Module of PIC18F4550

Summary of How to work with inbuilt ADC Module of PIC18F4550


This article explains the built-in ADC module of the PIC18F4550 microcontroller, covering its 10-bit resolution, 13 analog channels, external Vref pins, selectable clock options, and auto-triggering capability. It details ADC-related registers ADCON0 and ADCON1, describes bits for enabling the ADC, starting conversions, selecting channels (CHS0–CHS3) mapped to specific pins, and configuring pins as analog or digital via PCFG bits and VCFG reference selections.

Parts used in the PIC18F4550 ADC Module Project:

  • PIC18F4550 microcontroller (with inbuilt ADC)
  • Analog transducers/sensors (external)
  • Vref+ (RA3) external reference connection
  • Vref- (RA2) external reference connection
  • Power supply for PIC (Vdd, Vss)
  • Connecting wires / PCB traces for analog channel pins
  • Optional: clock source or oscillator for the PIC
  • Optional: pull-up/pull-down resistors for I/O as needed

A microcontroller, a digital device, can read, execute and transmit only digital signals. On the contrary, the outputs of the most of the transducers are analog in nature. Thus it is hard to interface these transducers directly with controllers. Analog-to-digital convertor (ADC) ICs are one way to make the analog input compatible with the microcontroller.

ADC Module of PIC
ADC Module of PIC

Using an external ADC adds complexity to the circuit. To avoid this complexity, PIC Microcontrollers have in-built ADC module which reduces the cost and connections of the circuit. This article explains the in-built ADC of PIC18F4550 controller.

As mentioned in the summary, a PIC microcontroller has inbuilt ADC for A/D conversion. The ADC module of PIC18F4550 controller has following specifications:

·         10-bit resolution output which means that an analog input gets converted into a corresponding 10-bit digital output.
·         13 channels which means that a total of 13 analog signals can be converted simultaneously into digital.
·         Vref+ (RA3) and Vref- (RA2) pins for external reference voltage.
·         8 selectable clock options.
·         ADC can be in auto-triggering mode for continuous A/D conversion.
ADC Registers:
To work with the inbuilt ADC of this PIC microcontroller, the certain registers are required to be configured. Each of these ADC registers has been explained below.
1. ADCON0 (A/D CONTROL REGISTER 0)
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
CHS3
CHS2
CHS1
CHS0
GO/DONE
ADON
ADON: This bit is used to enable/disable the ADC peripheral of the PIC.
1 = A/D converter module is enabled
0 = A/D converter module is disabled
GO/DONE: This is A/D conversion status bit. For ADON=1,
1 = A/D conversion in progress
0 = A/D Idle
CHS3: CHS0: These bits are used to select a particular analog channel from 13 available channels (0-12) which are multiplexed with digital I/O pins. The following table shows the bit configuration to select these analog channels:
CHS3:CHS0
Analog Channel
Pin
0000
Channel 0
RA0/AN0
0001
Channel 1
RA1/AN1
0010
Channel 2
RA2/AN2
0011
Channel 3
RA3/AN3
0100
Channel 4
RA5/AN4
0101
Channel 5
RE0/AN5
0110
Channel 6
RE1/AN6
0111
Channel 7
RE2/AN7
1000
Channel 8
RB2/AN8
1001
Channel 9
RB3/AN9
1010
Channel 10
RB1/AN10
1011
Channel 11
RB4/AN11
1100
Channel 12
RB0/AN12
2. ADCON1 (A/D CONTROL REGISTER 1)
 
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
 VCFG1
VCFG0
PCFG3
PCFG2
PCFG1
PCFG0
PCFG0:PCFG3: As mentioned earlier, there are 13 analog channels in PIC18F4550 which are multiplexed with digital I/O pins. This means that such a (multiplexed) pin can act as either a digital I/O pin or an analog input pin. Either of these configurations is selected by these bits. The following table shows the bit configuration to make a pin D (Digital I/O) or A (Analog input):

Quick Solutions to Questions related to PIC18F4550 ADC Module:

  • What is the resolution of the PIC18F4550 ADC?
    The ADC provides a 10-bit resolution output.
  • How many analog channels does the PIC18F4550 ADC have?
    There are 13 analog channels available (channels 0 to 12).
  • Which pins are used for external reference voltages?
    Vref+ is on RA3 and Vref- is on RA2 for external reference voltage connections.
  • How is the ADC enabled or disabled?
    ADC is enabled or disabled using the ADON bit in the ADCON0 register (1 enables, 0 disables).
  • How do you start an A/D conversion?
    Set the GO/DONE bit in ADCON0 to 1 to start conversion; it clears to 0 when conversion is complete.
  • How are analog channels selected?
    Channels are selected using CHS3:CHS0 bits in ADCON0 according to the channel-to-pin mapping table.
  • Can ADC pins be used as digital I/O?
    Yes; PCFG3:PCFG0 bits in ADCON1 configure multiplexed pins as digital I/O or analog inputs.
  • Are there selectable ADC clock options?
    The ADC offers 8 selectable clock options for conversion timing.
  • Does the PIC18F4550 support continuous ADC conversions?
    Yes, the ADC can operate in auto-triggering mode for continuous A/D conversion.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter