Voltmeter on PIC16F676 - an article in which I will talk about self assembly digital voltmeter direct current with a limit of 0-50V. The article provides a voltmeter circuit on the PIC16F676, as well as a printed circuit board and firmware. The voltmeter used to organize the indication in.

Specifications voltmeter:

  • The resolution of displaying the measurement result is 0.1V;
  • Error 0.1 ... 0.2V;
  • The voltage supply of the voltmeter is 7 ... 20V.
  • Average current consumption 20mA

The design is based on the scheme of the author N. Zayets from the article "Milivoltmeter". The author himself is very generous and willingly shares his developments, both technical and software. However, one of the significant drawbacks of its designs (in my opinion) is the obsolete element base. The use of which, at the present time, is not entirely reasonable.

Figure 1 shows circuit diagram author's version.

I will briefly go over the main nodes of the circuit. Chip DA1 is an adjustable voltage regulator, the output voltage of which is regulated by a tuned resistor R4. This solution is not very good, since a separate 8V DC source is required for the normal operation of the voltmeter. And this tension must be constant. If the input voltage changes, then the output voltage will change, and this is not acceptable. In my practice, such a change led to the burnout of the PIC16F676 microcontroller.

Resistors R5-R6 is a divider of the input (measured) voltage. DD1 - microcontroller, HG1-HG3 - three separate seven-segment indicators, which are assembled into one information bus. The use of separate seven-segment indicators greatly complicate the printed circuit board. This solution is also not very good. Yes, and the consumption of ALS324A is decent.

Figure 2 shows a redesigned digital voltmeter circuit diagram.

Figure 2 - Schematic diagram of a DC voltmeter.

Now consider what changes have been made to the schema.

Instead of an adjustable integrated stabilizer KR142EN12A, it was decided to use an integral stabilizer LM7805 with a constant output voltage of + 5V. Thus, it was possible to reliably stabilize the operating voltage of the microcontroller. Another plus of this solution is the possibility of using the input (measured) voltage to power the circuit. Unless, of course, this voltage is more than 6V, but less than 30V. To connect to the input voltage, just close the jumper (jamper). If the stabilizer itself is very hot, it must be installed on a radiator.

To protect the ADC input from overvoltage, a Zener diode VD1 was added to the circuit.

Resistor R4 together with capacitor C3 are recommended by the manufacturer for a reliable reset of the microcontroller.

Instead of three separate seven-segment indicators, one common indicator was used.

To unload the individual legs of the microcontroller, three transistors were added.

In table 1, you can find the entire list of parts and their possible replacement with an analogue.

Table 1 - PIC16F676 Voltmeter Parts List
Positional designation Name Analog/replacement
C1 Electrolytic capacitor - 470mkFh35V
C2 Electrolytic capacitor - 1000uFx10V
C3 Electrolytic capacitor - 10mkFh25V
C4 Ceramic capacitor - 0.1mkFx50V
DA1 Integral Stabilizer L7805
DD1 Microcontroller PIC16F676
HG1 7-segment LED indicator KEM-5631-ASR (OK) Any other low-power for dynamic indication and suitable for connection.
R1* Resistor 0.125W 91 kOhm SMD size 0805
R2* Resistor 0.125W 4.7 kOhm SMD size 0805
R3 Resistor 0.125W 5.1 ohm SMD size 0805
R4 Resistor 0.125W 10 kOhm SMD size 0805
R5-R12 Resistor 0.125W 330 Ohm SMD size 0805
R13-R15 Resistor 0.125W 4.3 kOhm SMD size 0805
VD1 Zener diode BZV85C5V1 1N4733
VT1-VT3 Transistor BC546B KT3102
XP1-XP2 Pin header to board
XT1 Terminal block for 4 contacts.

Figure 3 - Printed voltmeter board on PIC16F676 (side of conductors).

Figure 4 - printed circuit board side of the placement of parts.

Figure 4 - The printed side of the placement of parts (the board in the figure is not to scale).

