Another attempt at building a motor controller

Joined
May 25, 2018
Messages
197
With the stimulus checks for COVID and my old bike starting to show its age, I've decided it's time for an upgrade. I'm planning on purchasing a frame from Vector eBikes (Pretty good company AFAIK) and a QSMOTOR v3 rear hub. My current battery is super overkill for what it's doing (2 kWh of Samsung 30Q goodness) and I am itching for an upgrade.

However, my current controller is only good for 60 battery amps. It is a really cheap ($35) Chinese 18-FET controller with quite a few mods. It performs well but I don't want to push it any further or I'm afraid I'll blow it.

Since my last attempt at building a controller (which failed miserably), I've gotten a lot better at power electronics. Last summer I built a 1kW subwoofer amp for my car (runs off an eBike battery) and it's been quite reliable. When laying out the amplifier circuit, I kept loop area down as much as possible to minimize inductance and my cheap o-scope showed a lot less noise. Looking back at my first attempt I can't help but gag. I don't even know how much inductance there was but I wouldn't be surprised if it was 5x what a proper design would be.

To start my new design, I will essentially copy the board layout of a generic 12-FET controller, with either 12 HUGE IRF100P218https://www.digikey.com/en/products/detail/infineon-technologies/IRF100P218XKMA1/8627116s or 24 standard sized IRFB4110s. I'm currently leaning towards the larger TO-247 FETs because they have 4x less internal resistance and I'll only have to fit 12 FETs instead of 24. Only downside is that a set of TO-247 FETs costs about $80. A bit pricey but they should be bulletproof as I use shoot-through proof gate drivers and proper protection circuits (and fuses at first).

For the microcontroller, I plan on using a Teensy 4.0 development board. With around 750 MIPS non-overclocked, I could probably write the firmware in CIRCUIT PYTHON and be fine. (Just kidding I'll do it in C++).

To assemble everything together, I plan on screwing the FETs to an aluminium heat spreader (with kapton) and then bolting that to a hollow aluminium extrusion that will form the main case of the controller. Anyone know a good source for finned hollow extrusions?
 
Is there any reason you don't go with a system that someone has already invested bulk time in developing ?

At least for the control side? Make your own power stage, but use (for example) Lebowski for the control side?

Seems like it wouldn't be "too hard" to make a basic DIY controller, but if you want something with good "modern" features such as FOC and field weakening, it'll take a massive investment in time, and learning.

Why not stand on the shoulders of giants ? Focus on your own power stage only, and see some rewards quicker (and probably better). You can always do your own control system afterwards.
 
This is as much of a learning project as it is a practical eBike controller. I already have a controller that is capable of 60-70 battery amps, enough to get me up to likely 45-50 MPH in the frame I am doing.

I'm not your typical Arduino noob anymore. Since my last attempt, I've managed to become good enough at low-level programming to run an entire battleship game, complete with over 500 RGB LEDs, off of a chip with only 16 MIPS and 2 KB of RAM. https://hackaday.com/2020/12/26/squeezing-every-bit-from-an-atmega/. I'll have no problems with performance when my MCU is 20 times faster than the one Lebowski is using. I'm not that good yet but getting code that runs at 5% of Lebowski's speed will be a piece of cake, especially with HALF A MEG of high-speed, single-cycle latency RAM for lavish look up tables. I know it's way overkill but I can always lower the clock speed to save power if I have horsepower left over (I most likely will have a lot).

I'm a third year engineering student (Linear Algebra, Calculus, Etc.) and readily understood https://www.youtube.com/watch?v=oHEVdXucSJs This video series on controlling motors with FOC and SVPWM. If I implement the algorithms described, as well as a few custom tweaks, I'll have a brain board almost as good as Lebowski's (except the sensorless part, I'll need halls).

What I am expecting having a bit of difficulty with is the power stage. I've got the basics down (Minimize loop area, bus bars, decoupling) but I'd like a more experienced builder to give it a quick glance to make sure I don't miss any gotchas.
Given that the FETs I'm using are only 1.2 milliohms a piece and I'm using 12 of them, this thing will have roughly the IR of a 36 (!!)-FET IRFB4110 controller and will be able to handle continuous phase currents of over 300 amps... That is, if I design the power stage well.
 
