This article introduces the development of a USB DC power meter.
On the basis of the presented circuit of the voltmeter and the firmware of the PIC18F2550 microcontroller , a USB program was created, which could consider electricity, for a circuit with constant resistance. Since the constant energy meters are rare and expensive (20-30 thousand rubles in Russia and 6-10 thousand rubles in China and India), we decided to make a meter that would be suitable for our laboratory research, which eventually amounted to no more than 400 rubles., by component. They made a meter for measuring and comparing the energy of recovery in electric motors of different designs, but of the same power, it can also be used as a meter of energy received from a wind generator, solar batteries and other sources of direct current energy. A written program can read not only kW * h, but also watt * h, watt * s, etc ...
The assembled circuit included a voltage divider, which was also a design resistance (highlighted in red)
')

Which was entered into the USB-program (highlighted in red):

The value of the voltage multiplier is highlighted in blue, it can be obtained before measurements using the formula specified here:
bit.ly/1oNddey . Or pick up on a multimeter, that is, measuring the battery voltage with a multimeter, and then enter a voltage multiplier value so that the USB program (using our meter) shows the same voltage on the multimeter on the same battery.
The resistance value of the voltage divider can be selected for the transmission of large and small currents. A voltage divider is still needed if we apply a voltage of more than 5 volts, more than 5 volts cannot be applied to the microcontroller, so a voltage divider is needed.
It is worth noting that the circuit in Proteus is different from the circuit, which is made in the gland. VCC (red USB wiring) will not go on 1 foot, but on PIC's 20 foot. Also in the scheme for Proteus 8 and 19 legs are not drawn, in iron 8 or 19 (by choice) it is necessary to take it to the ground.


Counter, you can improve if you change the firmware of the microcontroller, so that the microcontroller measures the current value (using a current sensor) in the circuit and feeds them into the USB program, and the resistance value of the circuit disappears into the manual.

In order for the USB program to work, you need to install
Framework 4.0 or later. If we turn on the USB-program on Windows 7 or 8, then we need to enable it, as from the Administrator.
The USB program can process an unlimited number of connected counters, for this you need to choose to open the program and once again select the HID-compatible device from the list down (highlighted in black). The devices will list down in the order in which they are included in the computer.

In the USB program, you can also set the noise voltage threshold (highlighted in green), which will take for 0 volts all values not exceeding the selected one for the noise threshold in the example indicated 0.05 V.

It is noticed that in Windows XP, sometimes the program may not work. To do this, you need to clear the event log in front of the DC energy meter, how to clean it, and where it is located
here .
Algorithm USB-program to calculate the energy of DC:
The USB program receives the measured voltage from the microcontroller, then divides it into the input resistance, a current is obtained. After that, the measured voltage is multiplied by the input value of the voltage multiplier, the actual voltage is obtained, which is fed to the counter up to the divider. This real voltage is multiplied with the current and integrated over time, the energy value is obtained.
Link to USB program:
yadi.sk/d/CMS6Up4ZJzDYfLink to the source code of the si USB program
github.com/neremin/USB_VoltmeterLink to the circuit simulation in Proteus, and to the PIC controller firmware for quartz 20 Mhz:
yadi.sk/d/c76mzfURM9PqGLink to firmware sources (asm, c) and firmware for quartz 4 Mhz:
yadi.sk/d/wA4p7RFjM9Qk2USB program development:
Nikolay EreminProject management:
Julian BaryshnikovThanks:
Moty Mizrachi for the disinterested presentation of a USB voltmeter on his website, as well as correspondence tips.
Roman Verinsky and Vitaly Pavlov for disinterested help and advice on soldering and flashing microcontrollers.
Vitaly Azarov for disinterested advice on formulas and constructing a scheme for measuring DC energy.
Urry for disinterestedly checking the circuit in the gland and fixing the firmware for quartz 20 Mhz.
Alexandra Medyanikova for disinterested photographing the finished circuit in the gland.