【PIC microcontroller】-- ADC related knowledge

Publisher:科技思想家Latest update time:2022-07-25 Source: csdn Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

00 Write in front

This series of articles is from a teacher who has served as a teaching assistant for the PIC microcontroller course. I mainly explained the contents of several experimental classes to my junior students. Here I record some of the knowledge learned in class.


This series of articles mainly introduces:

Experiment 1 - Introduction and Basic I/O - Buttons and LEDs (The first step in learning embedded systems is to turn on a light, just like the first step in learning a programming language is to write a "hello world" code)


Experiment 2 – MPLAB + PICkit 3 + LCD + I/O (This experiment mainly introduces the use of LCD screen, which is often needed for debugging our system. For example, if we make a temperature measurement system, we can use the LCD screen to display the values ​​collected by the sensor, and then use the software to do further processing)


Experiment 3-ADC (This is an analog-to-digital conversion experiment, which is a comprehensive application of the knowledge learned in the previous analog-to-digital electronics)


Experiment 4 – Serial Communication – UART


Experiment 5 – Serial Communication – I2C


Experiment 6 – Timers and interrupts (This part is also a very important knowledge point, which will be used in many embedded systems. For example, a smart car can be built by adding a single-chip microcomputer and a few sensors. The smart car will use timers and interrupts)


01 Additional knowledge about ADC

The new content we are going to talk about today is the ADC module, which is a module that converts analog signals into digital signals. This should be familiar to everyone. We have learned this principle in the analog electronics class before. However, today we will not talk about the underlying principle, but teach you how to use it, that is, how to use the microcontroller to realize AD conversion;


Many PICs use the successive approximation type. These two pictures are its internal schematics. We have learned about analog and digital electronics before, so you can think about it again after class.

insert image description hereinsert image description here

Next, let's talk about the main technical indicators of AD conversion: conversion time (conversion rate), resolution, and conversion accuracy;

insert image description hereinsert image description here

Conversion accuracy is usually expressed in terms of resolution and conversion error, which is also mentioned in digital electronics textbooks.


02 How to view the chip manual?

Open the schematic diagram. The PIC16F877A has an on-board 8 channel 10 bit Analog-to-Digital Converter module. The corresponding pins are:

insert image description here

Here I will tell you how to read the chip manual. A classmate asked me before that the chip manual is in English, which is not easy to understand?


Then I will teach you, first find the corresponding module according to the directory, for example, our AD module today is here in Chapter 11, and then in the content, everyone focuses on the register, that is, what does each bit of the register mean, if you can't remember, you can only check it through the chip manual!


In addition, there is a register summary at the end of each chapter, which summarizes the registers related to the module.


03 ADC related registers

The next step is the highlight, the registers related to ADC. Similarly, after you configure these registers, you can start the microcontroller to perform AD conversion.


(The configuration register is actually to figure out the meaning of each bit of the register. Where can I find this?


1. Chip manual;


2. The teaching materials you distributed also mentioned this. The teaching materials actually help everyone translate the chip manual. This is indeed very useful for beginners, but after everyone is familiar with it, they will be able to use it by reading the chip manual.


So what I will say today is still based on the chip manual.)


04 ADC related registers

1. AD control register 0, ADCON0


2. AD control register 1, ADCON1

insert image description here

3. ADRESH and ADRESL registers. These two registers are used to store the digital signal after AD conversion. As we have just introduced, the number of bits after PIC conversion is 10 bits, and ADRESH and ADRESL are 8-bit registers (each storing the upper eight bits and the lower eight bits), so the total is 16 bits, then 16-10=6, and the remaining 6 bits are not needed, so just fill them with 0.


There are two ways to place the 10 bits, one is left-aligned and the other is right-aligned, which is controlled by the seventh bit of ADCON1.

insert image description here

4. Direction control register

Mainly set the pins of this analog port, including RE and RA


05 Several nouns

Sampling time: It is the time it takes for the microcontroller to read the analog signal from the external pin; (PIC is about 19.72us)


