*Update Log
———————————————————————————————————————— ——Modified
the input connection error of INA199.
Corrected the problem that the TYPE-A male connector is reversed to the computer socket
. Modified the shell model to correct the error that each interface is offset from the shell opening.
Optimized the VBUS routing, in Type-A A small piece of copper is laid on Port C to enhance the overcurrent capability
2022.9.4
* 1. Project function introduction
This project originated from the training camp activities organized by Jialichuang and National Technology Cooperation.


The input voltage of this power meter is 5-40V. If it is lower than 5V, the buck chip will not be able to output 3.3V normally. If the voltage is higher, remember to use high-voltage capacitors and other devices. The input current is 0-3A. It may not be a big problem if the current is larger, but it has not been tested. In theory, 5A will be fine for a short period of time. In the voltage and current sampling part, the official case of the training camp was adopted, using voltage dividing sampling to collect voltage and using INA199 series + current sensing sampling resistor to collect current. Both signal processing are directly handed over to the 12-bit ADC built into the microcontroller. Since there are only 12 bits, its minimum resolution for external input is only 3.3v/2^12=0.8mV. The resolution of voltage and current in the official sample program is 0.01, which is probably a trade-off for display effect, but it is enough for me. In addition to the basic measurement functions, this project also adds a fast charge deception function, with the option of PD/QC protocol deception.
*2.
There is no need to say more about the two sampling parts of the hardware part. The official examples are already very clear. It is worth mentioning that you should pay attention to the two input pins of the current sampling chip and be sure not to connect them reversely! ! ! ! , my first version of the circuit had this problem. After the welding was completed, the current was not displayed. When I measured the OUT pin, it only had a few millivolts. I thought it was the chip that had been shipped. I replaced it with a spare one and the problem still persisted, so I went to check. I didn't see anything wrong with the circuit, so I had no choice but to look at the datasheet carefully. I saw that there was a packaged op amp in it, and I suddenly realized that

I finally solved it by flying two wires. (The open source circuit diagram and pcb have corrected this problem). Also, you have to pay attention to the TYPE-A male connector. It should be on the same side as the screen. Otherwise, if you want to plug it into the computer after soldering, you will find that the screen has turned over... (This problem has also been corrected in the PCB)
The voltage reduction part , it originally copied the 4-24V version of the official case, so it’s so nice to just get it off the shelf. As a result, I later read in the group that the output was not normal at 5V, so I had to design it myself. In order to save space, I found a SOT-23 package and designed it by referring to the manual. The actual test results are good. 5-12V stably outputs 3.4V voltage. I did not test it because there is no suitable power supply. In theory, it should be normal. The input terminal of the chip supports 4.75-40V.
Then there is the fast charge deception solution. I went to learn about the fast charge protocol and finally found two suitable deception chips, CH224K and LDR6328. The advantage of LDR6328 is that it is compatible with the PD/QC protocol, but the problem is that it is I still like to be able to control automatic deception, so I finally chose CH224k, but it also has a problem. Although it also has dp and dn feet, the manual does not mention anything about the QC protocol, only that it can deceive PD. To be on the safe side, choose another QC plan. After searching for information, I came across the video of Station B: QC Deception 2-Protocol Chapter_Bilibili_bilibili This solution can be said to be extremely trouble-free in terms of hardware. The big guys also have projects on the open source platform. If you need it, you can Go and take a look at our city's Green Green - QC deception module - microcontroller version - Jialichuang EDA open source hardware platform (oshwhub.com).
The last interface part adheres to the principle that I want them all. It has TYPE-A male and female ports, TYPE-C female socket, DC female socket, and a 4p bent header, which can be used to power the motor or development board and Measure power to meet common requirements as closely as possible. (The picture shows a servo with a broken control board driven by DC power supply)
The shell part is modeled using the solidworks 2021 version. There should be no major problems in the version released now, at least that’s what the assembly diagram looks like. This time I was too lazy, and I didn’t even get the color right, so long as it worked, I tried proofing it three times, and the problems were basically corrected. I also left a margin of error for 3D printing. As long as the accuracy is within 1mm, it should be able to be inserted.

I used ABS for proofing this time, and it went quite smoothly. At least it came out, but there was some cracking in a small area. I guess if I want to pursue better printing effects, I have to seal it and print it. Four M3*16 screws were used for assembly
*3.
Although the software part is all 32-bit MCUs and based on ARM architecture, many register definitions or names of N32 and STM32 are still different. In order to develop well In this area, you must first be familiar with STM32, and then look at the register definitions of the peripherals to be used (u1s1 National User Manual is pretty good). However, my level is still too low, and I am not familiar enough with STM32, so the software development has not yet been completed. At present, I have only finished writing the quick charge, button library and menu structure. In addition, due to my recent busy schedule, it is a bit unrealistic to complete it before the end of the camp, so I can only shelve this part for now and will definitely do it next time.
*4.
Although there is a project summary There were some ups and downs, but fortunately the basic functions have been successfully completed, and many of the problems encountered have been mentioned before, so I won’t repeat them here. Overall, this is an improvement in my personal ability, I have verified some designs that I have never used before, and learned some knowledge that I have never learned before. I would like to thank Jialichuang and National Technology for providing this valuable learning opportunity. I also hope that the user ecology of domestic MCUs can be improved and there will be an atmosphere of community discussion, so that it can be easier and more convenient for students and developers. Get started with domestic MCU quickly.
* 5. Demonstration video