Voltammeter on PIC16F676. DIY radio engineering, electronics and circuits

Implementation of a voltmeter from Vladimir

Added switches to the indicator anodes, which increased the brightness of the display and allows the use of more powerful displays.

Two signets for DIP14 and SO14

The circuit uses BC847 (KT3102) transistors.

During the update of the main article on the voltmeter, the voltage divider was replaced in the circuit and seals from Vladimir. Firmware for the voltmeter is in the main article.

Implementation of a network voltmeter from Wali Marat

The signet differs from the circuit by replacing resistors R2 and R3 with one 4.7k trimmer and the absence of a zener diode VD1.

A modified network voltmeter circuit was also sent; it features a better-quality circuit for stabilizing the voltmeter's supply voltage.

Photo of a network voltmeter

Implementation of a voltmeter/ammeter from Wali Marat

A 5.1V zener diode VD1 (indicated in green) was added to all circuits from Wali Marat to protect the ADC input of the microcontroller from overvoltage.

The device presented here will be useful if you have a power supply with an output voltage of 0-10 V. These are the measurement limits that are “integrated” into the circuit shown in the figure. It is based on an Atmega8 (U1) microcontroller in a standard DIP package. It may seem cumbersome, but was chosen due to its wide popularity, and also because programmers for this microcontroller are very common. Atmega8 is used by most radio amateurs and on the Internet you can find many circuits with this microcontroller. Therefore, if you do not like this voltmeter, Atmega8 will not remain idle.

Digital voltmeter on Atmega8. The scheme is basic.

The voltmeter measurement will be displayed on a digital seven-segment three-digit indicator (DISP1). I'll give you some information about it.

7-segment digital LED indicator is an indicator consisting of seven LEDs installed in the shape of the number 8. By turning on or off the corresponding LEDs (segments), you can display numbers from zero to nine, as well as some letters. Typically, several digital indicators are used to create multi-digit numbers - for this, the indicators are equipped with a comma (dot) segment - dp. As a result, one indicator has 8 segments, although they are called 7-segment based on the number of digital segments.

Each indicator segment is a separate LED, which can be turned on (lit) or off (not lit) depending on the polarity of the voltage supplied to them. Indicators are available with both a common cathode and a common anode. We are talking about the common connection of all LEDs (segments). In addition, indicators can contain several digits, in which case each digit is called a digit or sign. For example, a three-digit (three-digit) seven-segment indicator contains three digits. This is exactly the kind of indicator you will need for this device.


The design uses a red glow indicator GNT-2831BD-11 with a common anode. Resistors R1-R8 determine the current in the indicator and, therefore, its brightness. Their resistance should not exceed the maximum output current (40 mA), even when all 8 LEDs are lit at once. The circuit uses a single-ended 10-bit ADC (analog to digital converter) located in the AVR. The output value range is 0-999. When the limit of these values ​​is reached, the symbol "---" will appear.

At the input of the voltmeter (in) a voltage divider is installed from resistors R9, R10 and R11, providing a measurement range of up to 10 V with an error of 0.01 V. At pin 23 of the microcontroller U1, the divider generates a voltage that should not exceed 2.5 V. Input resistance voltmeter is close to 1mOhm. To calibrate the voltmeter, apply a precisely known voltage to its input and, by moving the trimming resistor R11, achieve the same readings on the indicator.

The voltmeter update rate is about 4 Hz. The circuit is powered by a stabilized 5 V source. The current consumption of the device is about 25 mA (most of the consumption is in the indicator). Place components C1 and C2 as close to the microcontroller as possible.

Correctly set bits are shown in the figure below.


If you need measurement limits up to 100 V, change the value of R10 to 9.1 mOhm and R11 to 2.2 mOhm. Then you will get the desired measurement range with an error of 0.1 V and an input resistance of about 10 mOhm. In this case, you will have to change the location of the indicator point so that it is displayed behind two symbols, and not behind the first, as in the diagram. To do this, leave pin 28 of the U1 chip free, and connect pin 27 to the common wire. Now, instead of characters in the form 0.00, 00.0 will be displayed.