As for the firmware, the changes were not significant:

  • Added disable insignificant digit;
  • The time for issuing the result to the seven-segment LED indicator has been increased.

A voltmeter assembled from known working parts starts working immediately and does not need adjustment. In some cases, it becomes necessary to adjust the measurement accuracy by selecting resistors R1 and R2.

The appearance of the voltmeter is shown in Figures 5-6.

Figure 5 - Appearance of the voltmeter.

Figure 6 - Appearance of the voltmeter.

The voltmeter considered in the article was successfully tested at home, was tested in a car powered by an on-board network. There were no crashes. May be great for long term use.

Interesting video

Let me summarize. After all the changes, it turned out not at all a bad digital DC voltmeter on the PIC16F676 microcontroller, with a measurement limit of 0-50V. To everyone who will repeat this voltmeter, I wish serviceable components and good luck in manufacturing!

I have been doing radio electronics for several years, but I am ashamed to admit that I still do not have a normal power supply. I feed the assembled devices with whatever comes to hand. From all sorts of half-dead batteries and transformers with a diode bridge without any voltage stabilization and output current limitation. Such perversions are quite dangerous for assembled structure. Finally decided to assemble a normal power supply. And I started the assembly with an ammeter. Of course, it was necessary to start with another, but as it already is. Since I'm doing a little programming, I decided to develop a display meter myself. The screen is a display from Nokia-1202. Probably I have already tortured everyone with this display, but it is 3 times cheaper than 2x16 HD44780 (at least for us). Quite a solderable connector and generally good characteristics. Briefly speaking - a good option for voltage and current meter.

The electrical circuit of the digital ampervoltmeter for PSU

Digital ammeter board drawing

The first and second lines display the average value of voltage and current from 300 ADC measurements. This is done for greater measurement accuracy. The third line displays the load resistance calculated according to Ohm's law. At first I wanted to make it so that the power consumption was output, but I made a resistance. Maybe later I'll change it to power. The fourth line displays the temperature measured by the DS18B20 sensor. It is programmed to measure temperatures from 0 to 99 degrees Celsius. It must be installed on the radiator of the output transistor, or on some other circuit element where there is strong heating.

You can also connect a cooler to the microcontroller to cool the transistor heatsink. It will change its speed when the temperature measured by the DS18B20 sensor changes. There is a PWM signal on the PB3 pin. The cooler is connected to this output via a power switch. It is best to use a MOSFET transistor as a power switch. At a temperature of 90 degrees, the fan will have maximum speed. The temperature sensor may or may not be installed. In this case, the fourth line will simply display the inscription OFF. The cooler is connected directly. The output of PB3 will be 0.

There are two versions of the firmware in the archive. One for the maximum measured current of 5 amperes, and the second up to 10 amperes. The maximum measured voltage is 30 volts. The gain of the op-amp LM358 was chosen to be 10 according to the calculations. For different firmware, you need to choose a shunt. Not everyone has the ability to measure hundredths of an ohm and precision resistors. Therefore, the circuit has two tuning resistors. They can correct the measurement readings.

There is also a printed circuit board in the archive. There are slight differences in the photo - there it is slightly corrected. One jumper has been removed and the size is 5 mm smaller in height. The stability of the ampervoltmeter readings is high. Sometimes it floats only in hundredths. Although I compared it only with my Chinese tester. For me, this is quite enough.

Thank you all for your attention.

ARCHIVE:

Upgraded version

Added only the display of a tenth of the power.

Here I redid it for measuring up to 50A. Shunt 0.01 ohm. The gain of the op-amp is approximately 6 to 7. It will be necessary to recalculate the resistors. The fuses are the same as before.

I would like to present to your attention an upgraded version of the indicator for a laboratory power supply. Added the ability to turn off the load when a certain pre-set current is exceeded. The firmware of the improved voltammeter can be downloaded below. Diagram of a digital current and voltage meter.

