yeQKL

#The 7th Lichuang Electric Competition# Based on N32G430USB voltage and current meter

 
Overview
It can test 65w GaN and Xiaomi 67w fast charging, and 65w laptop charger.
The input voltage can reach up to 40v, and the current is 5a. No problem was found. There is no equipment to test higher current.
The disadvantage is that there is an error in sampling, and sometimes the DC-DC cannot work properly when the input voltage is around 5v.
WeChat_20220826201108.mp4
Ammeter upper shell v9.stl
Ammeter lower case v3.stl
PCB_PCB1_2022-11-05.pdf
BOM_Board1_PCB1_2022-11-05.xlsx
Altium_#The 7th Altium Electric Competition#Based on N32G430USB voltage and current meter_2022-11-05.zip
PDF_#The 7th Lichuang Electric Competition#Based on N32G430USB voltage and current meter_2022-11-05.zip
BOM_Board1_#The 7th Lichuang Electric Competition#Based on N32G430USB voltage and current meter_2022-11-05.xlsx
59961
#The 7th LiChuang Electric Competition#USB ammeter based on ina199

Introduction: USB Amperemeter, Liteon Training Camp
# USB Amperemeter



> ##### My USB Amperemeter Project

## Regarding the structural design

, only the PCB board is used as its appearance. After all, it is only for learning

! [image-20220816134202049](https://s2.loli.net/2022/08/16/FLGloteWXwHcM45.png)

## Regarding the circuit design

, the official case of the training camp open source is used without any modification. The 0603 package is replaced with 0402 (just because there are more original parts in this package)

## The main control

N32G430C8L7 microcontroller product adopts a high-performance 32-bit ARM Cortex™-M4F core, integrated with a floating-point unit (FPU) and digital signal processing (DSP), and supports parallel computing instructions. The maximum operating frequency is 128MHz, integrated with up to 64KB on-chip encrypted storage Flash, and supports multi-user partition permission management, and supports 16KB of 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 rich high-performance analog interfaces, including 1 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 is open source 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 chip's 1 pin needs to be connected to an additional 4.7uf filter capacitor.

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/6MNiUzbCXJsnZJZeAg7o7NkEUAmEpa8NhFy98wem.png)

## Reset circuit, BOOT circuit

Since this design is to adapt to the public version housing, the reset circuit and BOOT circuit are not designed with buttons, and two solder joints are used as short circuits.

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/bN2skZFrRhuDzcIpd7CweHNUIxYyHqrhnP7oGTZW.png)

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/gmvpEN1vRRMmFJ47IJkpC9IKMOyspc71gtBfTabE.png)

## The programming interface

chip supports multiple programming methods, such as the common ST-Link, USB-TTL, Jlink and other programmers on the market. In the case, the corresponding interface has been led out with a 2.54 spacing pin for programming.

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/jjXOjRhH4nAxyzy5P2oLcWQz4OpTC3ue1iMP9NEl.png)

## Voltage conversion

Although the MCU used in this case supports a maximum voltage of 5V, it takes into account the possible unstable voltage factors on the USB voltage or other voltages

![](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/image-20220830091134210.png)



## Current sampling, USB input/output

### USB input/output

The USB input end uses a Type-A male plug and inputs a voltage of 5V. This interface supports a maximum output of 3A. If it is larger, it will get a little hot. It is recommended not to exceed 3A of current. If you need to use a larger current, please replace the Type-A male plug.

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/YmNvPeAs86CZxiQzItKF9SCLchSBb4NTYNV7m7dt.png)

The USB output end 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, and the actual measured current is 2.5A, but it is not suitable for long-term work under this current. If you need to use a larger current, please replace it yourself.

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/S5AvissVOGq93repSJFonKTfhIJWqHU5Didx4Wwq.png)

### Current Sampling The current

sampling part is the INA199B1DCKR current sensing amplifier, (also known as a current sensing amplifier) ​​which is commonly used in 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 performing current sensing. 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 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 ultra-low resistance value resistors (0.0005 ohms, 2 milliohms, 3 milliohms, 10 milliohms, etc.), SMD alloy resistors, high-power resistors (20W, 30W, 35W, 50W, 100W) and other products is plus or minus 5PPM.

#### Sampling method

- This sampling uses **low-side sampling**, 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 the high position between the power supply and the load, although this placement 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, **high-side detection** requires the detection amplifier to handle a 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 seen in industrial, automotive, and telecommunications applications. Application examples include typical laptop battery voltages (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 larger 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 signal ripple due to common ground interference, compared to high-end sampling, the solution is simple, low-cost and highly reliable.

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. If you use other magnifications, you need to modify the program calibration again.

> Use INA199A3DCKT with a gain of 200

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/fQ9Y0MFqTosy6CKslT2ygN2HWlshuLsOk2nNeql2.png)

## 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. The typical circuit is as follows:

![image](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/wKhk7lyTeeiAFnQHAAAw10lZTKc300.jpg)

![图片.png](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/zrBEkjWbERCC5mF7sb8KD9FydojF5jsnpuUnoYXM.png)

## Display part The

display part uses a 0.91-inch 4P white OELD screen module and adopts IIC communication, with clear display effect.

![image](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/v2-60e18b9051c6d06dd9765c9e8b4834bf_720w.png)

Design display effect

