A Power Factor Online Detection Based on PIC Microcontroller Voltage Sampling

Publisher:kappa20Latest update time:2011-11-24 Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Introduction
Power factor is an important parameter in AC circuits, an important indicator for measuring whether the power system is operating economically, and an important detection quantity for the online monitoring system of the power supply line. It needs to be measured in real time in the power factor compensation system [1]. Therefore, it is very necessary to design a power factor online detection circuit with simple structure and high detection accuracy. The measurement of power factor generally requires sampling the voltage and current of the circuit under test, and then processing and extracting the power factor signal. It usually consists of voltage and current sampling circuits, shaping circuits, synchronous cycle measurement, phase measurement, etc. Its disadvantages are that the structure is complex and difficult to repair. Sometimes the power factor measurement accuracy is not high [2]. To this end, the author analyzes and calculates the power factor of the circuit under test based on voltage sampling, and displays the size of the power factor through the display circuit, and transmits the measured power factor over a long distance through the communication interface circuit. This not only simplifies the structure of the power factor measurement circuit, improves the measurement accuracy of the power factor, but also enhances the function of the power factor detection circuit.
2. Principle Analysis

The principle of detecting the power factor by extracting the voltage is shown in Figure 1 (a). First, three high-precision WB series digital AC voltage true RMS sensors are used to detect the power supply voltage U1 of the circuit under test, the voltage U2 across the additional adjustable resistor RP, and the load voltage U3. The function of the adjustable resistor RP is to make the additional resistance as small as possible to reduce the impact on the load under test, and to obtain a voltage
U2 with an appropriate value to meet the requirements of power factor calculation. According to circuit theory [3], the phasor diagram of voltages U1, U2 and U3 can be drawn as shown in Figure 1 (b), and COSϕ
is the power factor of the load under test.


Figure 1 Schematic diagram of voltage measurement principle and voltage phasor diagram
According to the cosine theorem in geometry,

From formula (2), we can know that as long as the voltages U1, U2, and U3 are calculated, the power factor COSφ of the load can be obtained. In order to reduce the hardware overhead of the measurement circuit, the data processing and calculation are completed by the microcontroller software.
3. Microcontroller input and output circuit design
The microcontroller input and output circuit mainly processes the voltage signal detected by the sensor, mainly including signal conversion, calculation, storage, and display of the power factor and data transmission. For this reason, we designed a circuit composed of a microcontroller and related components as shown in Figure 2.


[page]

The voltage sensor detects the voltage, where the 1-3 terminals are used to detect the power supply voltage U1, the 1-2 terminals are used to detect the additional resistor voltage U2, and the 2-3 terminals are used to detect the load voltage U3.
The MCU is the PIC16F877 MCU, which is one of the MCU series with the most integrated peripheral modules and the most powerful functions [4]. The MCU chip has an 8-channel, 10-bit resolution digital-to-analog converter ADC module and a 4K FLASH program memory. The RA port is a bidirectional I/O port with only 6 pins. It combines the A/D converter function on the basis of the basic input/output function. The port direction controller can define the port pin as input or output. RB and RC are 8-pin input/output programmable interfaces respectively. Each I/O port can provide or absorb 20mA of current, can directly drive light-emitting diodes and solid-state relays, and has a watchdog circuit. It has the characteristics of simple external circuit structure, easy use, and reliable performance. The power factor is directly output by the microcontroller through a 4-bit red high-brightness digital tube to display the power factor with a display accuracy of 0.001.
The three detection voltages are input to the microcontroller through the RA0, RA1, and RA2 pins of the input interface RA. The power factor is first converted into a digital signal by the A/D converter and saved, and the converted data is displayed in real time through the RC and RB interfaces. In addition, it can also communicate with the monitoring system through the serial interface to transmit the power factor of the line to the monitoring system in a timely manner. There are currently two commonly used serial communications [5], one is RS-232 serial communication, and the other is RS-485 serial communication. However, since the serial input and output interfaces of the PIC16F877 microcontroller are both TTL or CMOS levels, and the PC of the monitoring system is usually an external bus standard serial interface of the RS-232 specification and uses negative logic, the serial input and output interface levels of the PIC16F877 microcontroller do not match and need to be converted. Here, the MAX232 chip is used to implement the level conversion function. The peripheral circuit of the MAX232 chip is simple, and only four 0.1μF capacitors are needed.
4. Software Design [6]
The main task of the software is to complete A/D conversion, data calculation, display and communication. For convenience, the software is written in a modular structure. The main program mainly includes program initialization, subroutine calling, display, etc.

