* 1. Project function introduction:
USB ammeter based on N32G430C8L7+INA199, with an accuracy of 1%. It can check the current when USB is working and supports fast charging.
*2. Project properties:
This USB power meter supports fast charging. The DCDC chip BL9342 in the voltage conversion circuit has insufficient power supply. When the voltage is around 5V, the output is only 2.5V, which causes the power meter to not work. Later, it was replaced with MP2451 to solve the problem.
* 3. Open source protocol
gpl3.0
*4. Hardware part:
N32G430C8L7 microcontroller product adopts 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 working 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.
*5. Software Compiler
: Keil uVision5
MDK version: 5.29
Debugger: ST-Link V2
Notes
If the sampled voltage or current is inaccurate, you can modify the values of VOLTAGE_FACTOR and CURRENT_FACTOR in the main.c file according to the actual value. The specific calculation formula is:
VOLTAGE_FACTOR = actual voltage / displayed voltage
CURRENT_FACTOR = actual current / displayed current