Voltmeter at peak. Built-in ampere-voltmeter on PIC12F675 and LED indicators. Schematic diagram of a voltmeter for measuring alternating voltage

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 signets 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.

Schematic diagram and description of a homemade digital ammeter made on an ATtiny13 microcontroller, program and printed circuit board.

Once upon a time, the author of these lines came across a very interesting device, born in the USSR, back in 1976 - it was simply given away as unnecessary. This device was called ADZ-101U2, and it was a typical example of Soviet constructivism: a heavy twenty-kilogram “suitcase” with a carrying handle at the top and a powerful single-phase transformer inside.

But the most interesting thing is that this “suitcase” completely lacked a back panel - and not at all because the device managed to “sow” it, no. And the point here was that both of its panels were... front! On one side, the “suitcase” was a welding machine, and on the other, a charger for car batteries.

And if, as a “welder”, he didn’t evoke any special emotions, that’s okay, since there’s only 50 A of alternating current; then a “charger” is definitely a necessary thing in the household. Tests of the device confirmed its full combat capability (even welding worked!), but, of course, it was not without its drawbacks.

The essence of the problem was that the standard ammeter of the “charger” disappeared in an unknown direction, and the previous owner of the device found a completely “equivalent” replacement for it - a car ammeter, twisted from some kind of military truck, and having a very “informative” scale of ±30 A!

It is clear that monitoring the battery charge (and the charging current is only 3-6 A!) using such a device is, to put it mildly, problematic - it’s as if it doesn’t exist at all...

Therefore, it was decided to replace the “truck display meter” with some more or less adequate device, with a clear scale of 0-10 A. An ideal candidate for this role seemed to be a dial panel ammeter with a built-in shunt - one of those that had previously been used in almost all Soviet-made “chargers”, and many other places.

However, the very first walk through electrical stores and “breakdowns” brought disappointment: it turns out that nothing even remotely resembling the desired device has been on sale for a long time...

And so, at that time the author was not yet familiar with the endless expanses of Chinese miracle sites, so his hands again reached for the soldering iron, as a result of which a device was developed, the diagram of which is shown in Fig. 1, and the characteristics are in Table 1:

Table 1. Device characteristics.

Schematic diagram

