DIY digital voltmeter on pic. A simple modular AC voltmeter on PIC16F676. Implementation of a network voltmeter from Wali Marat

Simple voltmeter AC voltage with a frequency of 50 Hz, 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
One-sided printed circuit board
Compact design
Display of measured values ​​on a 3-digit LED indicator

Schematic diagram of a voltmeter for measuring alternating voltage


Implemented direct measurement 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!


We continue to understand the options for implementing a voltmeter - ammeter based on a microprocessor.
Don't forget the archive with the files, we will need them today.

If you want to install large indicators, you will have to solve the issue of limiting the current consumption through the MK ports. In this case, it is necessary to install buffer transistors on each digit of the indicator.

Large size indicators


So, the previously discussed circuit will take the form shown in Fig. 2. Three transistors VT1-VT3 of the buffer stage were added for each digit of the indicator. Installed buffer stage inverts the output signal of the MK. Therefore, the input voltage based on VT2 is inverse with respect to the collector of the specified transistor, and therefore is suitable for supplying a comma-forming output to the output. This makes it possible to remove transistor VT1, which was previously in the circuit in Fig. 1, replacing the latter with decoupling resistor R12. Do not forget that the resistor values ​​in the base circuits of transistors VT1-VT3 have also changed.
If you want to install indicators with unconventionally large dimensions, you will have to install low-resistance (1 - 10 Ohms) resistors in the collector circuit of the indicated transistors to limit current surges when they are turned on.

The operating logic of the MK for this option only requires a slight change in the program in terms of inverting the output signal for controlling the bits, namely ports RA0, RA1, RA5.
Let's consider only what will change, namely the subroutine already known to us under the code name “Dynamic indication generation function” in Listing No. 2(see folder “tr_OE_30V” in the archive or the first part of the article):

16. void Indicator ()( 17. while (show_digit< 3) { 18. portc = 0b111111; // 1 ->C 19. if (show_digit == 2)( delay_ms(1); ) 20. porta = 0b100111; 21. show_digit = show_digit + 1; 22. switch (show_digit) ( 23. case 1: ( 24. if (digit1 == 0) ( ) else ( 25. Cod_to_PORT(DIGIT1); 26. PORTA &= (~(1<<0)); //0 ->A0 27. ) break;) 28. case 2: ( 29. Cod_to_PORT(DIGIT2); 30. PORTA &= (~(1<<1)); //0 ->A1 31. break;) 32. case 3: ( 33. Cod_to_PORT(DIGIT3); 34. PORTA &= (~(1<<5)); //0 ->A5 35. break;) ) 36. Delay_ms(6); 37. if (RA2_bit==0) (PORTA |= (1<<2);// 1 ->A2 38. Delay_ms(1);) 39. if ((show_digit >= 3)!= 0) break; 40. ) show_digit = 0;)


Compare both options. The inversion of the signal on the RA port (line 20 of Listing No. 2) is easy to read, since it is written in binary form. It is enough to combine the outputs of the MK and the binary number. In lines 19 and 37, slightly strange conditions appeared that were not there at the beginning. In the first case: “delay the logical zero signal at port RA1 during the indication of the second digit.” In the second: “if there is a logical zero on port RA2, inversion.” When you compile the final version of the program, you can remove them, but for simulation in PROTEUS they are needed. Without them, the comma and the “G” segment will not be displayed normally.
Why? - you ask, because the first option worked great.

In conclusion, remember the words of the blacksmith from the film “Formula of Love”: “...if one person built it, another can always take it apart!”
Good luck!

Reader vote

The article was approved by 27 readers.

To participate in the voting, register and log in to the site with your username and password.

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

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.



What else to read