Portal for car enthusiasts

Voltmeter ammeter on microcontroller peak. Voltammeter on PIC16F676

The materials of this article were published in the journal Radioamator - 2013, No. 9

The article presents the design of a digital ammeter-voltmeter designed to work with a universal control board for laboratory power supplies. Its feature is the absence of its own current sensor. Current measurement uses the current sensor of the control board. The considered design is ideal for converting computer power supplies into laboratory DC power supplies.

The conversion of computer power supplies into laboratory ones turned out to be in great demand. In search of options for a control and protection scheme, the “Universal Control Board for Laboratory Power Supplies” was discovered (Radio Yearbook, 2011, No. 5, p. 53). The circuitry of the control board proved to be very simple and effective, meeting all the requirements for controlling and protecting a high-power laboratory DC power supply.

To indicate the output voltage and current, the design described in the above-mentioned article seemed very cumbersome and expensive, moreover, we consider it redundant to simultaneously indicate voltage and current in a power source of this class. At the same time, voltmeters assembled on a cheap PIC16F676 microcontroller with a three-digit LED indicator gained great popularity. Using a ready-made such a voltmeter turned out to be not very convenient due to the difficulty in transferring it to the ammeter mode. Therefore, we decided to develop our own switchable voltmeter circuit with a clear indication of the measurement mode, using, in addition, a current sensor from the control board.

The main technical characteristics of the ampervoltmeter:

  • supply voltage - 7 ... 35 V DC;
  • voltage measurement range - 0 ... 50.0 V;
  • current measurement range - 0.02 ... 9.99 A;
  • voltage measurement step - 0.1 V;
  • current measurement step - 0.01 A;
  • measurement mode switching - by a two-pole switching button with fixation;
  • indication of the measurement mode - a seven-segment indicator in the form of the letters "A" or "U".

Description of control board diagram

To begin with, consider the diagram of the "universal power supply control board", shown in the figure:

It is assembled on a single chip of a quad operational amplifier DA1 and in this case is designed to control a PWM controller such as TL494 of a computer power supply. Schemes for reworking computer power supplies using a PWM controller of this type have already been described many times, so we will not dwell on this. The circuit contains current measuring amplifiers on the elements DA1.1, DA1.4 and voltage on the elements DA1.2, DA1.3, from the output of which the control signal is fed to the PWM controller of the PSU. Variable resistors R13, R14 change the reference voltage of the output amplifiers of the voltage and current measurement channels, respectively. If the current in the load does not exceed the value set by the regulator R14, then the control unit will operate in the voltage stabilization mode set by the regulator R13. In this case, the HL3 indicator will light up. If the current in the load reaches the value set by the regulator R14, then if the SA1 switch is open, the control unit will go into the output current limiting mode. In this case, the HL2 indicator will light up. If the SA1 switch is closed, then when the set current in the load is reached, the output voltage will drop to zero and the HL1 indicator will light up. To exit the current cutoff mode, it is enough to open the switch SA1.

You can read more about the operation and adjustment of the control circuit in the original article: "Embedded universal control board for laboratory power supplies"

Description of the ammeter voltmeter circuit

The circuit diagram of the ampervoltmeter is shown in the figure below:

The basis of the ampervoltmeter is the DD1 microcontroller, which performs the function of analog-to-digital conversion of the input signal received at the RA0 input (IN circuit), and outputs the measurement result to a three-digit seven-segment LED indicator with common cathodes HG1. Switching the measurement channel is carried out by the SA1 button. The second pole of the SA1 button is used to supply a signal to the microcontroller (chain SW), which is used when processing the measurement result.

The display is dynamic with a refresh rate of 100Hz. Due to the fact that the indicator cathodes are connected directly to the microcontroller outputs, in order to reduce the load, each discharge is ignited in 2 steps of 4 segments. To avoid frequent blinking of the low-order digit of the indication, the refresh rate of the indications of the indicator is artificially reduced and is carried out 3 times per second. If the possibility of displaying the measured values ​​is exceeded, three dashes will appear on the indicator.

