Pic12f675 indicator from nokia voltmeter. Ampervoltmeter on pic12f675 - measuring equipment - tools. Large indicators

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 " AT" 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 " AT" 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 " AT" 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 " AT", 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

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

Specifications of the 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 a schematic diagram of the 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 the adjustable integral stabilizer KR142EN12A, it was decided to use the 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!


In this device, the author used the original method of controlling a four-digit seven-element LED indicator with signals from only four microcontroller pins. The microcontroller program provides for automatic calibration of the voltmeter.

The traditional connection of an LED digital indicator with a microcontroller through a serial-to-parallel converter 74HC595 requires the use of three outputs of the microcontroller to control the code converter and one more output for each digit of the indicator. Therefore, a four-digit indicator requires seven pins. This makes it impossible to use such indicators with low-output microcontrollers, for example, with PIC12F675, which has only six pins (not counting the power pins).

At the second stage, the rising level difference at pin 12 of the 74HC595 chip rewrites the zero contents of the shift register into the holding register. This completely extinguishes the indicator.

At the third stage, information is loaded into the shift register of the 74HC595 microcircuit with a serial code generated by the microcontroller at pin 14 of the microcircuit. Its output 11 receives clock pulses.

At the fourth stage, with an increasing level difference at pin 12 of the 74HC595 microcircuit, information from its shift register enters the storage register, and due to the high levels at the cathodes, the indicator discharges remain extinguished.

At the fifth stage, on the common cathode of the discharge, for which the parallel code output to the outputs of the 74HC595 microcircuit is intended, the program sets a low level, turning on its elements in accordance with this code. This completes the interrupt processing, and the set indicator state remains unchanged until the next interrupt.

To control an eight-digit indicator, eight microcontroller outputs are required. In this case, the signals from the additional four outputs simply control the levels on the cathodes of the discharges. It should be noted that in this case it is possible to use indicators with both common cathodes and common anodes, connecting elements or discharges to the outputs of the code converter, respectively. For the reasons stated below, it is preferable to organize the dynamic indication element-by-element in the first case, and bit-by-bit in the second.

Now let's talk about a voltmeter that uses the described principle.

Main technical characteristics

Measured voltage, V .............. 0...80

Measurement discreteness, V ...... 0.1

Accuracy..................0.5% + units ml. res.

Supply voltage, V...........7...15

Consumption current, mA, not more than .........................30

The voltmeter circuit is shown in fig. 1. It uses element-by-element dynamic indication. At each moment of time, a high level is set on the anodes of one group of the same-named elements of all digits of the HG1 indicator. On the common cathode terminals of the discharges in which these elements should glow, a low level is set, otherwise it is high. Please note that elements of the same name can be included simultaneously in all categories, but only one element is included in each category at the current time. That is why it was chosen to connect the anodes of the elements to the outputs of the DD2 microcircuit, the load capacity of which is higher than the outputs of the microcontroller.

Rice. 1. Voltmeter circuit

With an interrupt period of 2 ms, the refresh rate of the image on the indicator is 64 Hz and its blinking is imperceptible to the eye. The selected method of dynamic indication also made it possible to halve the number of resistors (R4-R7) that limit the current through the indicator LEDs.

The microcontroller PIC12F675-I / P (DD1) remain unoccupied in the dynamic indication of the I / O lines GP0 and GP3. The first one is used as an ADC input; the measured voltage is fed to it through the divider R1R2. On line GP3, in the absence of jumper S1, thanks to resistor R3, a high logic level is set, which serves as a signal that puts the voltmeter into calibration mode. If the jumper is installed, the level on this pin is low and the voltmeter operates normally.

When you turn on the voltmeter for the first time with the missing jumper S1, the HG1 indicator will be displayed with the rightmost sign flashing. In this state, a voltage as close as possible to 80 V should be applied to the input of the device, controlling it with an exemplary voltmeter. With a short-term connection of the contact pads intended for jumper S1, the device will calculate and remember the calibration factor and will use it in the future.

However, 80 V is a rather large voltage, and difficulties in obtaining it are not ruled out. In this case, during the indication of the value of the reference voltage, the device must be turned off and on again. The indicator will show , and at the next switching off and on - , , again and further in a circle. Calibration should be performed at the highest available voltage of these values. The higher the reference voltage, the more accurate the calibration. If at the time of calibration the input voltage differs too much from the reference voltage, the coefficient will not be calculated, and the indicator will display

After calibration, turn off the voltmeter and finally install jumper S1, otherwise the next time you turn it on, you will have to repeat everything again. The voltmeter can also work without calibration if the jumper S1 is already installed when it is first turned on. In this case, it uses the coefficient written in the program, but the error can exceed 10%. This will be warned by the included dot in the rightmost digit of the indicator.

Analog-to-digital conversion is performed in the "sleep" mode of the microcontroller to reduce interference from its operating nodes. From this state, it automatically exits at the end of the conversion.

The device is powered by a voltage of 5 V, obtained using an integrated voltage regulator DA1. You can use the 78L05 stabilizer instead of the one indicated in the diagram only as a last resort, since the stability of its output voltage is an order of magnitude worse. Without degrading the parameters, you can use the LP2951 stabilizer. The Zener diode VD1 for a voltage of 5.6 V, together with the internal protective diode of the microcontroller, protects the latter from damage when the measured voltage exceeds the permissible value. Without a limiter, the microcontroller supply voltage in this situation can critically increase.

The device is assembled on a 40x36 mm printed circuit board made of 1.5 mm thick one-sided foil fiberglass, shown in fig. 2. Most resistors and capacitors are size 0805 for surface mounting. Resistor R1 for reliable operation at high voltage is used with an output power of 0.5 W. Capacitor C1 can be installed both ceramic and output oxide, for which the board has a seat marked C1. The FYQ-3641AHR-11 indicator can be replaced with another one from the 3641A series or a three-digit 3631A series without altering the board. A photograph of the assembled device board is shown in Fig. 3.

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 the 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. In short - a good option for a 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 factor of the LM358 op amp 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. The appearance on the screen has also changed a little. 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.