Some pictures of the in-progress schematic and board.
Schematic.pngPretty much a standard power stage, with an IR2110 to handle the high peak gate currents that the massive FETs demand.


TopBoard.pngTop of the board. The golden area in the render is where a big bus wire (8 AWG) will be soldered. I will also be adding large, low-ESR capacitors (and smaller-value, lower inductance decoupling capacitors) to suppress high-frequency noise on the bus.


BoardBottom.pngBottom of the board. A 8 AWG bus bar will be soldered there as well. Since the bus bars are only a PCB thickness apart inductance will be kept to a minimum.

Drivers.pngHere's where I'm planning to put the gate drivers. Haven't routed the traces yet but they'll be pretty short and direct.


To further reduce inductance and power-stage noise, I also will probably use a component inspired by Litz wire. I'll have about 20-30 fine stranded wires twisted together, with half carrying positive voltage and half carrying negative. Inductance with that setup should be far lower than any other power stage design I can think of. I'll have one litz run going to each bank of 4 FETs. It won't have to be massive as it will mostly be carrying only the high frequency components of the rail current.

One last question: Should I have separate power and signal ground planes, joined at one location (star ground), or would one unbroken ground plane be better?
 
Finished.pngFinished the board, still a bit of space left if I want to add any new features. I decided on a wide-range buck converter IC for the 12v supply, allowing me to power up the board with as little as 15 volts for initial tests with no risk of FETs blowing (max gate voltage 20 volts).

Decoupling of the power stage looks pretty solid, with 10uf of distributed ceramic capacitance right next to the FETs. Since the bar stock I'll be using to mount the FETs allows about 1/4" of space behind the board, I'll epoxy 1uf capacitors to the rear edge of the board (as many as will fit) and solder them to the positive and negative buses. The 30uf of ultra-low-ESR capacitance right next to the FETs should be more than enough to stop any ringing. I also added a RC snubber on each phase as well to damp any ringing. I don't think I'll end up using the snubbers (they increase switching losses by about 2 watts @ 72v) but if the oscilloscope says they help, they'll stay.

On the control side, I will be using the same custom serial-based system that I used on my old bike. I'll have an Arduino and LCD on the handlebars that will take input from the throttle, brakes, etc, and send serial data to the Teensy to control the bike. The display will also show volts, amps, temperature, speed, etc. Basically a cheaper Cycle Analyst with a bigger screen.

If everything works as intended, I will be selling my 3 leftover boards for $4 apiece, plus shipping. I've added a header on the board for compatibility with the Cycle Analyst v3. Once I get everything working I will release the code and schematics, probably on Github.

EDIT: Whoops, I had a diode under where I planned to glue an inductor. I'll give it one last thorough look-over and I'll be sending my PCB and parts orders off tonight. I should be able to start working on hardware next weekend (hopefully).

EDIT 2: Leftover board order quota has been filled. I'll still be posting files once I get it working so you can print your own.

