We continue to understand the options for implementing a voltmeter - ammeter based on a microprocessor.
Don't forget the archive with the files, we will need them today.
If you want to install 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 install buffer transistors on each digit of the indicator.
Large size indicators
So, the previously discussed circuit will take the form shown in Fig. 2. Three transistors VT1-VT3 of the buffer stage were added for each digit of the indicator. The installed buffer stage inverts the output signal of the MK. Therefore, the input voltage based on VT2 is inverse with respect to the collector of the specified transistor, and therefore is suitable for supplying a comma-forming output to the output. This makes it possible to remove transistor VT1, which was previously in the circuit in Fig. 1, replacing the latter with decoupling resistor R12. Do not forget that the resistor values in the base circuits of transistors VT1-VT3 have also changed.
If you want to install indicators with unconventionally large dimensions, you will have to install low-resistance (1 - 10 Ohms) resistors in the collector circuit of the indicated transistors to limit current surges when they are turned on.
The operating logic of the MK for this option only requires a slight change in the program in terms of inverting the output signal for controlling the bits, namely ports RA0, RA1, RA5.
Let's consider only what will change, namely the subroutine already known to us under the code name “Dynamic indication generation function” in Listing No. 2(see 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 inversion of the signal on the RA port (line 20 of Listing No. 2) is easy to read, since it is written in binary form. It is enough to combine the outputs of the MK and the binary number. In lines 19 and 37, slightly strange conditions appeared that were not there at the beginning. In the first case: “delay the logical zero signal at port RA1 during the indication of the second digit.” In the second: “if there is a logical zero on port RA2, inversion.” When you compile the final version of the program, you can remove them, but for simulation in PROTEUS they are needed. 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 built it, another can always take it apart!”
Good luck!
Reader vote
The article was approved by 27 readers.
To participate in the voting, register and log in to the site with your username and password.In this device, the author used an original method of controlling a four-digit, seven-element LED indicator with signals from only four pins of the microcontroller. The microcontroller program provides an automatic calibration mode for the voltmeter.
The now traditional connection of an LED digital indicator to a microcontroller via a serial to parallel code converter 74HC595 requires the use of three pins of the microcontroller to control the code converter and one more pin for each digit of the indicator. Therefore, a four-digit indicator requires seven pins. This does not make it possible to use such indicators with small-pin microcontrollers, for example, with PIC12F675, which has only six pins (not counting the power pins).
In the second step, the rising edge at pin 12 of the 74HC595 writes the zero contents of the shift register to the holding register. This turns off the indicator completely.
At the third stage, information is loaded into the shift register of the 74HC595 microcircuit using a serial code generated by the microcontroller at pin 14 of the microcircuit. Its pin 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 bits 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 the low level, turning on its elements in accordance with this code. At this point, interrupt processing ends, and the set state of the indicator remains unchanged until the next interrupt.
To control an eight-bit indicator, eight microcontroller outputs are required. In this case, signals from the additional four pins simply control the levels at the cathodes of the discharges. It is worth noting 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 display 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 resolution, V......0.1
Accuracy.............0.5% + units. ml. resolution
Supply voltage, V............7...15
Current consumption, mA, no more...................................30
The voltmeter circuit is shown in Fig. 1. It uses element-by-element dynamic display. At each moment of time, a high level is set on the anodes of one group of elements of the same name of all digits of the HG1 indicator. At the common cathode terminals of the discharges in which these elements should glow, a low level is set, otherwise a high level. Please note that elements of the same name can be enabled simultaneously in all categories, but only one element is enabled in each category at the current time. That is why we chose 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 interruption period of 2 ms, the image refresh rate on the indicator is 64 Hz and its blinking is invisible to the eye. The chosen method of dynamic indication also made it possible to halve the number of resistors (R4-R7) limiting the current through the indicator LEDs.
The microcontroller PIC12F675-I/P (DD1) remains unoccupied in the dynamic indication of the I/O lines GP0 and GP3. The first is used as an ADC input; the measured voltage is supplied to it through a divider R1R2. On line GP3, in the absence of jumper S1, thanks to resistor R3, a high logical level is set, which serves as a signal that switches the voltmeter into calibration mode. If the jumper is installed, the level on this pin is low and the voltmeter operates normally.
When you first turn on the voltmeter with the missing jumper S1, the HG1 indicator will display the rightmost sign flashing. In this state, a voltage as close to 80 V as possible should be applied to the input of the device, monitoring it with a standard voltmeter. With a short-term connection of the contact pads intended for jumper S1, the device will calculate and remember the calibration coefficient and will use it in the future.
However, 80 V is a fairly high voltage, and difficulties in obtaining it are possible. In this case, while indicating the reference voltage value, the device must be turned off and turned on again. , will appear on the indicator, and at the next switching off and on - , , again and further in a circle. Calibration should be performed at the highest voltage available. 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 displayed on the indicator
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 operate without calibration if 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 may exceed 10%. A dot in the far right digit of the indicator will warn you about this.
Analog-to-digital conversion is carried out in the “sleep” mode of the microcontroller to reduce interference from its operating components. It automatically exits this state upon completion of the transformation.
The device is powered by a voltage of 5 V, obtained using an integrated voltage stabilizer 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 supply voltage of the microcontroller in this situation may increase critically.
The device is assembled on a printed circuit board measuring 40x36 mm from one-sided foil-coated fiberglass laminate with a thickness of 1.5 mm, shown in Fig. 2. Most resistors and capacitors are size 0805 surface mount. Resistor R1 for reliable operation at increased voltage is used with an output power of 0.5 W. Capacitor C1 can be installed either as a ceramic capacitor or as an oxide capacitor, for which a seat designated C1 is provided on the board." The FYQ-3641AHR-11 indicator can be replaced with another from the 3641A series or a three-digit 3631A series without remaking the board. A photograph of the assembled device board is shown in Fig. 3.
I've been working on radio electronics for several years now, but I'm ashamed to admit that I still don't have a normal power supply. I power 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 or 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 ampere-voltmeter. Of course, it was necessary to start from another, but as it already is. Since I’ve been doing a little programming, I decided to develop a display meter myself. The screen is a display from Nokia-1202. I’ve probably already tortured everyone with this display, but it’s 3 times cheaper than the 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.
Electrical circuit of a digital ampere-voltmeter for power supply
Drawing of a digital ampere-voltmeter board
The first and second lines display the average voltage and current values from 300 ADC measurements. This is done for greater measurement accuracy. The third line displays the load resistance calculated using Ohm's law. First I wanted to make sure 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 heatsink 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 radiator. It will change its speed when the temperature measured by the DS18B20 sensor changes. There is a PWM signal on pin PB3. 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 not be installed. In this case, the fourth line will simply display OFF. We connect the cooler directly. The output of PB3 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. According to calculations, the gain factor of the op-amp LM358 is chosen to be 10. For different firmware, you need to select 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 measurement readings.
There is also a printed circuit board in the archive. There are slight differences in the photo - it has been slightly adjusted there. One jumper has been removed and the size is 5 mm smaller in height. The stability of the ampere-voltmeter readings is high. Sometimes it floats only by hundredths. Although I only compared it with my Chinese tester. This is quite enough for me.
Thank you all for your attention.
ARCHIVE:
Modernized version
I only added a display of a tenth of the power.Here I modified it to measure up to 50A. Shunt 0.01 ohm. The op-amp gain 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 display meter for a laboratory power supply. The ability to turn off the load when a certain preset current is exceeded has been added. The firmware of the improved voltammeter can be downloaded below. Circuit diagram of a digital current and voltage meter.
Several details were also added to the diagram. From the controls there is one button and a variable resistor with a value from 10 kilo-ohms to 47 kilo-ohms. Its resistance is not critical for the circuit, and as you can see, it can vary over a fairly wide range. The appearance on the screen has also changed a little. Added display of power and ampere hours.
The trip current variable is stored in the EEPROM. Therefore, after switching 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 variable resistor knob, you need to set the current at which the relay will turn off. It is connected via a transistor switch to pin PB5 of the Atmega8 microcontroller.
At the moment of shutdown, the display will indicate 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 measurement mode. Log 1 will be sent to output PB5 of the microcontroller and the relay will turn on. This kind of current monitoring also has its disadvantages. The protection will not work instantly. Triggering may take several tens of milliseconds. 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 your attention. Boozer completed the ampere-voltmeter.
ARCHIVE:
Forum