(1) A/D conversion subroutine
This subroutine mainly selects the A/D input channel and the A/D conversion clock; sets the A/D interrupt and opens the corresponding interrupt enable bit; waits for the required sampling time; starts the A/D; waits for the A/D to complete; reads the A/D conversion result and stores it in the specified storage unit.
(2) Digital filtering subroutine
In order to avoid the interference noise generated in the industrial field causing errors in the power factor measurement, digital filtering is added during software design. There are usually many digital filtering methods, and the median filtering method is used here. That is, the voltages U1, U2, and U3 are sampled continuously for 5 times, and then these sampled values ​​are sorted and the middle value is selected. This filtering method is more effective in filtering out pulse interference.
(3) Operation subroutine
First, the voltages U1, U2, and U3 after digital filtering are read in, and then the square operation is completed through the multiplication instruction to obtain U12, U22, and U32, and then the subtraction, multiplication, and division operations are performed to finally obtain

, that is, the measured power factor is obtained.

The task of the communication subroutine is to complete the initialization of serial communication. The synchronous asynchronous receiving and transmitting module (USART) of the PIC16F877 microcontroller uses the RC6 and RC7 pins of the C port as a two-wire serial communication interface. In order to make the USART work in the sending and receiving states respectively, the bit 7 of the receiving state and control register of the USART and the bit 7 of the TRISC register are first set to 1, and the bit 6 of the TRISC register is set to 0. Secondly, to make the USART work in asynchronous communication mode, the sending and receiving rates, i.e., the baud rate, must also be set. Finally, by setting the bit 4 of the sending state and control register TXSTA to "0", the USART is made to work in asynchronous communication mode.
5. Experiment and result analysis
In order to verify the accuracy of the online measurement of power factor, the author built a test platform as shown in Figure 4, where COSϕ is a single-phase power factor meter with an accuracy level of 0.2. During the experiment, two different loads, incandescent lamps and electric fans, were used as measurement objects to carry out power factor measurement experiments, and the experimental results were compared with the readings of the power factor meter.

[page]



Figure 4 Schematic diagram of the test circuit

S1 is the power switch, S2 is the transfer switch. When S2 is closed in the lower position, the direct reading of the power factor meter can be obtained; when S2 is closed in the upper position, the power factor measurement value of the online measurement circuit can be obtained. The test results and calculated values ​​are shown in Table 1.

As shown in Table 1, the measured value obtained by the measurement circuit is very close to the reading of the power factor meter, indicating that the measurement circuit has good measurement accuracy. Incandescent lamps are pure resistive loads, while electric fans are inductive loads. The test shows that the power factor measurement circuit has good versatility and is suitable for both resistive loads and inductive loads. 5 Conclusion
The scheme of measuring power factor based on voltage sampling simplifies the structure of the power factor online detection circuit, reduces the cost, and improves the detection accuracy. In addition, this idea of ​​detecting power factor also has good practical value, because in practice, voltmeters are more common than power factor meters. When there is no power factor meter at hand, the voltmeter can be used to measure the corresponding three voltages. The power factor of the load can also be calculated by formula (2), which solves the difficulty of measuring power factor without a power factor meter and brings great convenience to the measurement of power factor. However, this measurement circuit also has its shortcomings. When measuring, an additional adjustable resistor needs to be connected in series, so the measurement is not very convenient. In addition, it will affect the work of the load. Therefore, when using it, the resistance value should be adjusted as small as possible to obtain an appropriate voltage. Through experiments, we believe that the voltage can be adjusted to about 10V, which can meet the measurement requirements and will not cause too much impact on the load.
The innovation of the author of this article: By sampling the voltage of the circuit under test and calculating the power factor of the circuit under test, the power factor measurement circuit structure is simplified and the measurement accuracy of the power factor is improved. It overcomes the traditional power factor measurement, which requires the detection of voltage and current, and then the voltage and current waveform transformation to obtain the phase difference of voltage and current, and finally the power factor of the circuit under test can be obtained.