EDIT 3: I had a very knowledgeable engineer (Peter Marinov) review my board and I ended up doing quite a fairly major redesign. First off, the pinout for the IR2110 was incorrect (It's Wide SOIC-16 not SOIC-14 like the DIP version) and the power supply layout needed some work as well. JLCPCB Already finished production and board should be here in a few days. First will be the vBatt - 12v DC-DC converter, I'll post that in a separate post.
 
The boards have finally arrived and I've spent the last few days soldering components. The hardest part was fixing my shop's broken hot air station (underspec'd chinesium resistor burned out).

The first thing I built was the 12v and 5v DC-DC converters. Peter Marinov suggested that I use Webench to design the SMPS schematic and the results are quite impressive. There is only around 10 millivolts ripple on the 12v line, and even less on 5v. It probably helps that I used way too many decoupling capacitors.

Getting FlexPWM working on the Teensy was a lot harder than it should have been. FlexPWM works by having 4 registers and a counter that counts only up to a preset value. When the counter value hits the first register, PWM pin A turns on. When it hits the second register, PWM pin B turns off. The 3rd and 4th registers control PWM pin B in the same manner.
However, the designers at Freescale intended that all of the half-bridges for one motor drive be connected to the same FlexPWM module to stay in sync. Unfortuantely, the Teensy 4.0 only has 4 pins that share the same module, so I had to split it between two modules.
Getting the modules to stay in sync was a pain. I spent 3 hours digging through the datasheet for a signal that could reset multiple modules at the same time, but the best I could get was within a 15 nanoseconds of sync due to the finite speed of the core. I finally gave up and settled on setting the first timer to run one cycle faster, entering a for loop filled with NOPs, and setting the timer's period to its initial value after a delay (determined by experimentation).

Once I got the FlexPWM working, I added half the FETs (and a power supply fuse) and programmed the Teensy to generate three PWM waves 120 degrees apart. After a bit of oscilloscope checking, I hooked up a BLDC motor and it turned. Even with basically no decoupling, the drain and supply rails only had around 5 volts of ringing. I don't know the motor current (sensors aren't configured yet), but it was enough that I couldn't stop the motor by hand (no wheel attached). The FETs were maybe a two or three degrees above room temperature with no heatsink.

Unfortuately, I don't have any oscilloscope photos to post because I neglected to take them. When I go into the shop in a few hours, I'll post some.
 
After several days of building and testing, I've found that most of the board works very well. The 70x 1uf ceramic capacitors soldered along the power rails result in minimal power rail bounce at 35 phase amps, even with no electrolytic capacitors added. The bus bars handle the current nicely, and the power supplies and decoupling networks provide relatively clean power to all components on the board.

There are also several parts of the board that don't work very well.

My idea for a cheap hall-effect current sensor was to attach a 5 amp SOIC-8 sensor in parallel with the main trace, and beef up the trace going to the sensor until I got the appropriate response. Unfortunately, the hall element in that IC is too sensitive and gets thrown off (up to 15-20%) by the current passing through the phase wires and generating a magnetic field. The solution: In V2, I'll use a hall sensor that is rated for the current I wish to measure.

For driving two FETs in parallel with 24nf of gate capacitance each, the IRS2010 gate drivers I chose aren't doing a very good job. During each switching transition, the MOSFETs are half-on for around 300 nanoseconds as the gate driver charges the gate. As the high-side FET turns on, the low-side FET's gate bounces up to around 1.2 volts when using a 22 volt power source. At 72 volts, this would be on the edge of causing Miller shoot-through. The dI/dt and dv/dt in the power stage are also causing noise on the digital side. The solution for both these problems is to use an isolated gate driver that can sink more than it can source. By adding -5v power rail and another bootstrap circuit, I can drive the FET gates to -5v when off, making Miller shoot-through a non-issue. To further reduce gate noise, I'll be running a twisted pair to the gate and source pins, just like Lebowski's power stages. I might also try ferrite beads around the gate drive wires if needed. The isolated gate drivers will also allow me to have two separate PCB's, further reducing noise at the Teensy.

Furthermore, the new gate drivers (UCC21540ADWKR) only require 1 PWM pin per driver instead of 2. FlexPWM code will be so much simpler now that I can run everything off of 1 FlexPWM block instead of trying to herd cats with 2.

With a big heatsink attached, I estimate my current board would be good for around 120-160 continuous phase amps with a 52 volt battery. Plenty for a normal e-bike, but my next bike (powered by a QS205 3t with Statorade) will be nowhere near "normal".

Final version of v1 board:IMG_20210201_002542.jpg

Drain-Source switching transition - pretty clean at 30 amps:IMG_20210131_004219.jpg

Gate drive, not so much. Needs ferrite bead and better driver:IMG_20210130_110353.jpg
 
Hey! Another guy building a controller for lols, like me!

My advice, with no warranty. I'm no pro at this...

Get jlcpcb or whoever to do as much of your soldering as possible. Debugging crappy solder joints is a waste of your life.

Re. The gate drivers and FETs... My understanding of gate driver current is that it's given as the most it can do due to it's own resistance, not that it'll die if you use too small gate resistors. You 6.8 ohms with 24nF is on the slow side and at a few (2.2 to 3.8Vgth) volts that's not a lot of pull to avoid Miller turn on. 2.2Vat 6.8 ohm is only 300mA pull on each FET. That said, it's a bit surprising you're approaching Miller with such huge input capacitance (24nF) and low reverse transfer (150pF). I'm hypothesising there may be another cause? Inductive coupled kick on the gate lines? I dunno... Is it really bouncing that much? Are you just getting scope artifacts? Maybe it is, but make sure you're using one of those spring things. I was panicking wildly about ringing and all kinds of things until i realized it was just the scope probe ringing.

Miller or inductive turn on is one of the things I've been fearing the most. It shouldn't happen. Modern FETs are designed to avoid it with big effort to reduce the reverse transfer capacitance. My math says it shouldn't happen. But if it does, it feels to me like one of the hardest things to bodge your way around, especially if it's inductive turn on. Miller could be mitigated to some extent by putting a diode on top of the gate resistor to increase the pull down.

If you're starring your ground, you'll want to take care to have the signals etc routed close to the ground star otherwise they have a big inductive loop. I'd tend towards a big solid ground plane, it takes less thought andi feel like it's less likely to massively mess up...
 
https://www.infineon.com/dgdl/Parasitic_Turn-on_of_Power_MOSFET.pdf?fileId=db3a30431ed1d7b2011eee756cee5475
Have a read of that. I don't think it's the whole story since if you have a return path to the gate driver with significant parasitic inductance, the output capacitance might start to interfere; 3.5nF and 24nF in your case might be more significant... But...

It says simply
(For a12V system) "in order to have a low sensitivity to parasitic turn-on, a CGS/CGD ratio has to be as high as possible,
possibly >15 (or at the very least >10)."

Your chosen FETs are more like 180, which would imply it's completely safe even at 100V. The FET data sheet says ideal for it. :confused: it shouldn't be having parasitic turn on.
 
Incidentally, your gate doesn't need a ferrite bead.

The jagged stuff on the gate trace is the point at which the mosfet actually turns on, then there's... Stuff... Happening across it's capacitances. The FET input is not an ideal capacitor. There's a period at about 3-4V where it is absorbing charge while opening the drain source channel, with no (or small) change in gate voltage. See diagram 14 of your FETs datasheet :wink:
 
I just got back from an oscilloscope session and I'm pretty sure you're right about the cause of the gate ringing. On my current board, the gate traces are directly above the (high di/dt) phase traces and some of them are almost two inches long. Upon closer inspection, what I thought was miller turn-on is actually ringing due to inductive coupling between the power and gate trace. With about 2cm^2 of loop area for some of the FETs, I'm not surprised. I'm also using 3.3 instead of 6.8 ohm for the gate drive and plan on decreasing that to 2.2 ohms once I get stronger drivers. Now that I know it's inductance, not Miller, I won't need my -5v supply anymore. That's about $5 less BOM cost and less to debug as well.

The new design will use twisted pairs running directly from the gate drivers to the FETs, soldered as close to the case as possible. The Lebowski controllers use this technique and work quite well.

The SMD soldering isn't a problem with flux and a decent hot-air gun. After a moderate learning curve, I estimate it takes me around 6 hours / board to solder all the SMD. It'd be a lot less if I printed out an enlarged picture of the PCB and wrote component values on it. It's pretty easy - tin the pads, add some flux, put the parts on, and apply hot air.

Regarding ground planes - I'll be using isolated gate drivers for v2, so I will have separate power and signal grounds, joined only at the battery negative wire and separated by about 9mm. I won't have to worry about noise on the power ground messing with the digital side of the board, especially the ADC readings.

To further simplify (and bulletproof) things, the gate drivers in v2 have built-in adjustable hardware deadtime so I'll only need 4 pins (A, B, C, and Disable) instead of 6. With all the pins on the same FlexPWM timer, I'll no longer have to herd cats to get my PWM timers synchronized.

P.S. I'm quite impressed with your MESC ESC that you're designing, especially the clean transitions with no ringing. If you used IR DirectFET packages, you could probably bump up the current quite a bit (w/ heatsinking) and still have virtually no ringing. Unfortunately the leg inductances of TO-247 make a bit of ringing unavoidable in my design.
 
Finished version 2, I'll give it a good look over tomorrow morning before sending it off to get manufactured. The new, optimized gate driver circuit was a tight squeeze to fit in without touching the gate drivers. Fortunately, tight packing = low inductance = clean turn-on/off = happy FETs. The male headers in the rendering is where the twisted wires will go to the FET gate/source terminals.

The new current sensors (Melexis MLX91220KDF) use differential hall sensing and will pass a greater fraction of the phase current (10% not 1%), so they should be about 100x less susceptible to interference from high amps in the phase wires. Furthermore, their fixed (as opposed to ratiometric) output is better for the Teensy's fixed 3.3v ADC reference voltage.

Total BOM + Board cost is around $165 / piece (including wires and Teensy), significantly less if ordering in bulk. Pretty economical compared to alternatives like Kelly, even if you factor in sunk R&D costs (around $65 so far) If this is successful and there's interest, I plan on selling kits for around $250 (SMD parts pre-soldered). With it being open-source, you can also procure parts and boards yourself.

Currently, there are quite a few controllers on the market, but either they suck (generic Chinese boards), are overpriced and inflexible (Kelly, ASI, Sabvoton), great but huge (Lebowski v1), or hard to make DIY (Lebowski V2). The goal of this project is a controller with a well-documented schematic and code that even laypeople (who know a bit of electronics) can understand and tinker with. In addition, it will be easy to extend; putting output stages and gate drivers on both sides will result in a controller with double the ratings for ridiculously large hubmotors or serious drag racing.
 
Images of version 2

Full board render
Gold areas will be beefed up by soldering 12 gauge copper wire(s) FullBoardRender2.png
Gate driver schematic GateDriver2Sch.png
Gate driver layout GateDriver2.png

The PDF is a schematic of the board as it is now. Untested but very close to the final schematic.
 

Attachments

  • CBEController.pdf
    204.1 KB · Views: 67
Thanks for the positive on the MESC! I wish i had more time for it but life has caught up and energy running out...

In my opinion... TOLL FET is far better than directFET. I'm nowhere near the current limit of the FETs with anything i currently have to plug it into. I read an infineon appnote where they basically say the TOLL is the best, hands down.

My opinion on the new ideas? I'm a bit worried you're piling up complexity to solve problems that should be solved by a bit of tidying up and good use of ground planes and power planes. I wouldn't do this twisted wire pair. I can't see that a twisted pair is ever going to be lower inductance than a decent differential pair on the board, and the connectors/joints get bigger and ugh... Kelly, sabvoton, the big vedder VESCs etc don't need to do this, they'll push several hundred amps for a few seconds, and for gate signals it makes no odds if they go for 100pwm cycles or 100 days. They also don't have isolated gate drivers. Isolated gate drivers and twisted pairs are for when your power stage is so huge you can't fit it on one board, your transistors are bolted to the wall etc.

Have you got enough caps? You've got a ton of board space left so put 2x as many electrolytic on. You're looking for hundreds of amps at 80V... And you don't have to fit them.

Your gate resistors. Huge packages. You can use 0603. They dissipate barely any power. P=C*V²*F where C is gate capacitance V is gate drive voltage. 24n*15*15*20000. That n has a lot of zeros.

I used to agree with you on the soldering, i built several MESC boards, but eventually 6 hours adds up once you're building your 8th board and you realise resistors are cheaper from jlc smt service then from mouser...
 
A friend and I made a massive MOSFET comparison spreadsheet:
https://docs.google.com/spreadsheets/d/1X2rFGrNOMii--7HAyMUkI9mJYP8kVNinVh1hMb_GhCk/edit?fbclid=IwAR1Hopctt9o51lELXJOxQnFg8m0Tos6-PwqkiX4pS0aPTT9Qt4Hb6GpUWxg#gid=1234077870

He's since gone and added some capacitor comparisons as well.

Oddly the DirectFET and HSOF/TO-LL don't fair so well but DFN8/DFNW MOSFETs fair quite well.
 
I've seen this spreadsheet before and nearly changed over to dfn style FETs, the reason i didn't was:
1)i was just sceptical of the amount of amps they claim for those tiny FETs
2) the fight for smaller is counter intuitive. You basically have a fixed amount of heat generated by switching and rdson and need to sink it. This requires thermal paths. The conduction out of a dfn just doesn't seem as good as a TOLL.
3) at some point, the PCB traces will burn. DFN legs are tiny compared to the big metal lumps on TOLL and direct FET.
That friend was euan, the a200s guy right? His ESC targets extreme small ness... And the cost? Well... I guess it goes some way towards offsetting his 8 layer 8oz copper board :lol:
 
