Application of PIC16LF874 single chip microcomputer in capacitance measurement module

Publisher:温馨生活Latest update time:2011-02-16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: In order to improve the accuracy of capacitance measurement, a capacitance measurement module based on the PICl6LF874 single-chip microcomputer is designed according to the working principle of the capacitive sensor. The application background and current research status of the capacitance measurement circuit at home and abroad are briefly explained, and the characteristics of the PICl6LF874 single-chip microcomputer of Microchip Corporation of the United States are introduced. The dynamic weak capacitance signal output by the capacitive sensor is converted into digital data through the PS02l capacitance-to-digital converter, and the measured data is processed, displayed and saved by the PICl6LF874 single-chip microcomputer application. The experimental results show that the relative error of the measured value of the fixed capacitance with a nominal value of 10-20 pF is within 1%. At the same time, it can be seen that the larger the capacitance value of the measured capacitance, the smaller the relative error between the measured value and the nominal value.
Keywords: PICl6LF874; capacitance sensor; PS02l; test

Capacitive sensors have been widely used in industry, medicine, military and other fields. However, most of the current capacitance measurement methods have low integration level and low precision, so accurate measurement of capacitance, especially small capacitance, has always been a very important content. The oscillation method has a simple circuit structure and poor anti-interference ability, and the capacitance between the plates affects the measurement results; the bridge method uses the bridge balance principle to measure capacitance, and the measurement results are greatly affected by the performance of the bridge arm capacitance. This article uses the PICl6LF874 microcontroller from Micmchip Company in the United States. The microcontroller adopts RISC reduced instruction set, Harvard bus structure, and pipeline instruction mode. It has the characteristics of strong anti-interference ability, low power consumption, high performance, and low price.

1 PICl6LF874 MCU
The PICl6 series MCU adopts Reduced Instruction Set Computer (RISC) structure, breaking through the natural structural dependence of traditional MCU on PC; coupled with the Harvard bus memory structure, two-stage pipeline instruction structure, single-cycle instruction and other technologies, it has taken a unique approach in the hardware structure of the MCU, greatly improving the efficiency of system operation. In addition, in view of the characteristics of MCU applications, PIC MCU also has some unique features in terms of power consumption, driving capability, peripheral module design, etc., making PIC a convenient and practical MCU with high cost performance.
The PICl6LF874 series MCU includes a series of different models of devices. The main features are:
1) Reduced Instruction Set Technology The PIC instruction system is specially designed according to the characteristics of small computers, striving to achieve higher efficiency for each instruction and reduce the duplication of instruction functions. The number of instructions for high, medium and low-end PIC MCUs is 58, 35 and 33 respectively. This brings two benefits. On the one hand, it can greatly improve the utilization rate of the code and help improve the execution speed. On the other hand, it brings great benefits to users' learning, memory and application. Programming and debugging are relatively easier, and the same function requires less coding, saving development time.
2) Harvard bus structure Harvard structure is that the program memory and data memory are independently addressed, that is, the two are located in different physical spaces. The PIC series of microcontrollers not only adopts the Harvard architecture, but also adopts the Harvard bus structure, thus giving full play to the potential advantages of the Harvard structure. It greatly improves the system's operating efficiency and data reliability.
3) Single-byte instructions Single-byte instructions are an innovative change to the microcontroller system. The instruction bits of high, medium and low-end PIC microcontrollers are 16 bits, 14 bits and 12 bits respectively. The addressing of ROM and RAM is relatively independent, and all instructions are realized in single bytes, which not only makes data access safer, but also significantly improves its operating speed.
4) Two-stage pipeline instruction structure Due to the use of the Harvard bus structure, the data bus and instruction bus are separated inside the device, and different bus widths are used. When an instruction is executed, the next instruction is fetched at the same time, so that higher efficiency can be achieved in each clock cycle.
5) Register group structure All registers of PIC, including I/O ports, timers and program counters, are in RAM structure, and only one instruction cycle is needed to complete access and operation.
6) One-time programmable (OTP) technology OTP can achieve zero time to market for products, and can be customized according to users to meet specific needs. Product customization can significantly improve the product life cycle and enhance the market competitiveness of products.
7) Low power consumption The power supply voltage is 2.0~5.5V. When using a 4 MHz crystal oscillator and a power supply voltage of 3V, the typical current consumption does not exceed 6 mA: when using a 32 kHz crystal oscillator and a power supply voltage of 3V, the typical current consumption is 20 mA, and the current consumption in sleep mode is less than lμA.
8) Complete variety and convenient selection The PIC series of microcontrollers has now formed a large family with more than 50 models in three grades of high, medium and low. The functions are flexible and diverse, and can meet the different needs of various applications.

2 Working principle of capacitance measurement module
The overall design principle block diagram of the capacitance measurement module is shown in Figure 1, which includes power management circuit, PIC16LF874 microcontroller, capacitive sensor, signal conditioning circuit, PS021 capacitance digital converter and interface circuit connected to the computer.

