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.
Next, let's talk about the main technical indicators of AD conversion: conversion time (conversion rate), resolution, and conversion accuracy;
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:
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
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.
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.
Previous article:【PIC microcontroller】--Serial port related knowledge
Next article:【PIC microcontroller】-- LCD related knowledge
Recommended ReadingLatest update time:2024-11-15 23:47
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Modern Motor Control Technology (Wang Chengyuan, Xia Jiakuan, Sun Yibiao)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【ufun learning】02 Concept and preliminary circuit design 1
- 【RT-Thread Reading Notes】Reflections on RT-Thread Chapters 7-8
- DC-DC chip LM2596SX-5.0/NOPB
- How does the lwip client let the server know that it has been shut down?
- Small car front-end 16W power supply design
- Bear Pie Huawei IoT operating system LiteOS bare metal driver transplantation 05-E53_SF1 expansion board driver and use
- TI's TPS61200 boost chip can only boost voltage but not reduce voltage during actual testing. Please help.
- Learn to make a flyback switching power supply-2
- Embedded Learning丨4412 Development Board-uboot Source Code-Assembly-Source Code Analysis (I)
- Using the I2C Bus