Yeah, Euan does have an unhealthy fixation with SMOL ESCs and while I don't disagree with you, he's been getting some promising results from the latest A200S.
 
My fixation is not on tiny ESCs. It's on being able to have hundreds of phase amps and the wheelie-popping torque that goes along with it. Once I get the final version done, I'll have an accelerometer and Arduino near the front of my bike controlling everything and with a bit of PID tuning, should be able to do continuous, stable wheelies.
It'd still be nice to have an open-source Phaserunner alternative though.

4-layer PCB's are several times more expensive at JLCPCB compared to 2-layer. Even though it would be easier to get good performance out of 4-layer, I wish to keep the cost down as much as possible. I don't see how I could make the ground planes any better with the current 2-layer board.

For the gate drive wires, I absolutely need twisted pairs with my layout. Routing gate signals over the (high dv/dt and di/dt) phase traces is just asking for inductive coupling and shoot-through at higher currents, even if I use a differential pair. I'm not sure how Kelly, Sabvoton, etc. lay out their boards but gate drive trace on top of phase trace = bad. I'm not sure if the diodes and second resistors in the gate drive circuit are needed. Better to include and not populate than realize you have to spend $25, a week of waiting, and several hours of labor to try a new design.

Regarding caps, I have around 70 uf of ceramics soldered to the back of the board and plan on increasing it to 120 uf (as many as will fit) for version 2. Preliminary tests with 35-40ish phase amps showed around a volt of power supply ripple, even with zero electrolytics populated. I see where I could squeeze in another two electrolytics without a major redesign so I'll go ahead and do that. Doubt I'll need to populate them though.