![QQ图片20220729114119.jpg](https://img66.oss-cn-hangzhou.aliyuncs.com/imagefortypora/fm5IqdwS52KajW4iQkJLd6EkoDiaI8Xih39Ipoqo.jpeg)

# Software Description

## Compilation parameters

- Compiler: ARM Compiler version 5 (-O0)
- MDK version: 5.31
- Debugger: ST-Link V2

## Note:

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 values. The specific calculation formula is:

```
VOLTAGE_FACTOR = actual voltage / displayed voltage
CURRENT_FACTOR = actual current / displayed current
```

> This is the fast charging version. There are some bugs in the DC power supply part. I don’t know if it is a problem with my wiring or the circuit itself. I will modify the wiring later to see if the output voltage can be normal.
VID_20220828_184419.mp4
VID_20220828_155807.mp4
PCB_PCB1_2022-11-05.pdf
BOM_Board1_PCB1_2022-11-05.xlsx
Altium_#The 7th Altium Electric Competition#USB Amperemeter based on ina199_2022-11-05.zip
PDF_#The 7th Lichuang Electric Competition#USB Ammeter Based on ina199_2022-11-05.zip
BOM_Board1_#The 7th LiChuang Electric Competition#USB Ammeter Based on ina199_2022-11-05.xlsx
59977
#The7thLiChuangElectricityContest#USB Ammeter

Introduction: Voltage and current USB power meter based on N32G430C8L7, small and beautiful.
1. Project Introduction
A small USB power meter based on the domestic N32G430 chip, supporting fast charging. With a 3D printed shell.
2. Project attributes
Based on N32G430+INA199
3. Hardware
(1) Main control chip: N32G430C8L7
The 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 maximum operating frequency is 128MHz, integrated up to 64KB on-chip encrypted storage Flash, and supports multi-user partition permission 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 stably operate in a 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. This case uses few resources, 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
zxHqEU0lAosKEhxXQRfbip81r8H6YVnq88tSioYs.png(2) The crystal oscillator circuit
uses an external 8M crystal oscillator
TlOM81M6gmu8PfOTENZMBSRdmmg00496UQGIhDcu.png(3) Reset circuit
895tEIzCjeSub7UJ9nNn9cl3RFZvJ6pewzcVWnod.png(4) Download options
support SWD download and serial port download.
OZCNYwHu8A5PInW5N6rcyQiXKBClLFULafTx59wy.png(5) The power circuit
supports fast charging. It uses a DC/DC power supply with high efficiency. Prevent the circuit from heating up when the input voltage is too large. The output voltage Vout=0.8*(R1+R3)/R1.
YvuCbb9GBoqTCrPxwFBnmvRx1uSl1K0Fmu64hx1B.png(6) The current detection circuit 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 performing current sensing. The parameters are as follows:
Common-mode range: –0.3V to 26V
Offset voltage: ±150μV (maximum)
Supports 10mV full-scale shunt voltage drop
This sampling uses low-side sampling, 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 not only eliminates the ground interference generated in the low-side detection scheme, but also detects accidental shorts from the battery to the system ground, but high-side detection requires the detection amplifier to handle a 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 seen in industrial, automotive, and telecommunications applications. Application examples include typical laptop battery voltage (17 to 20V), 12V, 24V or 48V batteries in automotive applications, 48V telecom applications, high-voltage motor control applications, current sensing for avalanche diodes and PIN diodes, and high-voltage LED backlights. Therefore, an important advantage of high-side current sensing 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. However, compared with the high end, the solution is simple, low-cost and highly reliable. Quiescent current: 100μA (maximum)
Inserting a low-resistance detection resistor in series in the current path will form a small voltage drop, which can be amplified and 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 sampling resistors is below 1 ohm, which belongs to milliohm-level non-inductive resistors. However, some resistors have sampling voltage and other requirements, so 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 high-precision non-inductive resistors (which can reach 0.01% accuracy, that is, one ten-thousandth accuracy) to make the sampling data very reliable. The temperature coefficient of products such as ultra-low resistance value resistors (0.0005 ohms, 2 milliohms, 3 milliohms, 10 milliohms, etc.) of SMDs, SMD alloy resistors, and high-power resistors (20W, 30W, 35W, 50W, 100W) is plus or minus 5PPM.
If the inventory of INA199B1DCKR is insufficient, you can replace the INA199A3DCKT chip. It should be noted that the magnification of INA199B1DCKR is 50, and the program calibration needs to be re-modified when using other magnifications.
SGtsE6nm9so4kpI0d1PcXmI1f9vpmtu86Llv2hep.png(7) Voltage detection circuit
The voltage sampling part is composed of a voltage divider circuit composed of two resistors.
kSxqIMYdBCD9MnSe3T83tmQJajMZFsu8BLzijft2.png(7) OLED display
The display part uses a 0.91-inch 4P white OLED screen module, using IIC communication, and the display effect is clear.
4. Software part
Compiler: ARM Compiler version 5
Debugger: ST-Link V2
5. 3D preview
Z88W6Zt36RUiPbJsepnvk9xu6YTBFZ1x4acRuSro.png
6. Physical display
7. Notes
The 3D printed shell cannot be fixed, I fixed it with tape.
8. Demonstration video
link: https://www.bilibili.com/video/BV1zP4y1f7PZ?spm_id_from=333.999.0.0&vd_source=1d89d957f45bfff307c7b2df72ea0abc
 
Power meter.rar
PCB_PCB1_2022-11-05.pdf
BOM_Board1_PCB1_2022-11-05.xlsx
Altium_#The 7th Altium Electric Competition#USB Amperemeter_2022-11-05.zip
PDF_#The 7th Lichuang Electric Competition#USB Amperemeter_2022-11-05.zip
BOM_Board1_#The 7th Lichuang Electric Competition#USB Amperemeter_2022-11-05.xlsx
59998
electronic
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-20 14:14:54

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号