In addition, it is possible to use one or two indicators. Moreover, if four digits are used, then the rightmost digit displays the stylized units of measurement “V” or “A”. But, there is a limitation on the use of indicators with OA. When the emitter followers are turned on in this way, the indicators become illuminated by measuring currents. Thus, with a 2-indicator circuit, it is advisable to use indicators with OK, in which case the measured currents will not affect the opening of the transistor switches.
If buttons are installed, then pressing button "B" on the left indicator will display the current mode of this indicator, "-U-" or "-I-". Further holding will change the mode. For a version with one 3-digit indicator, this function will help you remember what mode the device is in, and for a 2-digit indicator version, it will swap the displayed voltage and current values. In any case, the function of suppressing insignificant zeros is applied to the voltage, i.e., if the voltage does not exceed 9.9V, then we will not see the first zero (“_Х.Х”) on the indicator.
Kn "N" allows you to enter the current offset correction menu. This may be necessary if, to improve the linearity of the current readings, the op-amp was shifted to the linear section. Thus, by correction you can remove “extra” readings. After briefly pressing the button on the left indicator (if there are two of them), the message “ShI” (current offset) will appear and the indicator will begin to flash. While it is flashing, you can use the buttons to adjust the offset. After a few seconds, the indicator will stop flashing and the data will be written to non-volatile memory. At the same time, the indicator display mode will be saved in memory, which will appear the next time you turn it on.
Displayed voltage 0.0...99.9V, current 0...99.9A (or 0.0...9.99A, depends on the firmware file and OS settings of the op-amp).

Refinement of the current meter assembly:

The author of the improvement is impuls. Simsim idea.
The whole point is to organize the op-amp bias into the linear section,
followed by correction of the readings in the service menu.



You do not have access to download files from our server
PP files for 2x3 and 2x4 indicators, kindly provided by evg339

PP files for 2x3 and 2x4 indicators placed vertically, reworking the PP from evg339, kindly provided by VolosKR


You do not have access to download files from our server


You do not have access to download files from our server


You do not have access to download files from our server

Firmware file for indicators with OA
You do not have access to download files from our server
Firmware file for indicators with OK
You do not have access to download files from our server

Modification of the input voltage divider:


Attention! Divisor by 10


Firmware file below


The polarity of the indicators determines the position of the 1K resistor with 11 n. controller.

Option with measuring inputs for voltage - RA0 and current - RA1^

Firmware file for example, 1:10 i.e. up to 50V, 2x3.2x4.1x3.1x4 indicators and measuring inputs 13 and 12 controller legs You do not have access to download files from our server

Firmware file for example, 1:20 i.e. up to 100V, 1x3.1x4 indicators and measuring inputs 13 and 12 controller legs. You do not have access to download files from our server

Firmware file for example, 1:20 i.e. up to 100V, current measurement, 1x3, 1x4 indicators and measuring inputs 13 and 12 of the controller legs have been changed. You do not have access to download files from our server

Yes! There is no need for a voltage trimmer. Now, let's build with buttons.

Coviraylhik summed it up (thanks to him):

vaDCw2L8UAra0ra1.hex small letter v, div. e.g., 1:10 to 50V,
vaDCw2L4ra01.hex is for one indicator (select V,A with one button)
vaDCw2L8UAra01i.hex Standard up to 100V _0.0V , 0.00A div. voltage, 1:20
vaDCw2L8UAra01X.hex Standard up to 100V, but point 00.0A moved

A simple alternating voltage voltmeter with a frequency of 50 Hz is made in the form of a built-in module that can be used either separately or built into a finished device.
The voltmeter is assembled on a PIC16F676 microcontroller and a 3-digit indicator and does not contain very many parts.

