A6hmZt

#The7thLiChuangElectricityContest#N32G430 ammeter and fast charging sampling

 
Overview

 
* 1. Project function introduction
The ammeter implemented by National Technology MCU N32G430 supports voltage, current, power, ripple and current fluctuation graphic display.
I have just learned Keil5 to write microcontrollers, and I don’t understand a lot. After participating in the LiChuang training camp several times, I really feel that I can learn a lot, faster than independent learning. Why is this? I think there may be the following reasons:
1. With the guidance of professional personnel from manufacturers, you can quickly get started and provide effective technical support;
2. With the help of experienced big guys from LiChuang, you can get help if you have any questions, and there are also component coupons and PCB proofing coupons provided by LiChuang, which can reduce development costs and reduce worries;
3. There are thousands of people helping each other in the group. Even if most of them don’t know, there will always be some big guys or students who just understand a certain area who can help and answer, which can really improve the efficiency of learning.
 
So the training camp model is really very good. The main goal of the one I am making now is to achieve the following functions:
1. Voltage, current and power display, which is relatively simple and has been realized;
2. Voltage ripple display, the basic functions are also realized at present;
3. Charging protocol analysis, temporarily want to judge the protocol through D+D-, but the actual measurement seems to be very inaccurate, I don’t know how to analyze the charging protocol specifically, which needs to be improved;
4. Current fluctuation graph, which is in the process of improvement;
5. Power consumption statistics, although this function is simple, but I am not familiar with this microcontroller at present, and there are some errors in each time obtained, so it is still being optimized;
6. Fast charging fraud, the idea is to achieve it through D+D-, but later it was found that N32G430 does not have DAC function, so it is currently abandoned.
 
The finished product picture is also released for you to see, it is still relatively small, and a TYPE-C port is added, which is also more convenient.
The PCB that was sent back has been revised because the first version found that the hole left by the OLED soldering screen cable could not be put in. ^-^
The soldered style, I originally wanted to take a working picture, but found that the screen flickered a lot, and the display content was incomplete, so I simply put it up when recording a video later.
Three buttons can be used to easily achieve some switching, parameter adjustment, etc.
 
 
 
*2. Project properties
refer to the training camp project, reference project link: https://oshwhub.com/limengmeng12345/ji-chu-ying-usb-dian-ya-biao#P1
 
 
* 3. Open source agreement
GPL 3.0
 
*4. Hardware part
 
(1) Power supply part
Here, LDO is selected for power supply. In order to be compatible with fast charging, GM7333 is selected. This LDO supports an input voltage of 40V and supports a current output capacity of 250mA, which fully meets the power supply requirements of this national MCU. In addition, the peripheral circuit is simple, more convenient than using a step-down circuit, and the size is also smaller.
(2) The main control circuit
mainly uses four ADCs to sample voltage, current and the voltage of D+ and D-. BOOT0, PB0 and PB1 are used as buttons. RST is also brought out for debugging.
Then there are the serial port and SWD burning port. PB6 and PB7 are used as LEDs to facilitate program observation. After all, it is a novice, so it is also good to leave an extra status light to judge whether the system is running normally. It can also be used as a functional light later.
 
(3) Current sampling
    The current sampling uses INA199A1 for differential amplification. In fact, operational amplifiers can also be used, but it is best to use precision operational amplifiers. However, the accuracy of differential resistors should be high. Otherwise, the error between different hardware is relatively large, which is more troublesome, and there are more components. There is no cost advantage, so it is more convenient to use a dedicated current amplifier.
    Here we should pay attention to the A1 after the model. A means the accuracy is 1.5% (AB accuracy is 1.5%, C is 1%, please refer to the manual for details), 1 means the magnification is 50 times, 2 means 100 times, 3 means 200 times, that is, A1 means 50 times magnification and 1.5% accuracy. The selection is mainly related to the sampling resistor and the sampling voltage of the MCU. I will not go into details. If you want to know more, you can discuss with each other.
 
(4) There is actually nothing to say about voltage sampling
. It is just to divide the voltage and then sample it. The voltage here is sampled using 1:10, that is, the final calculated value multiplied by 10 is the actual voltage, D+ D- is 1:3, and the result is multiplied by 3. The voltage division calculation is Vadc=VIN*R2/(R1+R2), R2 is the low-side resistor, which is the one connected to GND. Note: The maximum voltage after voltage division cannot exceed the supply voltage (here is 3.3V), otherwise it will always be 3.3V and the true value cannot be obtained.
 
(5) OLED drive circuit
I use a 30P welded OLED screen, which supports SSD1306 and SH1106. I use the SH1106 white light 0.96 screen. This screen is relatively cheap on a certain fish, only 4-5 yuan each. You can consider buying more and putting them away for easy use. Of course, an OLED external interface is also reserved.
 
 
 
 
*5.
 
For the software part, let's take DMA to implement 4-way ADC sampling. This is also part of the official example. Then I encountered a problem that I didn't know whether to implement data processing after the ADC interrupt or after the DMA has processed the data. I asked in the group, and they actually said to find a circuit to learn. I had no choice but to go to the national technical staff to ask, because I was a beginner and didn't understand anything. However, after actually operating it once, I could understand what the specific function was and where it should be processed. For the rest,
 
you can read it yourself after the open source is completed. The comments will be more detailed, mainly for your own note-taking, otherwise you will forget it after a long time.
 
*6. BOM list
 
 
*7. Competition LOGO verification
 
* 8. Demonstrate your project and record it as a video and upload it
 
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-20 12:22:19

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号