1. Introduction
A USB voltage and current meter based on N32G430C8L7+INA199.
2. Engineering Description
Since it is a replica of the official case (video link: BV1ha411o72i), I don’t know the accuracy, and the equipment specifications may be different, so I won’t describe the accuracy.
3. Features
0.91-inch OLED screen, clear and compact display;
equipped with WS2812B colored lights, and can be controlled by buttons
4. Hardware
The hardware part is extracted from the official case (official case), which may not be consistent with the actual situation. The main
control
N32G430C8L7 microcontroller product uses a high-performance 32-bit ARM Cortex™-M4F core, integrated floating-point unit (FPU) and digital signal processing (DSP), and supports parallel computing instructions. The highest operating frequency is 128MHz, integrated up to 64KB on-chip encrypted storage Flash, and supports multi-user partition authority management, and supports 16KB embedded SRAM. It has an internal high-speed AHB bus, two low-speed peripheral clock buses APB and bus matrix, supports 40 reusable I/Os, provides a rich set of high-performance analog interfaces, including a 12-bit 4.7Msps ADC, supports 16 external input channels and 3 internal channels, and provides a variety of digital communication interfaces, including 4 U(S)ARTs, 2 I2Cs, 2 SPI/I2Ss, and 1 CAN 2.0B communication interface. The N32G430C8L7 microcontroller product can work stably in the temperature range of -40°C to +105°C, with a supply voltage of 2.4V to 3.6V, and provides a variety of power consumption modes. Not many resources are used in this case, and the internal clock has been open sourced to meet the design requirements, so there is no need for an external clock circuit. It should be noted that each power pin of the chip needs to be connected to an additional 100nF external filter capacitor, and the 1st pin of the chip needs to be connected to an additional 4.7uf filter capacitor.
USB input/output
The USB input uses a Type-A male plug, which inputs a voltage of 5V. This interface supports a maximum output of 3A. If it is a little larger, it will get a little hot. It is recommended not to exceed the current of 3A. If you need to use a larger current, please replace the Type-A male plug. The
USB output uses a 4P sinker female socket. In order to adapt to the public version shell, the maximum rated current of this female socket is 1.5A. The actual measurement is 2.5A, but it is not suitable for long-term operation at this current. If you need to use a larger current, please replace it yourself.
Current sampling
The current sampling part is the INA199B1DCKR current sensing amplifier (also called current sensing amplifier), which is commonly used for overcurrent protection, precision current measurement for system optimization, or closed-loop feedback circuits. This series of devices can sense the voltage drop across the shunt resistor at a common-mode voltage of –0.3V to 26V independent of the power supply voltage. There are three fixed gains to choose from: 50V/V, 100V/V, and 200V/V. This series of devices uses a zero-drift architecture with low offset, so the maximum voltage drop across the shunt resistor can be kept to a minimum of 10mV full-scale when sensing current. The parameters are as follows:
Common-mode range: –0.3V to 26V
Offset voltage: ±150μV (maximum)
Supports 10mV full-scale shunt voltage drop
Quiescent current: 100μA (maximum)
Sampling resistor selection
Inserting a low-resistance detection resistor in series in the current path will form a small voltage drop, which can be amplified and thus treated as a signal proportional to the current. However, depending on the specific application environment and the location of the detection resistor, this technology will pose different challenges to the detection amplifier. Generally, the resistance value of the sampling resistor is below 1 ohm, which is a milliohm-level non-inductive resistor, but some resistors have requirements such as sampling voltage, and large resistance value resistors must be selected, but the resistance base is large and the error is large. In this case, it is necessary to select a high-precision non-inductive resistor (which can reach 0.01% accuracy, that is, one ten-thousandth accuracy) to make the sampled data very reliable. The temperature coefficient of the chip ultra-low resistance resistors (0.0005 ohms, 2 milliohms, 3 milliohms, 10 milliohms, etc.), chip alloy resistors, high-power resistors (20W, 30W, 35W, 50W, 100W) and other products is plus or minus 5PPM.
Sampling method
This sampling uses the low-side sampling method, that is, the sampling resistor is connected to the GND loop. This design can calculate the complete differential, follow, amplify, and output when the differential signal is sent to the op amp. If high-side sampling is used, that is, the sampling resistor is placed at a high position between the power supply and the load, although this placement method not only eliminates the ground interference generated in the low-side detection scheme, but also detects the accidental short circuit from the battery to the system ground, but the high-side detection requires the detection amplifier to handle the common-mode voltage close to the power supply voltage. This common-mode voltage value range is very wide, ranging from the level required to monitor the processor core voltage (about 1V) to hundreds of volts commonly used in industrial, automotive and telecommunications applications. Application cases include typical laptop battery voltage (17 to 20V), 12V, 24V or 48V batteries in automotive applications, 48V telecommunications applications, high-voltage motor control applications, current detection for avalanche diodes and PIN diodes, and high-voltage LED backlights. Therefore, an important advantage of high-side current detection is that the detection amplifier has the ability to handle large common-mode voltages. Therefore, the current sampling method of sampling resistor plus op amp is best performed at the low end. Although low-end sampling will affect the ripple of the signal due to common ground interference. But compared to the high end, the solution is simple, low cost and high reliability.
Note: If the stock of INA199B1DCKR is insufficient, you can replace it with INA199A3DCKT. It should be noted that the magnification of INA199B1DCKR is 50, and the program calibration needs to be modified again if other magnifications are used.
Voltage sampling
The voltage sampling part is composed of a voltage divider circuit composed of two resistors. Its principle is the knowledge of resistor series voltage division. Its typical circuit is as follows:
![image]()
5. Software part
For the ammeter detection and display part, make changes based on the official case. For the reference video of the change: [USB voltage and current meter] Training camp summary
For the WS2812B color light control part, currently only a small light can be lit. The capabilities and tools are limited, and the code will not be uploaded.
6. Competition LOGO verification