Thursday, 23 February 2017

How to use Arduino to measure the real power (Program)

After making sure that the analog input 1 is connected to the output of ACS712 and the analog input 2 is connected to the output of the adjusting voltage circuit, the next step is using Arduino UNO to help to calculate out the real power value.


Figure 1 Arduino UNO Pin Mapping

Real power is the average of instantaneous power. The calculation is relatively straightforward:

Firstly, the instant power can be calculated out by multiplying the instant voltage measurement by the instant current measurement. After that, the instant power measurement can be summed over a given number of samples and divide by that number of samples:

    Calibration Theory for Voltage Part

As the voltage value going into the analog pin of Arduino UNO is not the real voltage, the calibration should be setup.

Referring to the circuit diagram above,
counts = (input pin voltage ÷ 3.3) × 1024
input pin voltage = transformer output voltage ÷ 11
transformer output voltage = mains voltage × transformer ratio
After simplify,
counts = mains voltage ×(transformer ratio×1024)/(3.3×11)
main voltage = counts ×(3.3/1024)×(11/transformer ratio)

The part of (11/transformer ratio), which can be calcuted out from the hardware part, will be 185.9, which is proved after a lot of testing.
Notes, the voltage transformer output is nominally 9 V for 230 V input, but this is at full load. When used as a voltage monitor, it is effectively running unloaded, and the voltage is approximately 20% higher (the value depends on the design of the transformer. 20% is typical for this type and size).

    Calibration Theory for Current Part

As the voltage value going into the analog pin of Arduino UNO is converted after the component of ACS712, the calibration should be setup.

Referring to the circuit diagram above,
counts = (input pin voltage ÷ 3.3) × 1024
input pin voltage = primary current × Sensitivity
After simplify,
counts = primary current ×(sensitivity×1024)/3.3
primary current = counts ×(3.3/1024)×(1/sensitivity)

The part of (1/sensitivity), which can be calcuted out from the hardware part with referring to the data ship of ACS712, will be 17.49, which is proved after a lot of testing.

Calibration Setup
After making sure the calibration value, the next step is adding them into the Arduino program and double confirm the value through comparing with the real value.

    Measure the real power for 1 second

Referring to the program below, the while loop for reading the voltage and current signal is depending on two conditions. The number of crossing in this project is 20. The value of the timeout is 200ms. That means it will go out of the while loop when the count of cross is bigger than 20 or time up.
Calculation:
20 No. of half wavelengths = 10 full wavelengths
1 / 50Hz = 20ms
10 × 20ms = 200ms = 0.2s
The reason for setting the value of time-out is 200ms is making sure it will go out of the while loop every 200ms.
0.2s × 5 = 1s
For measuring the real power for 1 second the for loop is used to accumulate the real power 5 times and then divide by 5.

No comments:

Post a Comment