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 diagram of a voltmeter on a PIC16F676, as well as a printed circuit board and firmware. The voltmeter was used to organize the indication in.

Specifications voltmeter:

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

The design is based on the scheme of the author N. Zaets from the article "Millivoltmeter". 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 run through the main nodes of the circuit. The DA1 microcircuit is an adjustable voltage regulator, the output voltage of which is regulated by an adjusted resistor R4. This solution is not very good, since for normal operation of the voltmeter, a separate 8V DC source is required. And this tension should 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 a burnout of the PIC16F676 - a microcontroller.

Resistors R5-R6 are the input (measured) voltage divider. DD1 is a microcontroller, HG1-HG3 are three separate seven-segment displays, which are collected in one information bus. The use of separate 7-segment displays greatly complicates the PCB. This solution is also not very good. And the consumption of ALS324A is decent.

Figure 2 shows a reworked digital voltmeter circuit diagram.

Figure 2 - Schematic diagram of a DC voltmeter.

Now let's see what changes have been made to the schema.

Instead of the KR142EN12A adjustable integral stabilizer, it was decided to use an LM7805 integral stabilizer 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. If, 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 the 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 reliable reset of the microcontroller.

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

Three transistors have been added to unload the individual microcontroller legs.

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

Table 1 - List of parts for voltmeter on PIC16F676
Positional designation Name Analog / replacement
C1 Electrolytic capacitor - 470mkFh35V
C2 Electrolytic capacitor - 1000mkFx10V
C3 Electrolytic capacitor - 10mkFh25V
C4 Ceramic capacitor - 0.1mkFh50V
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 BC546B bipolar transistor KT3102
XP1-XP2 Pin header to board
XT1 Terminal block for 4 contacts.

Figure 3 - Printed board for voltmeter on PIC16F676 (conductor side).

Figure 4 - PCB side of the placement of parts.

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

As for the firmware, the changes were not significant:

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

The voltmeter, assembled from obviously 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 external view of the voltmeter is shown in Figures 5-6.

Figure 5 - External view of the voltmeter.

Figure 6 - External view of the voltmeter.

The voltmeter considered in the article was successfully tested at home, tested in a car powered from the on-board network. There were no failures. 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 you serviceable components and good luck in manufacturing!

I have been engaged in radio electronics for several years, but I am ashamed to admit that I still do not have a normal power supply unit. I power the assembled devices with whatever comes to hand. From any semi-dead batteries and diode bridge transformers without any voltage stabilization and output current limitation. Such perversions are quite dangerous for assembled structure... Finally I decided to assemble a normal power supply. And he began the assembly with an ampere-voltmeter. Of course, it was necessary to start with something else, but as it is already. Since I am 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 here). A completely solderable connector and generally good performance. In short - a good option for voltage and current meter.

Electrical circuit of a digital ammeter for power supply

Drawing of the digital ammeter board

The first and second lines display the average voltage and current value from 300 ADC measurements. This is for greater measurement accuracy. The third line displays the load resistance, calculated according to Ohm's law. At first I wanted to make the consumed power output, but made resistance. Maybe later I'll convert 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 element of the circuit where there is strong heating.

You can also connect a cooler to the microcontroller to cool the radiator of the transistor. It will change its speed when the temperature measured by the DS18B20 sensor changes. There is a PWM signal on the PB3 leg. The cooler is connected to this pin through 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 does not need to be installed. In this case, the inscription OFF will be displayed in the fourth line. We connect the cooler directly. The PB3 output will be 0.

There are two firmware options 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 amplification factor of the LM358 op-amp is chosen according to the calculations. 10. For different firmwares you need to choose a shunt. Not everyone has the ability to measure hundredths of an ohm and precision resistors. Therefore, there are two trimming resistors in the circuit. 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 bridge has been removed and the size is 5 mm less in height. The stability of the ammeter readings is high. Sometimes it swims only by hundredths. Although only compared with my Chinese tester. That's enough for me.

Thank you all for your attention.

ARCHIVE:

Upgraded option

Added only display of a tenth of the power.

Here I redid it to measure up to 50A. Shunt 0.01 ohm. The op-amp gain is approximately 6 to 7. The resistors will need to be recalculated. 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 disconnect the load when a certain predetermined current is exceeded. The firmware of the improved voltammeter can be downloaded below. Circuit for digital current and voltage meter.

