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.
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.
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)
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:
2. ADCON1 (A/D CONTROL REGISTER 1)
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):