To display the measurement results in this ammeter, it was decided to use a pair of 7-segment LED indicators. Such indicators, despite being somewhat archaic compared to newfangled LCD modules of the 16xx type, also have a number of undeniable advantages: they are much more reliable and durable; do not deteriorate and do not become cloudy from contact with petroleum products (and oily hands in the garage are a common thing, the numbers on LED indicators are brighter and much more “readable” - especially from a distance; and besides, LEDs are not afraid of any cold in the garage - unlike An LCD that simply “goes blind” in the cold.

Well, the last argument in favor of the LED matrix - in the context of this development - was the fact that the long 1602 simply did not fit into the standard hole for the ammeter (round and very small!) on the charger housing. Having decided on the type of indicator, another question arose - which microcontroller to use as the basis for this device.

There was no doubt that this circuit needed to be built specifically on an MK - making an ammeter on a “CMOS scattering” could damage your mind. At first glance, the most obvious solution is the “workhorse” ATtiny2313 - this MK has a fairly developed architecture and a quite suitable number of input/output lines for connecting an LED matrix.

However, here everything turned out to be not so simple - after all, to measure current, the MK must include an analog-to-digital converter, but for some reason Atmel engineers did not equip the “2313th” with this function... The Meda family is a different matter: these chips necessarily have an ADC module “on board”.

But, on the other hand, even ATMega8v - as the simplest representative of the “older” family - has much greater functionality than is required by the construction of a simple ammeter. And this is no longer the best solution from the point of view of the classical approach to design!

The “classical approach to design” here means the so-called “principle of the necessary minimum” (the author of these lines is an ardent supporter of which, in defiance of the newfangled “Arduins”), according to which any system should be designed using the minimum possible amount of resources; and the final result should contain as few unused elements as possible. Therefore, in accordance with this principle - a simple device - a simple microcontroller, and nothing else!

True, not all simple MKs are suitable for the task. Take ATtinyl3, for example - it has an ADC, it is simple and inexpensive; Yes, it’s just that it doesn’t have enough input-output lines - for connecting a matrix of two “seven-segment devices” ...

Although, if you dream up a little, then this problem can be completely solvable - with the help of a penny counter K176IE4 and a simple algorithm that controls this counter.

In addition, this approach even has positive aspects - firstly, there is no need to “hang” a current-limiting resistor on each segment of the indicator (current generators are already available in the output stages of the meter); and secondly, in this circuit you can use an indicator with both a common cathode and a common anode - to switch to a “common anode” you need to change the connection of transistors VT1 and VT2, pin. 6 DD2 is connected to the +9 V line through a 1 kOhm resistor, and the left pin of R3 is connected to ground.

Rice. 1. Schematic diagram of a homemade ammeter (up to 10A) on an ATtiny13 microcontroller.

In order to control the counter using an MK, you need to use only two lines: one for the counting signal (C), and the other for the reset signal (R).

Moreover, during testing of the device, it turned out that the K176IE4 CMOS chip, being connected directly to the MK lines, works quite reliably with its TTL levels - without any additional coordination.

And two more MK lines control the VT1-VT2 keys, creating a dynamic indication. A source code fragment where the DD2 counter control procedure is implemented is shown in the listing:

Rice. 2. Control procedure for K176IE4.

The procedure is written in the low-level language AVR-Assembler; however, it can easily be translated into any high-level language. In the Temp register, the procedure receives a number that must be sent to the K176IE4 counter to be displayed on the indicator; line 1 of port B of the microcontroller is connected to the counter reset input (R), and line 2 is connected to its counter input (C).

To avoid flickering of numbers at the moment of switching the counter, before calling this procedure, it is necessary to extinguish both bits by closing transistors VT1 and VT2 by applying log.O to lines 0 and 4 of ports B of the MK; Well, after the procedure has worked, you can already light one or another indicator digit. By the way, thanks to the K176IE4 counter, you can connect a 7x4 indicator matrix to any MK, using only 6 I/O lines (two for controlling the counter, and four more for dynamic switching of bits).

And if you add another counter to the K176IE4 as a “partner” - the ten-day counter K176IE8 - to use it to “scan” the discharges; then it will be possible to connect an indicator matrix of up to 10 acquaintances to the MK, allocating for this only 5 input-output lines (two for controlling the K176IE8; two for the K176IE4; and one more for extinguishing the indicator at the time of counting the K176IE4)!

In such a case, the dynamic indication algorithm will be reduced to controlling the K176IE8 counter, which is in many ways similar to the algorithm for transmitting a digit to the K176IE4 counter, given in the listing above.

The disadvantages of such a connection of the indicator matrix - in addition to the use of an "extra" microcircuit - include the need to introduce additional +9 V power supply into the circuit, because attempts to power CMOS counters from +5 V, alas, were unsuccessful...

Almost any dual “seven-segment” device with common cathodes, designed for operation in circuits with dynamic indication, can be used as an indicator in this device. It is also possible to use a four-bit matrix, using only two of the four available bits.

True, in the process of working on the ammeter circuit, a small problem arose - with connecting the decimal point: after all, it should light up in the high-order digit, and not light up in the low-order one.

And if you do everything “wisely”, then it would be nice to allocate - for dynamic control of this very comma - another leg of the MK (since the K176IE4 does not provide any means for controlling commas) - in order to “hang” the indicator output on it , responsible for commas.

But, since all the I/O lines of the MK were already occupied, we had to deal with this problem in a far from elegant way: it was decided to leave both commas constantly lit, powering the corresponding output of the indicator “matrix” from the +9 V line through the current-limiting resistor R3 ( by selecting its resistance, you can equalize the brightness of the glow of the comma relative to the other segments); and simply cover up the extra comma in the low order (far right) with a drop of black nitro paint.

From a technical point of view, such a solution can hardly be called ideal; but a comma “made up” in this way does not catch the eye at all...

Two parallel connected resistors R1 and R2, each with a power of 5 W, are used as a current sensor. Instead of a pair of R1 and R2, it is quite possible to install one resistor with a resistance of 0.05 Ohm - in this case, its power should be at least 7 W.

Moreover, the microcontroller firmware provides the ability to select the resistance of the measuring shunt - both a 0.05-ohm and a 0.1-ohm current sensor can be used in this circuit.

In order to set the microcontroller the resistance of the shunt used in a particular case, it is necessary to write a certain value into the EEPROM memory cell located at address 0x00 - for a resistance of 0.1 Ohm this can be any number less than 128 (in this case the MK will divide the result measurements by 2); and when using a shunt with a resistance of 0.05 Ohm, a number greater than 128 should be written into this cell, accordingly.

And if you plan to operate the device with the 0.05-ohm shunt shown in the diagram, then you don’t have to worry about writing the specified cell at all, because a new (or “erased to zero”) MK will have the number 255 (0xFF) in all memory cells.

The device can be powered either from a separate source - with a voltage of at least 12 V, or from the power transformer of the charger itself. If the power is supplied from the charger transformer, then it is advisable to use a separate winding for this, which is in no way connected with the charging circuit; however, it is allowed to power the ammeter from one of the charging windings.

In this case, the supply voltage must be taken before the rectifier bridge of the “charger” (i.e., directly from the winding), and a 75 Ohm/1 W resistor must be connected to the break of both ammeter power wires. Resistors are necessary to protect the “negative” diodes of the VD1-4 bridge from the passage of part of the charging current through them.

The fact is that if you connect the device to the charging winding without installing these resistors, then, taking into account the common “ground” of the VD1-4 bridge and the diode bridge of the charger, about half of the battery charging current will return to the winding not through the powerful diodes of the charger rectifier, and through the “negative” arm of the bridge VD1-4, causing strong heating of low-power 1N4007.

Installing these resistors will limit the supply current of the device and protect the diode bridge VD1-4 from the flow of charging current, which now, almost completely, will flow along the “correct” circuit - through the powerful diodes of the charger rectifier.

Schematic diagram

The printed circuit board for this ammeter was developed for specific seats in the housing of a specific charger; its drawing is shown in Fig. 3.

The indicator matrix is ​​installed separately - on a small plate (a 30x40 piece of “breadboard”), which is attached to the main board with M2.5 bolts through spacer bushings, on the installation side; and connects to it with a 10-wire cable.

Another part of the resulting “sandwich” is a decorative front panel made of plexiglass, painted on the reverse side with nitro paint from a can (only a small rectangle - a “window” for the indicator) should remain unpainted.

The front panel is also attached to the main board from the installation side (with M3 bolts with spacer bushings - they also attach the device to the charger housing). The printed traces of the high-current circuit going to resistors R1 and R2 should be made as wide as possible, and the leads of the resistors should be soldered to them for the entire length, at the same time reinforcing the installation with a thick layer of solder.

It is advisable to use two M3 bolts as leads for connecting the device to the charger, soldering their heads to the board and securing them on the other side with nuts.

Rice. 3. Printed circuit board for a digital ammeter circuit on a microcontroller.

Program

When writing “firmware” to the MK, it must be configured to operate at a frequency of 1.2 MHz, from the internal clock generator. To do this, the clock frequency should be selected equal to 9.6 MHz, and the internal clock divider should be enabled by 8.

To increase operational reliability, it is also advisable to activate the internal power supervisor (BOD module), setting it to reset the MK when the supply voltage drops below 2.7 V.

All settings are made by writing the corresponding values ​​to the configuration Fuse cells: SUT1=1, SUT0=0, CKDIV8=0, BODLEVEL1 =0, BODLEVELO=1, WDTON=1. The rest of the "fuses" can be left as default.

Firmware for microcontroller and printed circuit board in Sprint Layout format - Download.

Rice. 3. Ammeter board for Attiny13 assembled.

Rice. 4. Ammeter board on Attiny13 assembled (view from the back).

Last summer, at the request of a friend, I developed a circuit for a digital voltmeter and ammeter. According to the request, this measuring device must be economical. Therefore, a single-line liquid crystal display was chosen as indicators for displaying information. In general, this ampere-voltmeter was intended to monitor the discharge of a car battery. And the battery running on the motor of a small water pump was running low. The pump pumped water through the filter and again returned it over the pebbles into a small pond in the country.

In general, I did not delve into the details of this quirk. Not long ago, this voltmeter came into my hands again to finalize the program. Everything works as expected, but there is one more request to install an LED to indicate the operation of the microcontroller. The fact is that one day, due to a defect in the printed circuit board, the power to the microcontroller was lost, naturally it stopped functioning, and since the LCD display has its own controller, the data previously loaded into it, the voltage on the battery and the current consumed by the pump , remained on the indicator screen. Previously, I had not thought about such an unpleasant incident; now I will have to take this matter into account in the program of devices and their circuits. Otherwise, you will admire the beautiful numbers on the display screen, but in reality everything has already burned out long ago. In general, the battery was completely discharged, which, as he said, was very bad for a friend then.
The diagram of the device with an indicator LED is shown in the figure.

The circuit is based on a PIC16F676 microcontroller and an LCD indicator. Since all this works exclusively in the warm season, the indicator and controller can be purchased at the cheapest. The operational amplifier chosen was also appropriate - LM358N, cheap and having an operating temperature range from 0 to +70.
To convert analog values ​​(digitize) voltage and current, a stabilized microcontroller supply voltage of +5V is selected. This means that with ten-bit digitization of an analog signal, each bit will correspond to - 5V = 5000 mV = 5000/1024 = 4.8828125 mV. This value is multiplied by 2 in the program, and we get 9.765625 mV per one bit of binary code. And for the correct display of information on the LCD screen, we need one digit to be equal to 10 mV or 0.01 V. Therefore, scaling circuits are provided in the circuit. For voltage, this is an adjustable divider consisting of resistors R5 and R7. To correct the current readings, a scaling amplifier is used, assembled on one of the operational amplifiers of the DA1 - DA1.2 microcircuit. The transmission coefficient of this amplifier is adjusted using a 33k resistor R3. It is better if both tuning resistors are multi-turn. Thus, when using a voltage of exactly +5 V for digitization, direct connection of signals to the microcontroller inputs is prohibited. The remaining op-amp, connected between R5 and R7 and the RA1 input of the DD1 chip, is a repeater. Serves to reduce the impact of noise and impulse interference on digitization, due to one hundred percent, negative, frequency-independent feedback. To reduce noise and interference when converting the current value, a U-shaped filter consisting of C1, C2 and R4 is used. In most cases, C2 does not need to be installed.

As a current sensor, resistor R2, a domestic factory shunt of 20A is used - 75ShSU3-20-0.5. With a current flowing through the shunt of 20A, a voltage of 0.075 V will drop across it (according to the data sheet for the shunt). This means that in order for there to be two volts at the controller input, the amplifier gain should be approximately 2V/0.075 = 26. Approximately, this is because our digitization resolution is not 0.01 V, but 0.09765625 V. Of course, it is possible apply homemade shunts by adjusting the gain of the DA1.2 amplifier. The gain of this amplifier is equal to the ratio of the values ​​of resistors R1 and R3, Kus = R3/R1.
And so, based on the above, the voltmeter has an upper limit of 50 volts, and the ammeter has an upper limit of 20 amperes, although with a shunt rated for 50 amperes, it will measure 50A. So, it can be successfully installed in other devices.
Now about the modification, which includes the addition of an indicator LED. Small changes have been made to the program and now, while the controller is working, the LED blinks at a frequency of approximately 2 Hz. The LED glow time was chosen to be 25ms to save money. It would have been possible to display a blinking cursor on the display, but they said that with an LED it would be more clear and effective. Look like that's it. Good luck. K.V.Yu.


.

One of the options for a finished device implemented by Alexey. Unfortunately I don't know the last name. Thanks to him for his work and photos.

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

Voltmeter Specifications:

  • Resolution of measurement result display 0.1V;
  • Error 0.1…0.2V;
  • Voltmeter supply voltage is 7…20V.
  • Average current consumption 20mA

The design is based on the diagram by the author N. Zaets 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 the schematic diagram of the author's version.

I’ll quickly go over the main components of the circuit. Chip DA1 is an adjustable voltage stabilizer, 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 must remain 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 are a divider of the input (measured) voltage. DD1 is a microcontroller, HG1-HG3 are three separate seven-segment indicators, which are collected into one information bus. The use of separate seven-segment indicators greatly complicates the printed circuit board. This solution is also not very good. And the consumption of the ALS324A is decent.

Figure 2 shows a modified circuit diagram of a digital voltmeter.

Figure 2 – Schematic diagram of a DC voltmeter.

Now let's look at what changes have been made to the diagram.

Instead of the adjustable integrated stabilizer KR142EN12A, it was decided to use the LM7805 integrated stabilizer with a constant output voltage of +5V. Thus, it was possible to reliably stabilize the operating voltage of the microcontroller. Another advantage 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, you just need to close the jumper. If the stabilizer itself gets 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 reliable reset of the microcontroller.

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

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

In Table 1 you can see the entire list of parts and their possible replacement with an analogue.

Table 1 - List of parts for the voltmeter on PIC16F676
Position designation Name Analogue/replacement
C1 Electrolytic capacitor - 470μFx35V
C2 Electrolytic capacitor - 1000μFx10V
C3 Electrolytic capacitor - 10μFx25V
C4 Ceramic capacitor - 0.1 μFx50V
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 connector to board
XT1 Terminal block for 4 contacts.

Figure 3 – Printed circuit board for a voltmeter on PIC16F676 (conductor side).

Figure 4 shows the printed circuit board side where the parts are placed.

Figure 4 – Printed side of the board for placing parts (the board in the figure is not to scale).

As for the firmware, the changes were not significant:

  • Added disabling minor digits;
  • The time for issuing results to the seven-segment LED indicator has been increased.

A voltmeter assembled from known working parts starts working immediately and does not require 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 discussed in the article was successfully tested at home and was 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, we got a not 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 good components and good luck in production!

Voltammeter on PIC16F676

This project is a DC ampere-voltmeter (or voltammeter if you prefer). Range - up to 99.9V and 9.9A (or 99.9A, depending on the firmware).


Its peculiarity is that it is built on the widespread PIC16F676 microcontroller, however, despite this, it has the ability to simultaneously display the measured voltage and current on four-character (or three-character) seven-segment indicators, both with a common anode and a common cathode (set one resistor). When using a four-character indicator, the last segment displays the symbol "U" for voltage and "A" for current. The ampere-voltmeter can also work with one indicator, and with the “B” button you can select what will be displayed on it - voltage or current. If both indicators are installed, you can use this button to swap their assignments. The "H" button is used to correct the ammeter readings and equalize the linearity of these readings, if necessary.

up feb 2014: The development can now be found at:

The circuit diagram of the voltammeter is shown below. As already mentioned, it is built on the widespread PIC16F676 microcontroller, on which, in particular, simple voltmeters and ammeters are assembled.


Click on the diagram to enlarge
Due to the limited number of pins for this MK, the 74HC595 register was used. This microcircuit has no analogues with the same pinout, but it is not in short supply and is often used in similar circuits to connect indicators to the MK. To protect the MK outputs from overload and increase the brightness of the indicators, transistor switches are used. When using indicators with a common cathode, it is necessary to use transistors of a different structure, connecting their collectors not to +5V, but to ground, while the resistor at pin 11 of the microcontroller must be moved to a different position. You may need to select resistors at the register output and in the transistor bases to match your indicators and transistors.

As mentioned earlier, the “B” button allows you to swap the purpose of the indicators if there are two of them. If there is only one indicator, then with this button you can alternate between displaying voltage and current. When you press the "H" button, the indicators will begin to flash. While they are flashing, you can use the “B” and “H” buttons to adjust the ammeter readings. After correction, the blinking will stop and the correction factor will be recorded in non-volatile memory. The display mode set by the "B" button is also stored in non-volatile memory.

After switching on, the indicators do not start to light immediately, but with a delay of several seconds. The frequency of reading changes is about 9Hz.

One of the printed circuit board options for four indicators with a common anode. The necessary corrections are circled in the figure: you need to remove the jumper going to ground and add one small jumper.


Files for the project.

Loading...Loading...