A few details have also been added to the scheme. From the controls - one button and a variable resistor with a nominal value of 10 kilo-ohms to 47 kilo-ohms. Its resistance is not critical for the circuit, and as you can see it can vary within fairly wide limits. changed a little and appearance on the screen. Added display of power and ampere * hours.

The trip current variable is stored in EEPROM. Therefore, after turning off, you will not need to configure everything again. In order to enter the current setting menu, you need to press the button. By turning the knob of the variable resistor, you need to set the current at which the relay will turn off. It is connected via a transistor switch to the PB5 pin of the Atmega8 microcontroller.

At the time of shutdown, the display will show an inscription that the maximum set current has been exceeded. After pressing the button, we will go back to the maximum current setting menu. You need to press the button again to switch to the measurement mode. Log 1 will be applied to the PB5 output of the microcontroller and the relay will turn on. This current tracking also has its disadvantages. Protection will not work instantly. The operation may take several tens of milliseconds. For most experimental devices, this drawback is not critical. For humans, this delay is not visible. Everything happens at once. A new printed circuit board was not developed. Whoever wants to repeat the device can slightly edit the printed circuit board from the previous version. The changes will not be significant.

For any questions, please contact the forum. Thank you for your attention. The ampervoltmeter was finished by Bukhar.

ARCHIVE:
Forum


We continue to deal with the implementation options for a voltmeter - an ammeter based on a microprocessor.
Do not forget the archive with the files, we will need them today.

If you want to put 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 put buffer transistors on each bit of the indicator.

Large indicators


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

The logic of the MK for this option needs only a slight change in the program in terms of inverting the output signal of the bit control, namely the ports RA0, RA1, RA5.
Let us consider only what will change, namely the subroutine already known to us under the conditional name “Dynamic Display Formation Function” in Listing #2(see the 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 signal inversion on port RA (line 20 of Listing #2) is easy to read because it is written in binary form. It is enough to combine the conclusions of the MK and the binary number. In lines 19 and 37, a little strange conditions appeared that were not there at the beginning. In the first case: "delay the logic zero signal on the RA1 port during the indication of the second bit." In the second: "if the RA2 port has a logical zero, inversion." When you compile the final version of the program, you can remove them, but they are needed for simulation in PROTEUS. 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 has built, another can always take it apart!".
Good luck!

Reader's vote

The article was approved by 27 readers.

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

Today I will 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 voltammeter

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 marked 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 is with a common anode, then we connect the resistor to the common wire.

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

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

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

We connect power to the assembled device, apply the measured voltage and current, adjusting the readings of the voltmeter and ammeter with trimmer resistors according to the readings of the multimeter.

As a result, the entire design of the voltammeter cost 150 rubles, without foil fiberglass. Ponomarev Artyom was with you ( stalker68), see you soon on the pages of the site radio circuits !

Discuss the article VOLTAMPERVATTMETER

The ampervoltmeter is designed to measure current 0-9.99A and voltage 0-100V with a resolution of 0.01A and 0.1V, respectively.

The op amp can be replaced with LM2904, the LCD display must be on the HD44780 controller. The number of characters is 2x8... You can also use a 2x16 character display, but in this case most of the display will remain unused. In such a situation, in the device where the ampervoltmeter will be built in, it is recommended to cut a window only under the working part of the display on which information will be displayed. Important! Directly on the displays, as a rule, a current-limiting resistor is installed in the backlight power circuit. If there is no resistor, then you need to install it yourself in the open circuit going to LED +. Resistor resistance 6 ... 100 Ohm, depending on the desired brightness of the backlight ...

Setting up the device is simple: - first, with the "contrast" resistor, we set the required display contrast, and with the "set U" and "set I" resistors, we adjust the accuracy of the readings of the voltmeter and ammeter. It is desirable to make adjustment at the upper limits of the readings of the voltmeter and ammeter. If, after adjustment, the ammeter without load displays any current value, we select the operational amplifier so that the current value is 0.00A without load!

Photo device!



Display of information on the display 2х16.

Connecting the ammeter to the power supply.


close