Several details were also added to the scheme. From the controls - one button and a variable resistor rated from 10 kilo-ohms to 47 kilo-ohms. Its resistance is not critical for the circuit, and, as can be seen, it can vary over a fairly wide range. Has changed a little and appearance on the screen. Added display of power and ampere * hours.

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

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

If you have any questions, please contact the forum. Thank you for attention. Bukhar finished the ampervoltmeter.

ARCHIVE:
Forum


We continue to deal with the options for implementing a voltmeter - 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 ports of the MK. In this case, it is necessary to put buffer transistors for each indicator bit.

Large indicators


So, the previously considered scheme will take the form shown in Fig. 2. Added three transistors VT1-VT3 buffer stage for each bit of the indicator. The installed buffer stage inverts the MK output. Therefore, the input voltage based on VT2 is inversely relative to the collector of the specified transistor, which means it is suitable for feeding 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 decoupling resistor R12. Do not forget that the values \u200b\u200bof the resistors in the base circuits of the VT1-VT3 transistors 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 only needs a small change in the program in terms of inverting the output control signal of the digits, namely ports RA0, RA1, RA5.
Let us consider only what will change, namely the subroutine already known to us under the conditional name "Function of generating dynamic indication" 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 \u003d\u003d 2) (delay_ms (1);) 20.porta \u003d 0b100111; 21.show_digit \u003d show_digit + 1; 22. switch (show_digit) (23. case 1: (24. if (digit1 \u003d\u003d 0) () else (25. Cod_to_PORT (DIGIT1); 26. PORTA & \u003d (~ (1<<0)); //0 -> A0 27.) break;) 28. case 2: (29. Cod_to_PORT (DIGIT2); 30. PORTA & \u003d (~ (1<<1)); //0 -> A1 31. break;) 32. case 3: (33. Cod_to_PORT (DIGIT3); 34. PORTA & \u003d (~ (1<<5)); //0 -> A5 35. break;)) 36. Delay_ms (6); 37. if (RA2_bit \u003d\u003d 0) (PORTA | \u003d (1<<2);// 1 -> A2 38. Delay_ms (1);) 39. if ((show_digit\u003e \u003d 3)! \u003d 0) break; 40.) show_digit \u003d 0;)


Compare both options. The inverse of the RA port (line 20 of Listing # 2) is easy to read because it is written in binary. It is enough to combine the conclusions of the MC and the binary number. On lines 19 and 37, a little strange conditions appeared that were not there at the beginning. In the first case: "delay the logical zero signal on the RA1 port while the second bit is indicated." In the second: "if the RA2 port is logical zero, inversion." When you compile the final version of the program, you can delete 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 movie "Formula of Love": "... if one person has built, another can always make out!"
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 voltammetric wattmeter

The printed circuit board on DIP details 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 firmwares: 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 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 is with a common anode, then the resistor is connected 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.

Short press of the button " IN"activates the indication of the operating mode: voltage" -U- ", current" -I- ", power" -P- ", ampere / hour counter" -C- ". 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 the button for 7-8 seconds H"until the indication" -S.- "appears on the display. Then, using the buttons IN"And" H"Adjust the offset" 0 ". If the buttons are pressed, there is a constant on the indicator, released - the corrected current readings. Exit from the mode - pressing the keys simultaneously " IN"and" H". Result - indication" -3- ", that is, writing to non-volatile memory. The ampere / hour counter is reset to zero by holding down the" H"3-4 sec.

In my case, I only put the button " IN", to switch the operating mode. The button" H"I do not put it, since current correction is not required if the op-amp LM358 new, then it has practically no displacement, and if it does, then 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 unit.

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

As a result, the entire construction of the voltampervatmeter cost 150 rubles, without foil-clad fiberglass. Ponomarev Artyom was with you ( stalker68), until we meet again on the site Radio circuits !

Discuss the article VOLTAMPERVATTMETER

The amperevoltmeter 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 the LM2904, the LCD display should 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 ammeter will be built in, it is recommended to cut a window only for the working part of the display on which the information will be displayed. Important! Directly on the displays, as a rule, a current-limiting resistor is installed in the backlight supply circuit. If there is no resistor, then it must be installed independently in the open circuit going to LED +. Resistor resistance 6 ... 100 Ohm depending on the desired backlight brightness ...

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

Photo of the device!



Information display on the display 2x16.

Connecting the ammeter to the power supply.


Close