You're right about the gate resistor sizes, they barely got warm on version 1. Changing them to 0805 from 1206 will cut down inductance as well.

Back of the board:v2Back.png
Ultra low ESR/ESL decoupling: IMG_20210204_093543.jpg

Edit: Said 2-layer when I meant 4
 
Mxlemming, I don't see how they're claiming 500 amps out of those tiny FETs either. It'd be doable if you could magically keep the tabs close to ambient, but for that you'd have to solder a copper heat spreader which wouldn't be easy and defeats the purpose of having a tiny FET.
It's sad that IR is discontinuing the IRF100P218/219, they are the best FETs I've ever seen and the large surface area of the TO-247 package makes getting the heat out easy.
 
Pinski1 said:
Yeah, Euan does have an unhealthy fixation with SMOL ESCs and while I don't disagree with you, he's been getting some promising results from the latest A200S.
Not arguing his A200S is bad, it's incredibly small and high power density. Quite a triumph, complete with a few explosions along the way he's been kind enough to share. I just wonder, is it pointlessly small and does it need bolting to an enormous heatsink to realise that power, thus rendering the power density in PCB terms a bit futile?

thorlancaster328 said:
My fixation is not on tiny ESCs. It's on being able to have hundreds of phase amps and the wheelie-popping torque that goes along with it. Once I get the final version done, I'll have an accelerometer and Arduino near the front of my bike controlling everything and with a bit of PID tuning, should be able to do continuous, stable wheelies.
It'd still be nice to have an open-source Phaserunner alternative though.
This is the dream. I own a Street Triple 675 that gets to 150km/h in a matter of seconds, and carries on to about 240... so the speed is neither here nor there for me;) but the lightness and quietness will make crazy fast off road and mountain bike trail centers etc much more fun.

