PIC24FJ128 - Analog Digital Conversion

ADC conversion

The role of the ANALOG-TO-DIGITAL CONVERTER (A/D) is to convert analog voltage values to digital values. Let’s explore the principle of operation of the A/D converter:
The ATD CONVERTER converts analogue voltage to binary numbers. These binary numbers can be in different lengths - 2, 4, 8, 10-bit. The more bits the binary number has, the higher the resolution of the - A/D.
For example: Suppose that the voltage that supplied to the A/D converter varies from 0 to 5 volts, and the A/D converter converts the input voltage to a binary number of two bits.
The accuracy of the value will be very bad because there would only be 4 options as below

  •  00
  • 01
  • 10
  • 11

For this reason, the greater the bits, the greater the precision of the measurement. The PIC24FJ128 is a 16-bit microcontroller whereby a 5V density is separated by 16bit, so the PIC24 can read numbers after the decimal point. For this reason, during the conversion there are significant bits before the decimal point, and less significant bits after the decimal point

Working Principle od ADC conversion on PIC24

From work register w3, I memorize in the register AD1PCFG from 15 to bit 2 as 1, and bit 1 and bit zero to 0 ( see register AD1PCFG). This means that I configure bit 0 and bit 1 as physically analogue input.

mov #0Xfffc,W3

mov w3,AD1PCFG

For more details see Figure 1 below

AD1PCFG

 Figure 1 - AD1PCFG register

 Activate 1 the bit 15 (ADON) on the register AD1CON1 which represent the automatic conversion

mov #0X80E0,W3

mov w3,AD1CON1

For more details see Figure 2 below

AD1CON1

 Figure 2 - AD1CON1 register

I put all bits to zero in the register AD1CHS to enable the channel AN0 as positive (Channel 0 Positive Input Select for MUX A Multiplexor Setting bits)

mov #0X0000,w3
mov w3,AD1CHS

For more details see Figure 3 and 4 below

AD1CHS

 Figure 3 - AD1CHS register

10BIT BLOCK DIAGRAM

 Figure 4 - 10-BIT HIGH-SPEED A/D CONVERTER BLOCK DIAGRAM

Start the sample by selecting bit 2 on register AD1CON1. Bits 5,6,7, was already selected previously 1, including also the bit 15. The bit 2 on register AD1CON1 when is 1 means the start of the sample

mov #0X80e4,w3

mov w3,AD1CON1

For more details see Figure 5 below

ASAM

Figure 5 - AD1CON bit 2 Start sample

Next step is take sample from temporary register, in this case ADC1BUF0

mov ADC1BUF0,w14
mov w14,PORTD

This instruction moves the sample from the ADC1BUF0 register to the PORTD register to display the sample on the LEDs.

mov #0X80e0,w3
mov w3,AD1CON1

Remove the start conversion, which means zero on bit 2 in the register AD1CON. The sample from Channel AN0 is completed and be ready for the next sample

Next sample will be from chanel AN1 (analoque input)

mov #0X01,w3
mov w3,AD1CHS

The instruction above shows that the sample will be taken from AN1 this time

mov #0X80e4,w3
mov w3,AD1CON1

The instruction above is the start sampling (as previously)

mov ADC1BUF0,w14
mov w14,PORTD

The instructions above show the new sample in the temporary register ADC1BUF0 and transferred to the PORTD for the Leds visualisation

mov #0X80e0,w3
mov w3,AD1CON1

Remove start conversion after sampling completed

Full routine of ADC conversion click here

 

 

 

favicon bacd

+(39) 347 051 5328

Italy - Kazakhstan

09.00am to 18.00pm

About

We offer the best and economical solutions, backed by 27+ years of experience and international standards knowledge, echnological changes, and industrial systems.

Marketing Materials

Spring Renovation
Industry
US Gas Company
Construct
Plus Project
Vam Drilling Service
X Project
X Project
Cabrrus Training

Marketing Materials1

Spring Renovation
Industry
US Gas Company
Construct
Plus Project
Vam Drilling Service
ultrasonic sensor
ultrasonic sensor
Cabrrus Training