Main characteristics of the voltmeter:
The shape of the measured voltage is sinusoidal
The maximum value of the measured voltage is 250 V;
Frequency of measured voltage - 40…60 Hz;
The resolution of displaying the measurement result is 1 V;
Voltmeter supply voltage is 7…15 V.
Average current consumption - 20 mA
Two design options: with and without power supply on board
Single Sided PCB
Compact design
Display of measured values ​​on a 3-digit LED indicator

Schematic diagram of a voltmeter for measuring alternating voltage


Implemented direct measurement of alternating voltage with subsequent calculation of its value and output to the indicator. The measured voltage is supplied to the input divider made on R3, R4, R5 and through the separating capacitor C4 is supplied to the ADC input of the microcontroller.

Resistors R6 and R7 create a voltage of 2.5 volts (half the power) at the ADC input. Capacitor C5, of relatively small capacity, bypasses the ADC input and helps reduce measurement errors. The microcontroller organizes the operation of the indicator in dynamic mode based on interruptions from the timer.

--
Thank you for your attention!
Igor Kotov, editor-in-chief of Datagor magazine


🕗 01/07/14 ⚖️ 19.18 Kb ⇣ 238 Hello, reader! My name is Igor, I'm 45, I'm a Siberian and an avid amateur electronics engineer. I came up with, created and have been maintaining this wonderful site since 2006.
For more than 10 years, our magazine has existed only at my expense.

Good! The freebie is over. If you want files and useful articles, help me!

Today I’ll tell you how to make a universal, simple measuring device with the ability to measure voltage, current, power consumption and ampere-hours on a cheap microcontroller PIC16F676 according to the following scheme.

Schematic diagram of a voltamperwattmeter

The printed circuit board on DIP parts turned out to be 45x50 mm. Also in the archive there is a printed circuit board for SMD parts.

For microcontroller PIC16F676 There are two firmware: in the first - the ability to measure voltage, current and power - vapDC.hex, and in the second - the same as in the first, only the ability to measure amperes/hours has been added (not always needed) - vapcDC.hex.

The resistor, indicated in gray on the printed circuit board, is connected depending on the indicator: if we use an indicator with common cathodes, then the resistor (1K) coming from the 11th leg of the MK is connected to +5, and if the indicator has a common anode, then we connect the resistor to the common wire.

In my case, the indicator and the common cathode, the resistor was located under the board, from the 11th leg of the MK to +5.

Briefly press the " button IN"activates the operating mode indication: voltage “-U-”, current “-I-”, power “-P-”, ampere/hour counter “-C-”. Some examples of op-amp LM358 have a positive offset at the output, it can be compensated by digital correction of the meter. To do this, you need to switch to current measurement mode, “-I-”. Hold the " button for 7-8 seconds N" until the inscription "-S.-" appears on the indicator. Then use the " IN" And " N» adjust the offset “0”. If the buttons are pressed, the indicator directly shows a constant; when pressed, the current readings are corrected. Exit the mode - simultaneously pressing the keys " IN" And " N". The result is the indication “-3-”, that is, recording in non-volatile memory. The ampere/hour counter is reset by holding the " button N" 3-4 sec.

In my case, I only put the button " IN", to switch the operating mode. Button " N"I don’t put it, since current correction is not required if the op-amp LM358 new, then it has practically no displacement, and if it does, it is insignificant. I do not put the segment indicator on a separate board, which can be easily attached to the device case, for example, built into a converted ATX power supply.

We connect power to the assembled device, supply the measured voltage and current, adjusting the voltmeter and ammeter readings using trimming resistors according to the multimeter readings.

As a result, the entire construction of the voltamperwattmeter cost 150 rubles, without foil fiberglass. Ponomarev Artyom was with you ( stalker68), see you again on the pages of the site Radio circuits !

Discuss the article VOLTAMPERWATTMETER