Skip to main content

The future of AI in business and its potential to transform industries

What is the Internal ADC pic18f chips?



Hello... In today's article, we will talk about the internal ADC pic18f. 
We will cover the article on the following points:
  • What is ADC?
  • Characteristics of ADC
  • Features of ADC
  • ADCON0 register
  • ADCON1 and ADCON2 register
  • Calculating Analog to Digital conversion time
  • Steps to program A/D converter

What is ADC?

ADC stands for Analog to Digital converter. ADC devices are the most widely used devices for data acquisition.

The computer understands the binary values but in the real world, everything is available in analogue values. Temperature, pressure, humidity, velocity etc are few examples of physical quantities that we deal with in everyday life.

Therefore. we need an Analog-to-digital converter to translate the Analog signal to digital numbers so that the microcontroller can read and process them.

The ADC is widely used in data acquisition, in recent years an increasing number of microcontrollers have an on-chip ADC peripheral just like timer and USART.

An on-chip ADC eliminates the need for external ADC which leaves more pins for other input-output activities.

Characteristics of ADC

1. Resolution

ADC pic18f has an n-bit resolution, where n = 8,10,12,13 or even 24 bits.
The higher the resolution, the smaller the step size. Stepsize is the smallest change that can be recognized by an ADC. 

The resolution of an ADC pic18f is decided at the time of its design and cannot be changed, but we can control the step size with the help of the Vref.

2. Conversion time

The time is taken by the ADC to convert the Analog input to a digital number is called the conversion time.

3. Vref 

It is an input voltage used for reference voltage. The voltage connected to the pin along with the resolution of the ADC chip decides the stepsize.


Example:-   

If the Analog input range needs to be 0 to 5V. Vref is connected to 5V that gives 5V/1024 = 4.88mV for the stepsize of a 10-bit ADC.

4. Digital data output

In the 10-bit ADC of the PIC18 chip, we have 10-bit of digital data output.

To calculate the output voltage we use the following formula:

                                              Dout= Vin/stepsize

where, 

              Dout = digital data output (in decimal)

               Vin = Analog input voltage

Example:- 

   For the 10-bit ADC, we have Vref = 5V. Calculate the D0-D9 output if the Analog input is 1.7V.

solve 

         step size = 5/1024 = 4.88mV

         Dout = 1.7V/4.88x10^3 V

         Dout = 348.360 = 348 (decimal)

5. Analog input channel

The PIC18 microcontroller chip comes with 5 to 15 ADC channels, depending on the family member this channel allowing us to monitor multiple quantities such as temperature, pressure, heat, and so on.

Features of ADC

  • It is a 10-bit ADC.
  • It can have 5 to 15 channels of Analog input channels, depending on the family member.
  • The converted output data is held by two special function register ADRESL and ADRESH.
  • The ADRESL and ADRESH register give us 16-bits and the ADC output data is 10-bit wide hence 6-bit are unused.
  • We can use Vdd the voltage source of the PIC18 itself as the Vref or connecting it to an external voltage source for Vref.
  • The conversion time is decided by the Fosc of crystal frequency connected to the OSC pins. The Fosc for PIC18 is as high as 40MHz, the conversion time cannot be shorter than 1.6ms.
  • It allows the implementation of differential Vref voltage.
                                            Vref = Vref(+)  -  Vref(-)

ADCON0 register

This register is used to set the conversion time and select the Analog input channel. To reduce the power consumption of PIC18, the ADC feature is turned off when the microcontroller is powered up. We need to turn on the ADC using the ADCON0 register.


ADCON1 and ADCON2 registers

This register is used to select the Vref voltage among other things. This register also used for making it right justified or left justified because we need only 10 bits of the 16.


The PORTA (RA0, RA1, RA2, RA3 and RA5) and PORTE (RE0, RE1, RE2) are used for Analog input channels.
For PCFG = 0110 we can use all the pins of PORTA as the digital I/O. The default is PCFG = 0000 which allows us to use all the 8 pins for Analog inputs.