Then we must start AD conversion after reading the analog signal. If there is no analog signal, there is no conversion. Therefore, there must be a delay before starting AD conversion. This delay must be greater than 19.72us, usually 50~100us.


AD conversion clock requirements:

There are 7 steps for AD conversion without interruption.

Reference address:【PIC microcontroller】-- ADC related knowledge

Previous article:【PIC microcontroller】--Serial port related knowledge
Next article:【PIC microcontroller】-- LCD related knowledge

Recommended ReadingLatest update time:2024-11-15 23:47

Auto repair oscilloscope measuring automobile oxygen sensor signal (zirconium oxygen belt heater)
Last time we talked about using an oscilloscope to measure the signal of the car's air flow meter. This time we will talk about using an oscilloscope to measure the car's oxygen sensor. The oxygen sensor is also called a λ (Lambda) sensor. Compared with the air flow meter sensor, although both have an impact on the in
[Test Measurement]
Auto repair oscilloscope measuring automobile oxygen sensor signal (zirconium oxygen belt heater)
STM32 ADC and serial port
If you simply use USART, the configuration is quite simple. You only need to configure the baud rate, data length, stop bit length, and check bit. Then set the pins of the serial port, the input is up-and-back input, and the output is push-pull output. In this way, the serial port is configured. If you use the library
[Microcontroller]
Wearable system based on three-dimensional assembled microneedle ion sensor
Human health monitoring and early disease detection are important goals of modern medicine. Monitoring long-term changes in human health can provide early warning and intervention for many diseases and provide important references for the treatment of specific diseases. In recent years, various types of wearable sen
[Embedded]
Wearable system based on three-dimensional assembled microneedle ion sensor
Detailed explanation of virtual reality headsets and sensor principles
    Virtual reality head mounted displays are the most popular digital devices at present. Oculus Rift is already on the market, HTC Vive is about to be shipped, and Sony Playstation VR will also be officially released in the summer. PC and game console users can experience the shock of virtual reality games. Of cours
[Home Electronics]
Detailed explanation of virtual reality headsets and sensor principles
Saizhuo Electronics launches new product SC9675TS with TPOS+PCB-Less+programmable camshaft position sensor chip
01. Product Introduction: SC9675TS is the latest camshaft position sensor chip with TPOS function released by Saizhuo Electronics. Compared with the previous generation, its detection accuracy is greatly improved, and a variety of parameter options are designed internally, so that the sensor can be op
[Automotive Electronics]
Saizhuo Electronics launches new product SC9675TS with TPOS+PCB-Less+programmable camshaft position sensor chip
Littelfuse: Building a wider range of safety sensor layouts from automotive use
Recently, Stefan Edenharter, senior marketing manager of Littelfuse Automotive Electronics Division, introduced Littelfuse's layout and development in the automotive industry. Stefan Edenharter, Senior Marketing Manager, Automotive Electronics Division, Littelfuse Stefan said that the company entered the sensor
[Automotive Electronics]
Littelfuse: Building a wider range of safety sensor layouts from automotive use
Murata: Automotive intelligence and electrification require safer automotive sensors
On July 3, the 2020 Munich Shanghai Electronics Show opened grandly. As the only live video partner of the Munich Show, Electronics Fans Network interviewed many companies in the fields of Internet of Things, 5G , artificial intelligence, etc. through live broadcasts during the exhibition, and conducted extensive exch
[Automotive Electronics]
Murata: Automotive intelligence and electrification require safer automotive sensors
Continental and Nanochip to create safer automotive pressure sensor chips
On October 24, 2024, the 2024 Continental China Experience Day hosted by Continental was held in Gaoyou City, Jiangsu Province . Nearly 200 guests from upstream and downstream of the automotive industry chain were invited to attend the meeting and held in-depth dialogues around the coordinated development an
[sensor]
Continental and Nanochip to create safer automotive pressure sensor chips
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号