To indicate the selected measurement mode, a single-digit seven-segment indicator with a common cathode HG2 with a smaller symbol than in HG1 is used. Segments "b", "c", "e" and "f" of the indicator HG2 are constantly lit. In the voltage measurement mode, the switch SA1 supplies positive power to the SW circuit, which, through the resistor R11, ignites the “d” segment, forming the “U” symbol on the indicator. At the same time, a high level based on transistor VT1 keeps it closed. When switching to the current measurement mode, a common wire is supplied to the SW circuit. Transistor VT1 opens, supplying power to segments "a" and "g", and the symbol "A" is formed on the indicator.

The power supply of the ampervoltmeter circuit is taken from the power supply of the PWM controller of the computer PSU and is stabilized using the integrated adjustable stabilizer DA1. Divider R3, R4 at the output of the stabilizer sets a voltage of about 3 V. This supply voltage of the circuit is chosen to ensure the ability to use the full range of the ADC of the microcontroller in the current measurement mode due to the low input signal level.

Construction and details

The elements of the control circuit and the ampervoltmeter are assembled on printed circuit boards made of one-sided foil fiberglass with dimensions of 40x50 mm and 58x37 mm, respectively. PCB drawings and layouts are shown in the figure below. The drawings are shown from the installation side of the elements.

The control circuit board is wired in such a way as to be fixed on the terminals of the variable resistors R13, R14. For ease of adjustment, output radio components are used in the design.

To ensure compactness in the design of the voltmeter, mainly surface-mount elements are used: 1206 form factor resistors and 0805 capacitors. It should be noted that the microcontroller microcircuit is installed in a DIP package. It is surface-mounted on the side of the conductors, with the ends of its leads curved outwards. The SA1 switch is a PS-850L type button used in older computers as a "turbo" switch.

Indicators HG1 (with a symbol size of 0.56 inch) and HG2 (0.39 inch) can be used with any similar ones with a common cathode, preferably with a red glow, since the “green” ones glow rather dimly.

Assembly and adjustment

You can read about the use of the control scheme and how to set it up in the original article. The ammeter voltmeter circuit does not need to be adjusted. It is only necessary to select the values ​​of the resistors R1 and R2 in the input dividers of the current and voltage measurement channels, respectively. This is best done experimentally, using a digital multimeter as a reference ammeter-voltmeter.

It should be noted that the ammeter will not work well if the signal at the output of the power supply is very "noisy". Therefore, you should carefully approach the selection of capacitors C1, C2 of the control circuit. We have already assembled more than six power supplies with such a control scheme, and in some power supplies the values ​​​​of capacitors C1, C2 had to be significantly increased compared to those indicated in the circuit.

Conclusion

The experience of operating power supplies with the above control scheme showed the inconsistency of its use for rework computer power supplies in laboratory due to the significant level of output voltage ripple - the PSU really "sings"! To create laboratory PSUs, it is now used

Last summer, at the request of a friend, I developed a circuit for a digital voltmeter and ammeter. As requested, this measuring device should be economical. Therefore, a single-line liquid crystal display was chosen as indicators for information output. In general, this ammeter was intended to control the discharge of a car battery. And the battery on the engine of a small water pump was being discharged. The pump pumped water through the filter and again returned it over the pebbles to a small pond in the country.