Calculating A/D conversion time

We can set A/D conversion time with the help of both ADCON0 and ADCON1 register. The conversion is defined in terms of Tad. Where Tad is the conversion time per bit.

To calculate the Tad we need to select a conversion clock source of Fosc/2, Fosc/4, Fosc/8, Fosc/16, Fosc/32, Fosc/64. Where Fosc is the speed of the crystal frequency connected to the PIC18 chip.

For PIC18 the conversion time is 12 times the Tad and Tad cannot be faster than 1.6ms.

To use the internal RC oscillator for the conversion clock source the Tad is typically 4 to 6 micro-seconds and the conversion time is 12x6us = 72us.

Another important factor is timing acquisition (Tacq). After an (A/D) channel is selected we must allow some time for the sample and hold capacitor (C hold) to charge fully to the input voltage. It is only after the elapsing of this acquisition time the A/D conversion can be started.

Steps to program the A/D converter of PIC18

  1. Turn on the ADC module of the PIC18 because it is disabled upon power-on reset to save power, we can use ADCON0, ADON instruction.
  2. Make the PIN for the selected ADC channel on the input pin. We use TRISAx or TRISEx where x is the channel number.
  3. Select voltage reference and Analog input channels, we use ADCON0 and ADCON1.
  4. Select the conversion speed, we use register ADCON0 and ADCON1.
  5. Wait for the required acquisition time.
  6. Activate the start conversion bit of GO/DONE.
  7. Wait for the conversion to be completed by polling the end-of-conversion (GO/DONE) bit.
  8. After the GO/DONE bit has gone LOW read the ADRESL and ADRESH register to get the digital data output.
  9. Go back to step5.

Popular posts from this blog

Top 7 domains to expertise after learning python

Top 7 domains to expertise after learning python Python is one of the most popular programming languages. It is an object-oriented, dynamic semantics and high-level programming language. It's high-level built-in data structure combined with dynamic binding and dynamic typing makes it attractive for rapid application development. Often programmers fall in love with python because of the increased productivity it provides. Python is one of the most readable languages in the world right now. This language is very popular among developers and is widely used by many programmers to create application and programs. The implementation of this programming language is simple and at the same time, the language has a very clean structure as compared to other languages.  So if you mastered your python concepts and skills, you can dominate these 7 domains. Machine learning / Artificial intelligence Desktop GUI Data analytics and data visualization  Web development Game development Mobile ap...

Different domains of Artificial intelligence(AI)

Artificial intelligence is a computer system that is able to perform tasks that ordinarily require human intelligence. Artificial intelligence systems are critical for companies that wish to extract value from data by automating and optimizing processes or producing actionable insights. There are certain domains of artificial intelligence on which we can create our expertise Machine learning Deep learning Robotics Expert systems Fuzzy logic Natural language processing Computer vision  1. Machine learning Machine learning is a subset of artificial intelligence. Machine learning enables computers or machines to make data-driven decisions rather than being explicitly programmed for a certain task. These programs or algorithms are designed in a way that they learn and improve over time when are exposed to new data. Different types of machine learning models Supervised learning Unsupervised learning Reinforcement learning Use cases Product recommendation on a shopping website. spam fil...

Top 5 free machine learning courses with certificate

In the era of 21st-century artificial intelligence, machine learning and data science became the most demanding and highest paying skills. After the covid-19 pandemic situation, the working style of the corporate sectors and the business had completely changed, now most of the business deals are made on the basis of data analysis, or when it comes to making the businesses automation the people hire a  machine learning engineer.    Hence it becomes really important for those who work in the corporate sector or a student pursuing a degree to get a job should update himself with these skills.  So, I listed you Top 5 machine learning courses from one of the leading organisations with completion certificates at free of cost. 1. Machine learning in the cloud with AWS batch About This course describes how to run and accelerate your machine learning applications in the cloud using AWS batch. AWS Batch is a fully managed service that allows you to easily and efficiently run b...