xfMKYBXm

#The7thLiChuangElectricityContest#USB Ammeter

 
Overview


 
1 Project function
The ammeter based on N32G40C8L7+INA199A1.
The basic ammeter version supports 5V fast charging, maximum input voltage 6V, and maximum input current 2A. A 0.91 OLED monochrome screen is used to display the current, voltage, and power values ​​in real time, and it does not have expansion functions.
The advanced ammeter version supports fast charging, pd deception, maximum input voltage 20V, and maximum input current 3A. A 0.96-inch color LCD is used to display the current, voltage, and power values ​​in real time, as well as the current, voltage, and power change trend curves in real time.
PS: I am a novice. If there is anything wrong with the project, please point it out in the comment area. If you don’t like it, please don’t spray it! Thank you all!
 
 
2 Hardware part
2.1 N32 minimum system
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, with up to 64KB of on-chip encrypted storage Flash, and supports multi-user partition authority management, and supports 16KB of embedded SRAM. It has a built-in internal high-speed AHB bus, two low-speed peripheral clock buses APB and bus matrix, supports 40 reusable I/Os, provides a rich high-performance analog interface, 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/I2S, 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.
This case uses fewer resources and does not need to connect an external crystal oscillator. At the same time, according to the reference materials provided by National Technology, each power pin needs to be connected to a 100nf capacitor for filtering, and pin 1 needs to be connected to a 4.7uf capacitor. In
 
addition to the external clock circuit and filter capacitor, the minimum system of the microcontroller also lacks a reset circuit and a boot circuit. The reset circuit and the boot circuit do not use buttons to pull up or down. In order to reduce the area occupied by the buttons on the PCB, two solder joints are used to replace the buttons.
 
2.2 Burning interface
The burning interface selects the pin header to connect with pwlink, while retaining the serial port. However, in the 5v basic version, you can choose to replace the straight plug pin header with a curved plug pin header.
How to use PWlink to download the program? First open Keil, then open the magic wand, and in Debug, we select the third "DAP", and then click "ok". Why not use the serial port to burn? According to many group friends, the serial port download of N32 is extremely unstable! In order to save time and facilitate debugging. Using various links to download and debug programs is the best choice.
 
2.3 Voltage conversion
The voltage conversion of the basic version is the same as the device selected in the official scheme: XC6220, this linear regulator is used as a 5v to 3.3v converter. However, the 22uf capacitor is a little expensive. If you don't mind the number of components, you can actually replace it with two 10uf capacitors in parallel.
The advanced version of the voltage conversion chooses the dcdc buck solution. Since the official dcdc buck chip: BL9342, in the topology of the schematic diagram provided by the official scheme, the starting voltage of BL9342 is 6v, but 5v can start this chip when fast charging is triggered. So in order to start DCDC without fast charging, RT8259 is used here for voltage conversion. In its typical application circuit, the voltage input range is 4.5v-24v, but RT8259 heats up seriously in high voltage conditions.
 
2.4 Voltage sampling
The voltage sampling part consists of a voltage divider circuit composed of two resistors, and its principle is the knowledge of resistor series voltage division.
Because I bought a 90kΩ resistor in LiChuang Mall, I mistakenly bought a 390kΩ resistor. Adjust VOLTAGE_FACTOR to 4 in the program to solve the problem.
 
2.5 Current Sampling
The official recommended current sampling is INA199B1DCKR current sensing amplifier, but due to the shortage of LiChuang Mall, it is changed to INA199A1DCKR here. Its parameters are almost the same as the former and it can replace the former.
The sampling method 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 the accidental short circuit 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 used 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 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, easy to implement, low cost, and high reliability. (Copied from the official website)
Basic version of the sampling circuit:
Advanced version of the sampling circuit:
 
2.6 Use a rotary encoder to select PD deception voltage
Here, a rotary encoder is selected instead of a traditional button, and its hardware circuit is shown below.
According to the data sheet, the waveform output by the encoder when it rotates is similar to that of the Hall encoder, so the interrupt comparison level is used in the software to determine whether it is forward or reverse. After actual testing, the output result of the encoder is relatively stable when the interrupt mode is selected as the rising and falling edge trigger.
Use CH224K for PD deception. CH224K has integrated USB PD and other fast charging protocols, supports PD3.0/2.0, BC1.2 and other boost fast charging protocols, automatically detects VCONN and simulates E-Mark chips, supports up to 100W power, built-in PD communication module, high integration, and streamlined peripherals. Integrated output voltage detection function, and provides over-temperature and over-voltage protection functions. It can be widely used in various electronic devices to expand high-power input such as wireless chargers, electric toothbrushes, rechargeable shavers, lithium battery power tools and other applications. CH224K generates a lot of heat under high voltage conditions, and the layout is designed for heat dissipation.
The level configuration when CH224K is connected to MCU is as
follows. The hardware circuit of CH224K is as follows:
 
2.7 Display part
The basic version uses a 0.91-inch oled white display screen.
Display effect:
The advanced version uses Zhongjingyuan 0.96-inch color LCD (plug-in version) without external circuit, and uses FPC0.5 8p connector to connect the screen to the PCB.
Display effect:
 
3. For some
basic versions of the software, you can directly use the demo provided by the official website.
The advanced version of the software is modified on the official demo. The changes are as follows: 1. Use the rotary encoder to select the PD decoy voltage.
                                                                                              2. Add the function of viewing the current, voltage, and power curves.
 
4. Display pictures
 
5. Explanation
The basic version 5v version has been verified. The advanced version 2nd generation cannot be completed at the end of the camp due to express delivery problems, so now upload the 5v version and the advanced version 1st generation video (because the DCDC cannot be started after power-on, the advanced version only uploads the debugging video), and then upload the working video after the second generation.
Finally, thank LiChuang EDA and National Technology.
Official original project reference: [Training Camp Official Case] ​​USB Amperemeter-Jialichuang EDA Open Source Hardware Platform (oshwhub.com)
 
Summary of this ammeter project: 1. There are problems with the selection of components and PCB layout in the hardware design of the ammeter. 2.
                                    The first time to solder a 48pin device, it is simple.
                                    3. The software used a domestic 32-bit microcontroller for the first time, and accumulated a certain amount of knowledge about 32-bit microcontrollers.
                                    4. The software has prominent problems and needs to strengthen the study of C language.
 
5. Update Note:
The advanced version 2 has been verified and the program is uploaded.
PS: 1. This version has hardware defects. Normal insertion cannot trigger the fast charge of Huawei mobile phones. It may be due to poor soldering.
     2. The power curve on the program shows that there is a runaway phenomenon, and other curves do not appear. The source code has been uploaded. Please give me some advice! ! !
     3. The PD deception function has not been verified.
Photos of the second generation
 
 
 
 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-22 09:19:07

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号