# Vintage V2 - A3941 Brushed DC motor develope log
###### tags: `motor`
[TOC]
## How to build it
### [Tutorial Link](https://www.youtube.com/playlist?list=PLf_CDGphvxlqz9d2QpOabWCdljQ_45ARI)
## PCB Design Link
### [Github Link](https://github.com/Chungchiyu/Vintage-Brushed-DC-motor-driver/tree/main)
### V2.0
- [IBOM](https://chungchiyu.github.io/pcb_ibom/Vintage_V2/Vintage_V2.0-PCB_DC%20motor%20driver%20(shunt)_rev0.html)
### V2.1
- [IBOM](https://chungchiyu.github.io/Vintage-Brushed-DC-motor-driver/Vintage_V2/V2.1/Vintage_V2.1-PCB_DC%20motor%20driver%20(shunt)_rev0%20.html)
### V2.2
- [IBOM](https://chungchiyu.github.io/Vintage-Brushed-DC-motor-driver/Vintage_V2/V2.2/Vintage_V2.2-PCB_DC%20motor%20driver%20(shunt)_rev0%20.html)
### V2.3
- [IBOM](https://chungchiyu.github.io/Vintage-Brushed-DC-motor-driver/Vintage_V2/V2.3/Vintage_V2.3-PCB_DC%20motor%20driver%20(shunt)_rev0%20.html)
- [Schematics](https://chungchiyu.github.io/Vintage-Brushed-DC-motor-driver/Vintage_V2/V2.3/Schematic_Vintage-V2.3-(motor-driver)_2024-09-06.pdf)
- [Gerber](https://github.com/Chungchiyu/Vintage-Brushed-DC-motor-driver/tree/main/Vintage_V2/V2.3/Gerber) (彩蛋如果被老闆發現可以改用 boring)
## V2.0
### Prior knowledge
1. [How to overcome negative voltage transients on low-side gate drivers' inputs](https://www.ti.com/lit/an/slua939/slua939.pdf?ts=1694944689568&ref_url=https%253A%252F%252Fwww.google.com%252F)
#### Layout recommendation
在設計高頻、快速開關、高電流電路時要小心注意:
- [x] 1. A3941 的地以及 Power 的地要**分開**回到 Supply 濾波電容的地。這樣可以最大限度降低開關雜訊對元件邏輯及類比參考的影響。
- [x] 2. 導熱板需要接地。
- [x] 3. 在所有功率 FET 的 Drain 和 Source 端使用短且寬的銅線,以最大限度降低雜散電感。當中包括馬達端、電源端以及 Low-side FET 的 Common Source。這樣可以降低由快速開關、大電流引進的電壓。
- [x] 4. 可以在功率 FET 的 Source 及 Drain 間使用陶瓷去耦合電容(100nF),來限制由線路電感引起的瞬態電壓突波。
- [x] 5. 讓 Gate 放電迴路連接的 Sx 和 Lss 走線盡可能短。任何寄生電感都會導致負電壓回灌至 A3941,一旦超過限制就會燒壞。如果有發生這類狀況可以用鉗位二極體來限制負電壓的幅度。(詳見 Prior knowledge 1)
- [x] 6. 諸如 RDEAD 或 VDSTH 等敏感的連接,需要非常小的地電流,應該要接到靜地(Quiet Ground),獨立連接並且最接近 GND 腳位。
- [x] 7. VBB、VREG、V5 的電源去耦應連接到電源供應器的地,該接地要獨立連接到接近 GND 的位置,並且去耦合電容應該要越接近相應腳位越好。
- [x] 8. 如果空間不足,靜地可以跟電源地併用,但 RDEAD 電阻需要盡可能接近 GND 腳位。
- [ ] 9. 可以檢查 LSS 引腳上的瞬態峰值電壓偏移,如果超過接受範圍(-4~6.5v)。請在 LSS 及 GND 間增加鉗位二極體或是電容來保護。
- [x] 10. Gate 充放電路徑容易產生瞬態大電流,因此連接 GHx、GLx、Sx、Lss 的走線越短越能降低寄生電感。
- [x] 11. Lss 連接到電源端的地,不建議將 Lss 直接連接到 GND,容易會導入雜訊到敏感功能中,如死區的時鐘。
- [x] 12. 加入一個低價的二極體至 VBB 來提供電池反接保護。在反接狀況下,用 FET 的本體二極體可以將反向電壓箝制在 4V。在這樣的情況下,多加一個二極體可以保護 A3941 被反向電壓擊穿。

### Problem
- [x] 1. 第三層並未與其他層具有相同的分割,使得分割無意義
- [x] 2. 銅柱可以浮接,不應該同時通過第三層連到 DGND
- [x] 3. 走線不是順線擺
- [x] 4. 第三層應該要是 Power 層
- [x] 5. A3941 散熱 PAD 要接地
- [x] 6. Filter 的 OP 沒有去耦合電容


## V2.1
### Log
#### 2023/11/30
- Teaching how to solder the boards.
- Power on for first test.
* <a href="#20231130-001" smoothhashscroll="">Debug[001]</a>
#### 2023/12/01
* <a href="#20231201-002" smoothhashscroll="">Debug[002]</a>
#### 2024/01/28
* <a href="#20240128-003" smoothhashscroll="">Debug[003]</a>
#### 2024/02/03
* <a href="#20240203-004" smoothhashscroll="">Debug[004]</a>
### Debug
#### 2023/11/30 [001]
- [x] 1. Two fault pin leds were soldered upside down.
2. The power indicator with zener diode is able to provide the led a stable voltage from 2.7v to 3.1v when supply voltage changes from 12v to 30v.
- 
- [x] 3. The power led is too bright to watch. Maybe add a 1k ohm resistor between led and DGND.
- [x] 4. Failed to run the driver. <a href="#20240128-003" smoothhashscroll="">[see 003]</a>
1. I changed the A3941 but the problem remained the same.
- [x] 2. The PWM, DIR, FF1, FF2, RST are 5V signal, however, the STM32 only produce 3V signal. Maybe needs to add a level shifter for these signal pins.
#### 2023/12/01 [002]
- [x] 1. Continue to [001-4] problem. <a href="#20240128-003" smoothhashscroll="">[see 003]</a>
1. Using Arduino to provide 5V signal, however, the problem remained the same. Also, the PWM signal drop to 4.3V while connecting to driver.
2. Again changing the A3941 but the problem remained the same.
3. Removed the diodes and capacitor across the MOSFET, but the problem remained the same.
4. The V5 voltage drop to 3.8V with no reason. Guessing there might be some shortage in the circuit.
#### 2024/01/28 [003]
- [x] 1. Continue to [002-1] problem.
- Problem solved.
- The network resistor is not a 10P5R version, it is a 10P8R one. The connections inside the resistor are not independent.
- 
- Due to the connection between PWM, DIR and so on, A3941 got confused by mixed signal.
- Change to 10P5R will solve this problem.
#### 2024/02/03 [004]
- [x] 1. Using 3V as input will end up MOSFET heating.
- Also the resolution of the lower PWM duty cycle isn't enough. Within +-0.5v will directly drop to 0v.
- Need to add level shifter to input pins.
- [x] 2. Reset pin will float with the input voltage.
- It will damage the MCU GPIO.
- Need to add a level shifer.
#### 2024/02/04 [005] <a href="#20240204-002" smoothhashscroll="">[Solved]</a>
- [x] 1. The decoupling capacitors of A3941 power were placed at wrong location.
- The decoupling capacitors need to be as close to IC as possible.
-  
### Development
#### 2024/02/04

1. Check real shunt resistance.
- 0.015R -> 0.018R
2. Considering our driver needs to handle at least $\pm 5A$.
Assume using STM32 ADC input, the input range will be 3V with resolution of 12bits.
$\text{Current resolution: }3V\div4096\div20V/V\div0.015R=2.4mA$
Therefore, IN240A1 will be enough for precision with 0.015R shunt resistor.
## V2.2
### Log
#### 2024/02/03
* <a href="#20240203-001" smoothhashscroll="">Development[001]</a>
#### 2024/02/04
* <a href="#20240204-002" smoothhashscroll="">Development[002]</a>
#### 2024/07/03
* <a href="#20240427-001" smoothhashscroll="">Debug[001]</a>
### Developement
#### 2024/02/03 [001]
- [x] 1. Change resistor pack 10P8R to 8P4R and additional 0603.
- [x] 2. Add a reverse protection diode for A3941.
- [x] 3. Add an optional switch for power on/off.
- [x] 4. Add test points for V5, VDSTH, RDEAD.
- [x] 5. Add resistor for power indicator to reduce the brightness.
- [x] 6. Add 5 level shifter for input signals.
#### 2024/02/04 [002]
- [x] 1. Change the decoupling capcitors for A3941.
- 
#### 2024/02/05 [003]
- [x] 1. Add a differential input filter (LPF) with 20kHz cut-off frequency.
- [**Three guidelines for designing anti-aliasing filters**](https://e2e.ti.com/blogs_/archives/b/precisionhub/posts/three-guidelines-for-designing-anti-aliasing-filters)
- 
### Debug
#### 2024/04/27 [001]
1. The driver didn't work.
- V5 pin directly output close to VBat voltage.
- After checking all the wiring and components were fine, the V5 pin and reset pin still had the same voltage as VBat. Normally V5 stays around 5v, and reset stays around 4~6v.
- After **fucking two hours of debugging**, I finally found out that the PCB has potential problem with wiring.
- 
- The GND area inside blue square didn't connect to the rest GND area. The PCB was not made properly.
- Fix it by jumping it to near GND pin.
- Guessing it is because the footprint of A3941 had some compatible issue with the whole PCB document. Because the only connection between A3941 pad and other GND is the 4 vias in the middle of pad.
- 
- To fix it for good, add more vias inside the pad, and also add more vias for the GND pins of A3941.
- [x] 2. The FF2 fault pin turned on.
- The MOSFET of Q2 got brunt while debugging the problem 1.
- After changing the new MOSFET, it is fixed.
- [ ] 3. The bridge circuit will lightly heat up during working.
- [x] 4. Change reset pin of pull up to V5 resistor's resistance from 100k to 20k, because the datasheet recommended.
### BOM (Bill of Materials)
:::spoiler 2024/02/04 BOM
| | Value | Footprint | Quantity | Remain | Buy |
| --- | --------------- | ------------------------------------ | -------- | ------ | --- |
| 1 | 100kΩ | R0603 | 2 | | 100 |
| 2 | 100K排阻0603\*4 | RES-ARRAY-SMD_0603-8P-L3.2-W1.6-TL | 2 | | 100 |
| 3 | S8050_C19630847 | SOT-523-3_L1.6-W0.8-P0.50-LS1.6-BR | 2 | 3 | 50 |
| 4 | BSS138W-TP | SOT-323-3_L2.2-W1.3-P1.30-LS2.1-BR | 1 | | 30 |
| 5 | BSS138DW-7-F-ES | SOT-363-6_L2.0-W1.3-P0.65-LS2.1-BL | 2 | | 50 |
| 6 | 1N4001 | SOD-323_L1.7-W1.3-LS2.5-RD | 5 | 46 | 100 |
| 7 | 1K排阻0603\*4 | RES-ARRAY-SMD_0603-8P-L3.2-W1.6-TL | 1 | | 100 |
| 8 | 1kΩ | R0603 | 2 | 13 | 200 |
| 9 | 47pF | C0603 | 1 | 91 | |
| 10 | 15mΩ | R1206 | 1 | 8 | 20 |
| 11 | HEADER8 | CONN-TH_8P-P2.54_XH2.54-8P-S | 1 | 17+20 | |
| 12 | 47kΩ | R0603 | 6 | 248 | |
| 13 | IPD036N04LG | TO-252-2_L6.6-W6.1-P4.58-LS9.9-BR | 4 | 14 | |
| 15 | 1uF | C0603 | 4 | 145 | |
| 16 | 4.7uF | C0603 | 2 | 99 | |
| 17 | 0.47uF | C0603 | 1 | 48 | |
| 18 | 220uF | CAP-TH_BD8.0-P3.50-D0.6-FD | 2 | 16 | 36 |
| 19 | 10nF | C0603 | 1 | 99 | |
| 20 | 1nF | C0603 | 2 | 98 | |
| 21 | 100nF | C0603 | 6 | 244 | |
| 22 | LED-0603_R | LED0603_RED | 2 | 17 | 40 |
| 23 | LED-0603_G | LED0603_GREEN | 1 | 5 | 20 |
| 24 | 47Ω | R0603 | 4 | 98 | |
| 25 | 4.7kΩ | R0603 | 1 | 97 | |
| 26 | 470Ω | R0603 | 1 | 48 | |
| 27 | 100Ω | R0603 | 2 | 98 | |
| 28 | 2kΩ | R0603 | 1 | 96 | |
| 29 | 3kΩ | R0603 | 1 | 95 | |
| 30 | 15.9kΩ | R0603 | 2 | 97 | |
| 31 | A3941KLPTR-T | TSSOP-28_L9.7-W4.4-P0.65-LS6.4-BL-EP | 1 | 21 | |
| 32 | LMV822IDT | SOIC-8_L4.9-W3.9-P1.27-LS6.0-BL | 1 | 2 | |
| 33 | INA240A1PW | TSSOP-8_L4.4-W3.0-P0.65-LS6.4-TL | 1 | | 10 |
| 34 | KF350-3.5-2P | CONN-TH_P3.50_KF350-3.5-2P | 2 | 6+1 | 40 |
| 35 | ZM4728A | LL-41_L5.0-W2.5-LS5.0-RD | 1 | 7 | 20 |
| 36 | SWITCH | SWITCH_9\*3.5\*3.5MM | 1 | | 20 |
:::
:::spoiler 2024/06/03 BOM
| ID | Name | Footprint | Quantity | Remain | Buy |
| --- | --------------- | ------------------------------------ | -------- | ------ | --- |
| 1 | 20kΩ | R0603 | 1 | 50+ | 0 |
| 2 | 390nF | C0603 | 1 | 0 | 50 |
| 3 | 15.9kΩ(16k) | R0603 | 2 | 50+ | 0 |
| 4 | 10Ω | R0603 | 2 | 50+ | 0 |
| 5 | 100kΩ | R0603 | 1 | 50+ | 0 |
| 6 | 100K排阻0603\*4 | RES-ARRAY-SMD_0603-8P-L3.2-W1.6-TL | 2 | 50+ | 0 |
| 7 | S8050_C19630847 | SOT-523-3_L1.6-W0.8-P0.50-LS1.6-BR | 2 | 50 | 0 |
| 8 | BSS138W-TP | SOT-323-3_L2.2-W1.3-P1.30-LS2.1-BR | 1 | 30 | 0 |
| 9 | BSS138DW-7-F-ES | SOT-363-6_L2.0-W1.3-P0.65-LS2.1-BL | 2 | 48 | 0 |
| 10 | 1N4001 | SOD-323_L1.7-W1.3-LS2.5-RD | 5 | 100 | 0 |
| 11 | 1K排阻0603\*4 | RES-ARRAY-SMD_0603-8P-L3.2-W1.6-TL | 1 | 4 | 100 |
| 12 | 1kΩ | R0603 | 2 | 100+ | 0 |
| 13 | 47pF | C0603 | 1 | 50+ | 0 |
| 14 | 15mΩ | R1206 | 1 | 50+ | 0 |
| 15 | HEADER8 | CONN-TH_8P-P2.54_XH2.54-8P-S | 1 | 30 | 0 |
| 16 | 47kΩ | R0603 | 4 | 100+ | 0 |
| 17 | IPD036N04LG | TO-252-2_L6.6-W6.1-P4.58-LS9.9-BR | 4 | 13 | 80 |
| 19 | 1uF | C0603 | 4 | 50+ | 0 |
| 20 | 4.7uF | C0603 | 2 | 50+ | 0 |
| 21 | 0.47uF | C0603 | 1 | 30+ | 0 |
| 22 | 220uF | CAP-TH_BD8.0-P3.50-D0.6-FD | 2 | 50+ | 0 |
| 23 | 10nF | C0603 | 1 | 50+ | 0 |
| 24 | 1nF | C0603 | 2 | 50+ | 0 |
| 25 | 100nF | C0603 | 6 | 200+ | 0 |
| 26 | LED-0603_R | LED0603_RED | 2 | 40+ | 0 |
| 27 | LED-0603_G | LED0603_GREEN | 1 | 20+ | 0 |
| 28 | 47Ω | R0603 | 4 | 50+ | 0 |
| 29 | 4.7kΩ | R0603 | 1 | 50+ | 0 |
| 30 | 470Ω | R0603 | 1 | 30+ | 0 |
| 31 | 100Ω | R0603 | 2 | 50+ | 0 |
| 32 | A3941KLPTR-T | TSSOP-28_L9.7-W4.4-P0.65-LS6.4-BL-EP | 1 | 20 | 0 |
| 33 | LMV822IDT | SOIC-8_L4.9-W3.9-P1.27-LS6.0-BL | 1 | 20+ | 0 |
| 34 | INA240A1PW | TSSOP-8_L4.4-W3.0-P0.65-LS6.4-TL | 1 | 9 | 10 |
| 35 | KF350-3.5-2P | CONN-TH_P3.50_KF350-3.5-2P | 2 | 50 | 0 |
| 36 | ZM4728A | LL-41_L5.0-W2.5-LS5.0-RD | 1 | 20+ | 0 |
| 37 | SWITCH | SWITCH_9\*3.5\*3.5MM | 1 | 19 | 0 |
:::
#### Extra reamins
- Resistor
- 0R 0603 50pcs
- 330R 0603 50pcs
- 20k 0603 100pcs
- 1k pack 0603 15pcs
- 150R 0603 50pcs
- Capacitor
- 100pF 0603 100pcs
- Bead 0R 1A 50pcs
- 470pF 0603 50pcs
- Transistor
- S8050 SOT-23 15pcs
## V2.3
### Log
#### 2024/07/03
* <a href="#20240703-001" smoothhashscroll="">Development[001]</a>
### Development
#### 2024/07/03 [001]
- Finish PCB soldering
- The board performed well.
- The only problem remains in <a href="#20240427-001" smoothhashscroll="">V2.2 Debug [001-3]</a>
- **Small bug:** The SMD pads of the C6 and C9 220uF capacitors were missing due to a bug in the transfer of the PCB file from EasyEDA Std to Pro, causing it unable to use SMD capacitors.
- 