4-layer PCB's are several times more expensive at JLCPCB compared to 2-layer. Even though it would be easier to get good performance out of 2-layer, I wish to keep the cost down as much as possible. I don't see how I could make the ground planes any better with the current 2-layer board.
Is it expensive because you went over 100mmx100mm? I always made my golden rule to be below that size, because I am tight. I pay 5.5USD plus postage for 5x 4 layer boards from JLC.

For the gate drive wires, I absolutely need twisted pairs with my layout. Routing gate signals over the (high dv/dt and di/dt) phase traces is just asking for inductive coupling and shoot-through at higher currents, even if I use a differential pair. I'm not sure how Kelly, Sabvoton, etc. lay out their boards but gate drive trace on top of phase trace = bad. I'm not sure if the diodes and second resistors in the gate drive circuit are needed. Better to include and not populate than realize you have to spend $25, a week of waiting, and several hours of labor to try a new design.
Route the traces on an external plane (you don't have any internal planes), you can cut them with a knife if needed. If you do it sensibly, you absolutely do not need twisted pairs for a 3 cm hop.
On top of phase trace is not necessarily bad if the currents are perpendicular, and especially not for the high side FET.
I see your problem though, your layout does make routing on a 2 layer board rather tricky if you want to keep the ground plane tidy. The twisted wires won't harm so meh. Do it.

Regarding caps, I have around 70 uf of ceramics soldered to the back of the board and plan on increasing it to 120 uf (as many as will fit) for version 2. Preliminary tests with 35-40ish phase amps showed around a volt of power supply ripple, even with zero electrolytics populated. I see where I could squeeze in another two electrolytics without a major redesign so I'll go ahead and do that. Doubt I'll need to populate them though.
:bigthumb:
Eventually, with 400A, your caps will get rather hot and die. More caps = less load per cap = less heat = less capacitor death.

You're right about the gate resistor sizes, they barely got warm on version 1. Changing them to 0805 from 1206 will cut down inductance as well.
You could probably use 0402 or 0201 and it would still be OK... 0603 I think is the happy medium.

Back of the board:v2Back.png
Ultra low ESR/ESL decoupling: IMG_20210204_093543.jpg
This is really quite an innovative technique. Can't see it catching on for mass production, but hey!

Few more questions... What is L5 for?

Are your inductive current sensors referenced to the MCU side of the ground star (correct) or the power side (nuh huh).

Another thought is that NXP has a motor control library. Have you looked into it? I wired my ESCs up so that I could use the ST library, although I later implemented my own FOC. It was useful to do that since it demonstrated quite clearly at the start the board worked, and it was just my shitty software that was the limiting factor (still is... I suck at code).
 
Your hall sensors. Filter them - about 1MHz cutoff; about 1nF after the 2k input impedance will do on your circuit; I used 4k7 and 100pF and it completely solved the problem. They will be routed near to the motor phase wires, and will pick up a lot of noise. I have seen it on my first revision and one my colleague made. It royally f^cks up the hall sensor detection, especially if you are using interrupts or timer resets. I used a phase locked loop sampling at the middle of PWM period and counting PWM pulses to get around this, but it barely worked atall with the ST firmware.
 
They will be routed near to the motor phase wires, and will pick up a lot of noise. I have seen it on my first revision and one my colleague made. It royally f^cks up the hall sensor detection, especially if you are using interrupts or timer resets.

Good point - I never thought of that. Makes sense that 70+ volts switching in a few hundred nanoseconds would couple to the hall sensor lines. I'm hoping to eventually get sensorless running, but sensored is always nice to have.

The board would be expensive as a 4-layer because it's 200x80 mm. Getting 12 TO-247 FETs on a board half the size would be pretty close to impossible.

On top of phase trace is not necessarily bad if the currents are perpendicular, and especially not for the high side FET.
Makes sense but there's no way to keep the gate drive traces perpendicular to the phase traces on the bottom and still end up at the right gate pins.

Given that the QS205 can only take 150 phase amps on a continuous basis, I don't think my capacitors will get that hot, especially with all that ceramic on board to absorb the high-frequency PWM energy. If needed, I can probably throw about 4 more on the board and run twisted pairs to the power rails.

L5 is to keep noise from coupling from the analog to digital side. It's probably useless because of additional regulators downstream but it might help reduce noise and lead to cleaner ADC readings. Everything except the FETs are connected to the analog ground.

Another thought is that NXP has a motor control library. Have you looked into it? I wired my ESCs up so that I could use the ST library, although I later implemented my own FOC. It was useful to do that since it demonstrated quite clearly at the start the board worked, and it was just my shitty software that was the limiting factor (still is... I suck at code).

I'm more of a software guy myself. Even on v1 with no useful current sensing I still got a motor spinning smoothly with sinusoidal SVPWM. Interrupt fires off at every 20Khz PWM cycle so everything stays synced. Even with my fancy interquartile ADC smoothing, I'm only using roughly 25% CPU (speed = 390 MHz) in the FOC interrupt.
For driving challenging motors with very non-sinusoidal BEMF, I will use a combination of standard PID and a loop-up table that will calibrate itself as the motor runs. Once I get that and rotor detection (sensors + interpolation) working, I only have to adjust the angle and magnitude of the current vector and I will have a working FOC.
 
Now that I think about it, having a look-up table of motor BEMF will enable a whole bunch of special features that other controllers don't have. If I know the current and voltage vectors, I can calculate the rotor position (sensorless FOC). It should also be able to measure phase-phase resistance and get an approximate motor temperature (after self-calibration of course).

A lot of previously unfathomable stuff becomes possible when you have a processor that's 10x faster than strictly necessary.
 
I was thinking about a back emf table as well. I'm on 72mhz and using about half the clock cycles at 35khz so there's definitely space for it. I do often wish i didn't have to worry about using divides, square roots etc though, maybe i should have sucked up the cost and used H7 stm but i target cheap... So far BEMF table seems unnecessary. Even with a motor with a terrible BEMF it generates very clean sinusoidal current, provided the angle is accurate. If the hall sensors are off, it generates more of a saw tooth...

Hall sensors I found were just so much easier than sensorless. Save a lot of frustration with initial spinning.

Consider a ferrite instead of L5. An inductor and a few uF is likely to oscillate rather than damp out noise.
 
I'm coming around to really liking this, after initial dislikes...
(Arduino
Through holes
No hardware over current)
But I'm increasingly thinking it's quite good; as long as the foc out trumps the everything else in priority, you've then got a really really easy to build applications on platform. That teensy 4 is crazy powerful compared to everything else.

Arduino has some serious advantages over vesc for being useful - namely the licence. It's all LGPL at the user developer stage, so it makes sense for products. One big thing that's been bugging me about VESC is the gplv3, which means anyone and everyone must have source. This sounds great, except...

These things can kill people. Having the freedom to fettle by running 10 lines of terminal in Linux is dangerous... Any newb can change the current limits, voltage limits in a few minutes, and then face plant their onewheel or whatever when it burns. I've been doing a lot of regulatory stuff for work recently and honestly, it seems like a legally very dangerous place to be releasing your product source on things like this. It's not like this is logging the weather or taking a picture every time the door is opened... It's propelling people to potentially 100km/h.

For this reason, I released all my code under BSD 3 clause...

If you made your code into a library where you just implement a few low level functions... Write the pwm, generate a break condition, read the ADCs, halls... It could be trivial to port to other boards within arduino... Obviously only the more powerful ones...There is now arduino support for many stm32f4 targets including f405, which could make your code portable to many vesc boards even.

Hardware I'm also liking more and more... The gate drives and current sensors are far cheaper than I thought and could be very scalable since they enable hundreds of volt operation. The isolated phase sensors make synch with pwm optional... Which makes the code much more portable.
 
Back
Top