The working principle of the capacitance measurement module is as follows: the capacitance sensor outputs a weak capacitance signal, and the capacitance signal passes through the signal conditioning circuit and enters the PS02l capacitance-to-digital converter. The capacitance measurement range of this device is from 0 to tens of nF (unlimited). After the internal conversion of the device, the required value is obtained by setting the internal register of PS02l; the data is transmitted to the PICl6LF-874 microcontroller through SPI, and the measured data is then sent to the host computer (computer) through the asynchronous serial communication interface USART of the microcontroller. Finally, the host computer application displays the measurement results and saves the test data.

3 System Hardware Connection
This measurement circuit requires a control device to control the reading and writing of data. The PICl6LF874 microcontroller with simple structure, powerful functions and compatible with SPI serial interface is selected. Since the peripheral interface of PS02l is SPI, the microcontroller can control the operation of PS02l very well, and the measurement data can be sent to the host computer through the USART serial interface. The connection of the microcontroller is shown in Figure 2, and the connection diagram of PS02l is shown in Figure 3.

4 Implementation of system software functions
The application software designed based on PS021 includes programs such as detection, control, data processing, database management and system interface. Under the conditions of program running speed and storage capacity, try to use software to implement the hardware functions of traditional instrument systems and simplify hardware configuration. In addition, the interface is the "window" of the test system and virtual instrument, and is the main way for the system to display functional information. Software design should not only realize functions, but also have a beautiful interface. After determining the hardware platform of the test system, the key is to choose a suitable software development tool to write the corresponding application software. The test module is developed in a graphical programming language. The development environment can provide an integrated development environment, which is easy to connect to the instrument hardware and has a good user interface. According to the principle of host computer application design, the software of the test system is obtained. By setting some parameters on the main interface of the software, the hardware circuit is connected to the host computer, and the measurement results can be displayed. The measurement results are displayed on the data display interface, as shown in Figure 4.

5 Experiment and results
The above software was used for measurement. Before measurement, the measurement system must be calibrated. During calibration, PS02l requires that the reference capacitor Cref and the measured capacitor Cmeas are in the same capacitance range, that is, to ensure that the Cmeas/Cref ratio does not exceed 25% (PS02l limit value). The reference capacitor is a very important part and has a direct impact on the quality of measurement and the temperature stability of measurement. Recommended capacitor materials: CFCAP (multilayer ceramic capacitor of Taiyo Yuden) series, COG or NPO ceramic capacitors. The discharge resistor Rdis is closely related to the discharge time. The discharge time τ=0.7R(C+20 pF), and the time constant τ ranges from 2 to 10μs (5μs is recommended). The discharge resistor value is calculated according to the formula.
In the experiment, fixed capacitors of 1, 2, 3, 5.1, 6.8, 8.2, 9.1, 12, 13, 15, 16.5, and 18 pF were selected as the measured capacitors. Determine the size of the reference capacitor according to the range of the measured capacitance, then determine the discharge resistor value according to the measured capacitance and the reference capacitance value, combined with the discharge time, and finally select the appropriate measurement mode for measurement. Under the calibrated system, connect a reference capacitor to the reference end and the measured end respectively. At this time, the value displayed on the data display interface is the sum of the reference capacitance value and the parasitic capacitance value (the data displayed by Sensor 1 in Figure 3); then connect the measured capacitance in parallel based on the measured end reference capacitance. At this time, the measured data is the sum of the measured capacitance value, the reference capacitance value and the parasitic capacitance value. The subtraction of the measured values ​​in the above two steps is the measured capacitance value. The final measured capacitance value statistics are shown in Table 1.


Table 1 reflects the relative error between the measured value and the nominal value of the measured capacitance. It is also known that the larger the capacitance value of the measured capacitance, the smaller the relative error between the measured value and the nominal value. Since the measured capacitance is affected by factors such as ambient temperature, the amount of solder, and the quality of the measured capacitance, there is a certain error. Multiple measurements are averaged to obtain a more stable capacitance value. Under the calibrated system, the fixed capacitance is measured to verify the accuracy of the measurement module. The measured value and the nominal value are very close. It can be considered that the error of the measured capacitance nominal value is small, and it is further known that the capacitance measurement module has a high measurement accuracy.

6 Conclusion
The PlCl6LF874 single-chip microcomputer can well control the capacitance measurement module, which has a good role in promoting the research of capacitive sensors. The single-chip microcomputer simplifies the circuit design and makes the measurement results reach a higher accuracy; at the same time, this measurement module can reduce the volume of the circuit board, thereby reducing the volume of the entire device; it greatly simplifies the circuit design process, reduces the difficulty of product development, and is of great significance to accelerate product development and reduce production costs. The experimental results show that this measurement module has good practicality.

Reference address:Application of PIC16LF874 single chip microcomputer in capacitance measurement module

Previous article:PIC microcontroller A/D conversion data storage and serial port efficiency
Next article:Design of Programmable Cryptographic Processor Using EPIC Technology

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号