References
[1] Liu Xinping, Li Jun. Application of single chip microcomputer in motor power factor measurement [J]. Computer Engineering and Design. 2007, (2): 400-401.
[2] Zhang Jianxiong, Su Hongying, Zheng Wenzheng. Power factor measurement instrument based on electric energy metering chip [J]. Electrical Applications 2006, (4): 76-78.
[3] Qiu Guanyuan, ed., Circuits (4th Edition) [M]. Beijing: Higher Education Press, 1999.
[4] Duan Dapeng, Jiang Xiuchen, Sun Caixin, et al. Digital measurement algorithm of dielectric loss factor based on orthogonal decomposition [J]. Proceedings of the CSEE, 2008, 28(7): 127-133.
[5] He Ankun, Zhang Jingwu, Chen Ming. Implementation of serial communication between inverter and PC based on RS-485 [J]. Microcomputer Information, 2007, 10-1: 98-99.
[6] Cao Yue. Design of methane sensor based on PIC16F877 microcontroller[J]. China Science and Technology Information, 2008 (8): 128-129.

Keywords:MCU Reference address:A Power Factor Online Detection Based on PIC Microcontroller Voltage Sampling

Previous article:Design of On-site Power-free Electronic Password Lock Based on 51 Single-Chip Microcomputer
Next article:Common Problems of C51 Microcontroller in Electronic Circuit Design

Recommended ReadingLatest update time:2024-11-16 23:59

51 microcontroller serial communication uses two methods similar to the printf function
Today I will briefly talk about how to The use of "printf" function in 51 microcontroller: including using the built-in printf function and writing a printf function by yourself. Before pasting the code, I will introduce some relevant knowledge, which is mainly used to write the printf function by yourself. ①C lan
[Microcontroller]
51 microcontroller serial communication uses two methods similar to the printf function
DS1307 interfaces with 8051-compatible microcontrollers
This application note provides information on how to interface the DS1307 real-time clock (RTC) to a microcontroller and provides some example code to access the device. introduce The DS1307 serial real-time clock integrates a 2-wire serial interface and can be controlled using an 8051-compatible microcontroller. Th
[Microcontroller]
DS1307 interfaces with 8051-compatible microcontrollers
A New 51-Core Single-Chip Microcomputer MSC1210 and Its Application
Practical application systems often require high-precision measurements, and must also perform real-time and fast control to improve their development efficiency. For this reason, people often use high-precision A/D chips plus single-chip microcomputer systems with ISP development functions to achieve this. Texas In
[Microcontroller]
A general design scheme for simulating information appliances using single-chip microcomputers
  1 Introduction   Human beings have entered the information age. Information exchange has become a necessity for people's lives and production, and is developing rapidly. Therefore, whether it is mobile phones, PDAs or home appliances, they will eventually be integrated into the network. Traditional IT and tradition
[Microcontroller]
A general design scheme for simulating information appliances using single-chip microcomputers
PIC12F683 Microcontroller Experiment Board
Introduction Electronics is my hobby. When I was in college, I had some experience with microcontrollers, and I did a few projects with Atmel's AT89C51. Lately, I have grown an interest in PIC microcontrollers, and I thought I should start with an 8-pin microchip. I picked the PIC12F683 microchip. This microcon
[Industrial Control]
PIC12F683 Microcontroller Experiment Board
Programming microcontrollers using STVD and Cosmic C compiler
  Pulse width modulation (PWM) is an analog modulation technique in which the duration or width of a pulse varies over time. It is a commonly used technique for generating a continuous pulse signal with a defined frequency and duty cycle. Simply put, PWM changes the width of the pulse while keeping the frequency const
[Microcontroller]
Programming microcontrollers using STVD and Cosmic C compiler
STM32 MCU serial port receives GPS data and parses NMEA GPRMC
The program mainly realizes the full analysis of GPRMC data, including time analysis, position analysis, heading analysis, combination analysis, positioning status analysis, etc. Directly use the stm32 series microcontroller to process the data received by the GPS board to obtain the corresponding information 1. gps.h
[Microcontroller]
Design of intelligent pressure sensor based on 51 single chip microcomputer
  0 Introduction   All the single-chip microcomputers currently compatible with Intel 8031 ​​instruction system are collectively referred to as 51 single-chip microcomputers. Intel's 8031 ​​single-chip microcomputer is the ancestor of 51 single-chip microcomputers. 8031 ​​single-chip microcomputer is one of the most
[Microcontroller]
Design of intelligent pressure sensor based on 51 single chip microcomputer
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号