In general, I did not delve into the details of this quirk. Not so long ago, this voltmeter again came to my hand 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 of the microcontroller was lost, it naturally stopped functioning, and since the LCD has its own controller, the data loaded into it earlier, the voltage on the battery and the current consumed by the pump , remained on the indicator screen. Previously, I did not think about such an unpleasant incident, now it will be necessary to take this matter into account in the program of devices and their schemes. And then you will admire the beautiful numbers on the display screen, but in fact everything has burned down for a long time. 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 basis of the circuit is the PIC16F676 microcontroller and the LCD indicator. Since all this works exclusively in the warm season, the indicator and controller can be purchased at the cheapest. The operational amplifier was also chosen appropriate - LM358N, cheap and having an operating temperature range from 0 to +70.
To convert the analog values ​​(digitization) of voltage and current, a stabilized microcontroller supply voltage of +5V was selected. And this means that with a ten-bit digitization of the analog signal, each digit will correspond to - 5V = 5000 mV = 5000/1024 = 4.8828125 mV. This value in the program is multiplied by 2, and we get - 9.765625mV per one bit of the 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 readings of the current value, a scaling amplifier is used, assembled on one of the operational amplifiers of the DA1 - DA1.2 chip. The gain adjustment of this amplifier is carried out using a resistor R3 of 33k. It is better if both trimmers 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, DD1 chip, is a repeater. Serves to reduce the impact on the digitization of noise and impulse noise, due to one hundred percent, negative, frequency independent feedback. To reduce noise and interference when converting the current value, a U-shaped filter is used, consisting of C1, C2 and R4. In most cases, C2 can be omitted.

As a current sensor, resistor R2, a domestic factory shunt for 20A is used - 75SHSU3-20-0.5. With a current flowing through the shunt at 20A, a voltage of 0.075 V will drop across it (according to the passport for the shunt). This means that in order for the controller to have two volts, the gain of the amplifier should be approximately 2V / 0.075 = 26. Approximately - this is because we have a digitization resolution of not 0.01 V, but 0.09765625 V. Of course, you can 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 - 50 volts, and the ammeter - 20 amperes, although with a shunt rated for 50 amperes, it will measure 50A. So that it can be successfully installed in other devices.
Now about the refinement, which includes the addition of an indicator LED. Minor changes have been made to the program and now, while the controller is working, the LED blinks at a frequency of about 2 Hz. The LED glow time is 25ms, for economy. It would be possible to display a blinking cursor on the display, but they said that with an LED it is more visual and effective. Look like that's it. Good luck. K.V.Yu.


.

One of the variants of the finished device, implemented by Alexey. Unfortunately, I don't know the last name. Thank you for your work and photos.

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

A simple AC voltmeter with a frequency of 50 Hz is designed as a built-in module that can be used both separately and be built into a finished device.
The voltmeter is assembled on a PIC16F676 microcontroller and a 3-digit indicator and does not contain very many details.

The main characteristics of the voltmeter:
The form of the measured voltage is sinusoidal
The maximum value of the measured voltage is 250 V;
The frequency of the measured voltage - 40 ... 60 Hz;
Discrete display of the measurement result - 1 V;
Voltmeter supply voltage - 7 ... 15 V.
Average current consumption - 20 mA
Two design options: with and without PSU on board
Single sided PCB
Compact design
Display of measured values ​​on a 3-digit LED display

Schematic diagram of a voltmeter for measuring AC voltage


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

Resistors R6 and R7 create a voltage of 2.5 volts (half power) at the input of the ADC. The relatively small capacitor C5 shunts the ADC input and helps to reduce the measurement error. The microcontroller organizes the operation of the indicator in dynamic mode by interrupts 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 maintain this wonderful site since 2006.
For more than 10 years, our magazine exists only at my expense.

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

Voltammeter on PIC16F676

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


Its peculiarity lies in the fact that it is built on a common 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 with a common cathode (set one resistor). When using a four-character display, the last segment displays the character "U" for voltage and "A" for current. The ampervoltmeter can work with one indicator, while using the "B" button you can choose what will be displayed on it - voltage or current. In the event that both indicators are set, this button can be used to swap their assignment. Button "H" is used to correct the ammeter readings and align the linearity of these readings, if necessary.

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

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


Click on the diagram to enlarge
In view of the limited number of pins for this MK, register 74HC595 is used. This microcircuit has no analogues with the same pinout, but it is not scarce and is often used in such circuits to connect indicators to the MK. To protect the outputs of the MK from overload and increase the brightness of the indicators, switches on transistors 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 rearranged to a different position. You may need to match the resistors at the output of the register and in the bases of the transistors to match your indicators and transistors.

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

After switching on, the indicators do not start to glow immediately, but after a delay of several seconds. The frequency of change of indications is about 9 Hz.

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


files for the project.