New ground-up ESC - MESC_FOC_ESC

Electric Motors and Controllers
mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 08 2020 6:26pm

Hi forum, second post ever. I'm not really an online person, but Hi.

I'm making my own ESC, basically because I like tinkering with electronics and kind of want to for fun, partly because I'm learning software, but also because there wasn't anything vaguely small, cheap and powerful for my EBike... VESC is upwards of 200$ for an original from Trampa, upwards of 65 for a basic Flipsky 4.20 that's really only good for 600W continuous and probably only 10 ish series cells, despite saying 13s.

So my target is cheap and powerful and high(er) voltage capable, kind of the same intention as Shaman's Cheap FOCer, but not VESC, and probably substantially cheaper for similar or more power as a result. That's the target anyway.

I'm at the stage where I spun my bike wheel with the R1.0 board. Slowly.
https://www.youtube.com/watch?v=UVoDkMEkBVg

I made the following design decisions:
Standard footprint <1$ 600V 4A gate drives and TO263 FETs, no special combined funnyness like DRV chips.
STM32f303CB micro - they're cheap at like 2USD, embed opamps, have an FPU, can definitely run FOC (ST have standard software for it that I have flashed onto an earlier, tiny, non ebike board I made with the same MCU).
I have used a TI Boost converter 5V-12V for the gate drivers, so the upper voltage limit can go to whatever the FETs are rated to, by simply disconnecting the buck converter (snip/DNF a ferrite bead) and powering the logic from 5V on the PWM in, or USB in. Below 60V operation and a TI buck converter can create the 5V rail.

I militantly 2 layer boarded and one sided assembled it, and kept the ground plane as unbroken as possible. Heatsink can be bolted to the underside. I think the BoM cost is below 25$. Think.

I'd like a few bits of feedback/commentary:
1) What are the best connectors, and what do we really want for our EBikes and boards? Currently I've got Molex Picoblades, because my motor had a picoblade put on it by my friend... but I'm sure something else is preferable, those Picoblades are a complete PITA and don't seem very robust either.
a) Hall connector
b) PWM in connector
c) UART connector
d) I have an I2C, 3v3 and GND connection, in case of plugging in an inertial sensor, or interfacing with a BMS or SSD1106 screen thingy
e) There's a USB B micro that is probably not going to change.

2) What other inputs are desireable? (none is a great answer).

3) Any clangers anyone can spot? Appears to work pretty well based on my limited testing so far, but I have yet to run it beyond 20A phase current and 23V, owing to the PSUs I have...

4) How the heck do I bench test a board that'll drive something in the region of several kW of power? How do I sink that much mechanical energy while not riding up a hill (at my desk or in my garage)? I've got a load of car batteries kicking about to generate 48V, so got that side of things covered...

Image
Image
Image

Cheers,

David

thepronghorn   1 kW

1 kW
Posts: 306
Joined: Mar 27 2011 8:07pm
Location: Bay Area, California

Re: New ground-up ESC - MESC_FOC_ESC

Post by thepronghorn » Aug 09 2020 4:05pm

Hello and welcome!
mxlemming wrote:
Aug 08 2020 6:26pm
....
So my target is cheap and powerful and high(er) voltage capable, kind of the same intention as Shaman's Cheap FOCer, but not VESC, and probably substantially cheaper for similar or more power as a result. That's the target anyway.
....
As another comparison point for your market research, you could also look at the custom open source firmware that casainho and now stancecoke wrote for the KT motor controllers. Are they small enough for you?
viewtopic.php?f=30&t=87870

Is there anything wrong with VESC besides requiring a slightly more expensive microcontroller? You can still use your cheap gate drivers and mosfets.

Is the design going to be open source? Are you hoping to sell these yourself or provide kits?

As far as your questions:
1. The best connectors depend on what market you are going after (ie copy the connectors other controllers use so you can be a drop in replacement) and how weatherproof you are trying to be. There is a big difference between the fully potted phaserunner and the heatshrinked VESC 4.20's you mentioned from flipsky.

3. Not sure how much power you're actually aiming for, but you'll probably need to populate more bus cap for 600W+. Run some double pulse tests to check your power layout.
Why buck down to 5V then boost to 12V? Unless you want to enable <12V operation, it seems easier to buck to 12V first with a linear regulator down to 5V.

4. See zombiess recent motor controller threads for dyno ideas. You could also build an inertial dyno. The best place to put several kW of power is to regen it back into your test motor. Other places include heating up water, spinning up large masses, moving masses up hills, and heating up air.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 11 2020 3:45am

Hi,

I'm not really planning on making these for profit. If anyone else wants to make my design, they're welcome to. Yes it's open source, but the main objective is me learning how to program and design electronics, jumping in at the deep end.

VESC makes my head swim with the complexity of the code. And needs Linux which is a bit of a pain for me. There's nothing wrong with it really, I just want to have a go myself.

The boost from 5 to 12 is slightly counterintuitive but I think actually very logical - the gate drives only use a few mA at full power, whereas the 5v could use any amount on peripherals. The micro eats up about 60mA so already 10x the gate drives. Additionally, I can power the micro and gate drives from the usb plug, which opens up any amount of bus voltage by just removing the buck converter.

The flipsky vesc has jst PH connectors. My motor has jst ZH. If their sensible choices, I'll put them on v2.

Thanks for the double pulse test hint. I'm not sure what it is but I'm sure I can find it.

Caps chosen based on 100amps, 30khz so roughly 15us charge/discharge, 220uFx3 gives a ripple using I=CdV/dt of 2.3V. Of course the caps don't take anything like all the current.

The ESR might be a problem re. heating... But putting more caps in v2 is an easy mod.

Cheers! Thanks for the feedback.

zombiess   1 GW

1 GW
Posts: 3009
Joined: Feb 01 2011 2:16am
Location: Ventura

Re: New ground-up ESC - MESC_FOC_ESC

Post by zombiess » Aug 11 2020 4:09pm

If you think the VESC code is complex, I'm guessing you are not planning on FOC control as it is quite complex to wrap ones mind around and comprehend, unless you already have that part.

Trying to do 100A "cheap" is not the greatest of ideas. Big currents are unforgiving to mistakes. Wear safety glasses during testing, hot MOSFET chunks flying at your eyes is not happy fun time.

Bucking to 5V then boosting up can work, but i would suggest using an unregulated module to accomplish this, they cost $3-8. Designing converters can be a complicated ordeal. I happily pay $10 per chip for solutions from analog devices due to the tools they provide for designing converters with their products
Fundamentals United, Inc.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 12 2020 6:41am

Hi Zombiess,

The Buck and boost converters are already implemented and work perfectly. Easy enough. I've got 12V stable on the gate drive regardless of if it's powered by USB or from the 5V stepped down from the HV rail. The chip is about 35c and the associated inductors and capacitors are probably another 50c.

I'm absolutely planning on doing FOC. BLDC with Hall sensors is already running, not well but running, the needed improvements relate to phase angle correction for the hall sensors - the Hall sensors on both my motors are not quite in phase so towards the end of each step the current ramps up quickly.

I also already have pwm-cycle-by-cycle current readings, on all 3 phases.

To fix this, I really need angle estimation, which I can get from timer triggers on the XORed Hall sensors. It's non trivial but totally doable.

Once I have rotor angle estimation, I can feed that into the Clark and Park transforms. It's again not trivial, I'm sure the implementation will be finnickety but the math and concept really isn't very complicated. I'll be implementing it from scratch, not copying from elsewhere. I'll under no illusion this is hard.

At the moment I'm running with a 10 ohm resistor in the power line, which should save me from flying MOSFET. When it comes to power testing time, I'll probably put a lid on top of it. I've got my eye on a clear cooking bowl in my kitchen.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 20 2020 11:27am

Update:
https://www.youtube.com/watch?v=T7VMXkmtVWw

I ran the ESC with ST's Motor Control Workbench FOC software and algorithm, just to get my ebike going while there's still sun this summer. I still don't have any way to sink kW of mechanical power on the bench, so it's going straight onto the EBike and I'll ride it up a hill as soon as my battery pack is secured nicely.

From this I have determined that it works pretty well, for a first go certainly. There are no big clangers.

Switching overshoot/ringing is about 12V, before I have installed the snubbers, 400ns dead time seems fine, current traces remain pretty clean...

Does definitely need more capacitors though, there are a few V (3 ish) drop on the power line in sync with the PWM.

@zombiess... I read through your posts about wanting completely isolated power supplied and gate drives, but I couldn't find a really convincing explanation anywhere within the threads of why exactly this is the case. I found ST make a 48V module that handles 100amps continuous (many hours of use) 220A peaks, the STEVAL-CTM009V1 https://www.st.com/en/evaluation-tools/ ... 009v1.html that does not use isolated gate drives. They also use 6 paralelled FETs, by simply giving them individual gate resistors, which came up strongly as a do not do in the Cheap FOCer threads. I presume the ST motor control team are not jokers and know what they are doing.

Could you explain, for a simple (yet mathematically and physics capableable) person what you think differentiates whether they are needed or not? My gut feel is that it comes down to the loop size, ground return paths and flux linkages of your gate drive lines/power lines - especially important if you're trying to put your gate drivers and/or MCUs on different boards, or you are using separate gate drivers for the high and low sides.

Realised I never posted the Repo for this hardware - https://github.com/davidmolony/MESC_FOC_ESC

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Aug 26 2020 3:12pm

mxlemming wrote:
Aug 08 2020 6:26pm
2) What other inputs are desireable? (none is a great answer).
Had to laugh out loud when I saw this!
Great Project. Love the design choice to stay away from expensive DRVs and go with an generic chip like the STM32.

Stancecoke (german Hochsitzcola) wrote firmware which is FOC cacapble for lishui controller that use STM32 chips. From his thread you can see it's no easy task - the main difficulty beeing the limitation of the chips used by lishui to do all the floating calculations. Maybe yours is more powerful. You might want to look into it - I suspect most of it could be readily adapted to your device. Also I'd just contact the guy. He had the same objective as you, which is writing a FOC software from scratch. Should be an enriching conversation!

As of the "what do you want question", I think it's more about design choice than free wishes. I you use a Cycle Analyst to control your bike, all that is really required from the motor controller is doing its job to switch cleanly between the phases and have a throttle input somewhere which is used by the CA to control the controller :)

Now that's a $130 piece of hardware we're talking about, so if you want to stay true to your given goal of affordability, you might want to dig into displays and sensors (torque, pas) connectors (analog and digital), and some algorithm to modulate power output based on those input. The open source firmware and the lishui firmware have some basic support of common chinese devices, like kt displays and erider torque sensors but there is definitely a lot of work to do.

Personnaly my only wish would be esc specs up to 75V and 40A. Not planning on riding a motorcycle, but a simple 1000W dd hub can draw an impressive amount of power when starting. 75V is a safety buffer for regen as I've seen spikes of 67V when braking.

Here is a good place to read about common motor connectors: https://www.ebikes.ca/learn/connectors.html
Best I know is L1910
Last edited by qwerkus on Aug 26 2020 3:15pm, edited 1 time in total.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 26 2020 4:56pm

Cheers for that feedback. The stancecoke code gets my attention... The entire FOC and observer is like 1 page! There is no fluff. Love it. Barely believe it can work it's so short. Might reach out to the guy, can't borrow his code directly since it's gplv3 licensed which for various reasons I'm avoiding (my work are terrified of it so I'm cautious as a result).

The other software project that is really impressive is the ODrive, which uses the same Ortega observer (so does the VESC) but the odrive code is way less scrambley.

I'm not using quite the same micro as stancecoke... I'm using the f303 which is the same price, but 72mhz and has onboard opamps and critically the cortex m4 floating point unit. And close coupled RAM if it comes to a real squeeze. It's also supported by st motor control workbench which is... Hmmm... :?

I already rode the bike around the road outside my house last night, running the ST FOC algorithm. Something was very not right... Lots of bangs that I thought was belt slip but actually turned out to be software just going nuts, what felt like about 500W not 5kW and a hot hot motor. Suspect it's getting the Hall sensors or dq currents in a kerfuffle.

Despite a hot motor, implying high currents (80mm diameter alien power systems 8072, 50kV) the controller was basically cold.

I'm going cheap as hell and open source on the controller lever as well. I've made a PCB with an stm32f030k6, an sh1106 screen and two analog Hall sensors to read the throttle and brake lever. It then converts to 50hz 1500us centered pwm. The whole lot is printable on a200$ 3d printer and the pcb BoM including board and screen from jlc is well below 10$. I'll post pics later once my baby goes to bed... It has a UART so i can get battery readings and rudimentary data from the controller.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 26 2020 5:51pm

https://www.youtube.com/watch?v=h6R5qGUonHM
Took it for a quick ride.

https://photos.app.goo.gl/svcSPMS3ow2tczEi7
There is is mounted to my bike.

https://photos.app.goo.gl/fS6LTs4WWcH33pow5
There's the lever I made.

Might do an actual PCB BoM cost estimation. I'm guessing 25$ not including heatsink. How far off will I be.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 26 2020 6:00pm

qwerkus wrote:
Aug 26 2020 3:12pm

Personnaly my only wish would be esc specs up to 75V and 40A. Not planning on riding a motorcycle, but a simple 1000W dd hub can draw an impressive amount of power when starting. 75V is a safety buffer for regen as I've seen spikes of 67V when braking.
This will easily handle that once I'm done unphucking the firmware.

Might need a seperate 5V rail though, the DCDC I'm using is only 65V (absolute maximum 70V apparently https://www.ti.com/lit/ds/symlink/lmr36510.pdf) ready. I chose it because... I had a load of free samples left after another project I did for work... but there is a 100V ready TI chip that's almost the same pinout. Maybe R2 can use that (https://www.ti.com/lit/ds/symlink/lm5018.pdf or https://www.ti.com/lit/ds/symlink/lm5163.pdf).

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Aug 27 2020 12:19am

mxlemming wrote:
Aug 26 2020 6:00pm
qwerkus wrote:
Aug 26 2020 3:12pm

Personnaly my only wish would be esc specs up to 75V and 40A. Not planning on riding a motorcycle, but a simple 1000W dd hub can draw an impressive amount of power when starting. 75V is a safety buffer for regen as I've seen spikes of 67V when braking.
This will easily handle that once I'm done unphucking the firmware.

Might need a seperate 5V rail though, the DCDC I'm using is only 65V (absolute maximum 70V apparently https://www.ti.com/lit/ds/symlink/lmr36510.pdf) ready. I chose it because... I had a load of free samples left after another project I did for work... but there is a 100V ready TI chip that's almost the same pinout. Maybe R2 can use that (https://www.ti.com/lit/ds/symlink/lm5018.pdf or https://www.ti.com/lit/ds/symlink/lm5163.pdf).
Excellent news! Any chance to get partially populated boards somewhere (europe) ? Last home brew reflow operation I tried ended up with quite poor results...

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 27 2020 7:46am

I'm afraid that to date I've been entirely hand soldering. Building up boards for other people isn't high on my list... However, there's a possibility of jlcpcb assembly next time round, because like you I'm not super keen on 5 hours of manual pick and place. Perhaps get resistors, capacitors, MCU, diodes... mounted leaving the gate drives, FETs (maybe jlc have some half decent FETs...) and DCDC chips to do.

This is alpha minus prelim stage development stuff bear in mind. I'll have to think about whether I can commit to actually finishing things to an acceptable standard, unless you're in for a ride of hope.

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Aug 27 2020 11:26am

mxlemming wrote:
Aug 27 2020 7:46am
I'm afraid that to date I've been entirely hand soldering. Building up boards for other people isn't high on my list... However, there's a possibility of jlcpcb assembly next time round, because like you I'm not super keen on 5 hours of manual pick and place. Perhaps get resistors, capacitors, MCU, diodes... mounted leaving the gate drives, FETs (maybe jlc have some half decent FETs...) and DCDC chips to do.
Yeah that's the idea. Not looking for a perfect board either here - more something to tinker around. Always wanted to experiment with FOC, but never had a non locked board cheap enough to serve as test subject.

Also, I have some big DD hubs here - should help putting that board under some actual stress...

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 27 2020 1:46pm

Where do you live? UK? You're welcome to one of the bare boards I have now if you're willing to solder it up.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 27 2020 5:34pm

Actually, looking at jlcpcb library, there's not a whole lot of use. No capacitors over 50V, no decent MOSFETs, all the useful parts are on extended... They have the f303 chip though.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 27 2020 7:25pm

Mouser BoM for 1 off is coming in as 46GBP, 60USD, not including the 0603 resistors because I can't be bothered with choosing penny resistors tonight, and assuming mainly wire to board, except Hall&USB, but using all the expensive bits and STH310N10F7-2 FETs, which are absolute monsters.

There are some crazy prices on there, victim of one offs I guess - MCU, DCDC chips, Gate drives, FETs all 2x the volume/JLC price.

In fact, if I put in 1000 of the BoMs into Mouser, the price is a much more reasonable 20.5GBP = 27USD each (but my budget does not stretch to 20kGBP orders) :lol:

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Aug 28 2020 4:54am

mxlemming wrote:
Aug 27 2020 7:25pm
Mouser BoM for 1 off is coming in as 46GBP, 60USD, not including the 0603 resistors because I can't be bothered with choosing penny resistors tonight, and assuming mainly wire to board, except Hall&USB, but using all the expensive bits and STH310N10F7-2 FETs, which are absolute monsters.

There are some crazy prices on there, victim of one offs I guess - MCU, DCDC chips, Gate drives, FETs all 2x the volume/JLC price.

In fact, if I put in 1000 of the BoMs into Mouser, the price is a much more reasonable 20.5GBP = 27USD each (but my budget does not stretch to 20kGBP orders) :lol:
Currently living in Switzerland. Digikey or Tme are usually cheaper here. Thanks for your offer, but I'd rather avoid soldering smt stuff again. No time and I'd need a proper reflow device, or at least a heatgun good enough for smt.
Now If jlcpcb can print the pcb and reflow all the tiny smt parts, it would be easy enough to add large parts like mosfets and capacitors. Those you can buy in bulk to reduce prices. Even 50 or 100 already get you decent discounts. Also, I'd keep an eye on ebay or similar platforms. Often enough electronics parts show up a ridiculous prices because of excess stock or bankrupcies.
Agreed: that fet look tough, though I'm not sure about an optimal cooling solution, since the tab is facing the pcb to serve as drain. Also I miss 3-4 small diameter bolt through holes in the corners to solidly bolt the board somwhere (like a battery box!). Not sure what the plan is with the 3 large middle holes.

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Aug 29 2020 7:58am

qwerkus wrote:
Aug 28 2020 4:54am
Now If jlcpcb can print the pcb and reflow all the tiny smt parts, it would be easy enough to add large parts like mosfets and capacitors. Those you can buy in bulk to reduce prices. Even 50 or 100 already get you decent discounts. Also, I'd keep an eye on ebay or similar platforms. Often enough electronics parts show up a ridiculous prices because of excess stock or bankrupcies.
Agreed: that fet look tough, though I'm not sure about an optimal cooling solution, since the tab is facing the pcb to serve as drain. Also I miss 3-4 small diameter bolt through holes in the corners to solidly bolt the board somwhere (like a battery box!). Not sure what the plan is with the 3 large middle holes.
https://photos.app.goo.gl/fKqqHk4JGH6SRnUi9

This should explain the 3 holes. And the cooling. I have doubled the number of thermal vias for the next PCB revision. Heatsink is some random one that work buys hundreds of, removes from a device, throws away and replaces with another... Plan on using https://www.ebay.co.uk/itm/Transistor-I ... %7Ciid%3A1 in future.

Re. the connector suggestions from Qwuerkus and Pronghorn, I'm moving over to JST PH on halls and PWM in, with an XT60 power in this weekend. Hoping for a full BoM including resistors as well, maybe order a new set of PCBs in a week or so.

I'll aim for JLC doing the SMT small stuff next time. I bought a big pile of FETs and gate drivers when RS were doing them at £1.50 each, so have enough for 2 or 3 controllers. I have a few types I'm trying out left over from various other projects, bought on RS special offer, etc... See which work best. Noticing that it's not all about Rdson already, the smaller ones often switch faster so you can get shorter min duty cycles.

Hoping for a big commit, push, merge on the firmware this weekend (3 day weekend in the UK) to have sensored BLDC with torque control basically working... It's working fine with my little motor in forwards mode, just need to get backwards mode and check it's not doing anything terrible with the big motor. The foundations are all there for FoC already - current&voltage measurements verified and being dumped in a 3x3 vector of uint16s, with a cycle by cycle interrupt, so it really is ready to start FOCing about with.

zombiess   1 GW

1 GW
Posts: 3009
Joined: Feb 01 2011 2:16am
Location: Ventura

Re: New ground-up ESC - MESC_FOC_ESC

Post by zombiess » Aug 30 2020 2:14am

mxlemming wrote:
Aug 20 2020 11:27am
@zombiess... I read through your posts about wanting completely isolated power supplied and gate drives, but I couldn't find a really convincing explanation anywhere within the threads of why exactly this is the case. I found ST make a 48V module that handles 100amps continuous (many hours of use) 220A peaks, the STEVAL-CTM009V1 https://www.st.com/en/evaluation-tools/ ... 009v1.html that does not use isolated gate drives. They also use 6 paralelled FETs, by simply giving them individual gate resistors, which came up strongly as a do not do in the Cheap FOCer threads. I presume the ST motor control team are not jokers and know what they are doing.

Could you explain, for a simple (yet mathematically and physics capableable) person what you think differentiates whether they are needed or not? My gut feel is that it comes down to the loop size, ground return paths and flux linkages of your gate drive lines/power lines - especially important if you're trying to put your gate drivers and/or MCUs on different boards, or you are using separate gate drivers for the high and low sides.

Isolation is for safety and for noise management. Flipping hundreds of amps back and forth in a few hundred nanoseconds can produce quite a bit of noise and bounce around the ground reference.

I learned a design method which results in a high performance, fault tolerant, functional + reliable power stage and gate drive every time. These are all features I want in my own designs. I've recently designed a low cost BOM version which should open up some manufacturing possibilities. I've lost more than one China quality controller on an ebike due to shorted phase wires. One test I do on my own controllers is to purposely (and sometimes not purposely) create shoot through to verify gate drive shutdown and fault detection function, haven't killed a MOSFET yet.

When paralleling you typically want a main gate resistor and individual gate resistors which are around 1/10th of the main gate resistor value. I don't remember the justification for the 1/10th and can't find it in my notes, but their purpose is to dampen oscillations on the gate drive trace. I've paralleled up to 11 TO-247s in my own research and experimented with these resistor values when pulsing +1000A through the array. I have noticed that higher individual resistors (say 2 ohm vs 0.5 ohm with a 7.5 ohm main) after a main gate resistor make a significant difference in reducing noise. This is stuff you usually figure out on the bench while tuning the drive.

Congrats on getting up and running!
Fundamentals United, Inc.

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Sep 01 2020 12:41pm

mxlemming wrote:
Aug 29 2020 7:58am
This should explain the 3 holes. And the cooling. I have doubled the number of thermal vias for the next PCB revision. Heatsink is some random one that work buys hundreds of, removes from a device, throws away and replaces with another... Plan on using https://www.ebay.co.uk/itm/Transistor-I ... %7Ciid%3A1 in future.
I like the simplicity of the clamp idea: with only 2-3 bolts, you basically hold the entire board AND ensure a good contact between heatsink and board.
No so convinced by the thermal design though. The Fet will heat up the entire pcb (plus all components) before reaching the heatsink. Sure, if it works well and the fet stay cool, you can cool the entire pcb that way, but if they run hot, wouldn't it drastically shorten the lifespan of all smaller components ?

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Sep 01 2020 5:32pm

https://photos.app.goo.gl/Cd8WfZsxCr76z8ET6

It's been a weekend of ups and downs. Rode my ebike with my bldc code on the board... But a math error in converting ADC readings to currents resulted in toasted MOSFET. And a toasted nickel battery strip :shock:

https://photos.app.goo.gl/4ZVwPe7T9QAPi4hs6

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Sep 01 2020 5:58pm

qwerkus wrote:
Sep 01 2020 12:41pm
I like the simplicity of the clamp idea: with only 2-3 bolts, you basically hold the entire board AND ensure a good contact between heatsink and board.
No so convinced by the thermal design though. The Fet will heat up the entire pcb (plus all components) before reaching the heatsink. Sure, if it works well and the fet stay cool, you can cool the entire pcb that way, but if they run hot, wouldn't it drastically shorten the lifespan of all smaller components ?
I see your thoughts, but counter that on 90+% of VESCs and other ESCs, there are SMT MOSFETs mounted in a similar way. For instance, the VESC 75-300 you can see it's a similar situation, but only has conduction through the top of the FET (which is far less conductive than the bottom). The other side has resistors and other widgets that prohibit heatsink attachment.
https://www.youtube.com/watch?v=fbK2dcoYS7g&t=94s

With my recent math cockup above, it seems that this thermal arrangement was sufficient to mean that the failure mode was the leg of the MOSFET fusing rather than actual FET overheating.I got about 100m down the road before the big white sparks appeared.

BTW, the math error was:
Converting the ADC reading to current=((float)ADCraw-(float)zerocurrentmidpoint)xgain factor = signed float current.

I got the gain factor wrong by about 3, which meant that the max current read was ~30A when the ADC was actually saturated at 100A+.

This might not have been a problem, except I had implemented a current control PID loop, which had a max request current of 80A... resulting in a 50A PID current error with a current reading maxed at 30A... resulting in a large duty cycle that can never be addressed.

Gentle application of the throttle allowed it to sustain life for a few hundred metres until I got enthusiastic... I guess the overcurrent comparators never tripped because the current was not a shoot through/other "catastrophic" event... so probably less than the 200A threshold.

I guess that's what happens when someone who's new to coding tries to implement a power electronics algorithm from scratch in their spare evenings :lol:

mxlemming   100 W

100 W
Posts: 157
Joined: Jul 17 2020 7:56am

Re: New ground-up ESC - MESC_FOC_ESC

Post by mxlemming » Sep 04 2020 5:25am

Fixed the PCB, up and running again with sensible, correct pid loop values.

As promised, over the weekend I updated the PCB design to remove a few niggles, change the connectors for jst ph series, add the SWO line, remove the 0402 resistors... Best of all, it should now work with lm5163 so the whole board is 100V ready (hopefully 20s compatible considering voltage spikes). I've also populated a BoM with all the jlc little bits (resistors, small caps, diodes, mcu...)

The software is updated on github as well. It's still basic, but compiles and spins a bldc motor in 6 step with current control and has the currents and voltages ready to mess with FOC. Written in stm32 cube IDE for windows so piece of cake for everyday numpties to compile and run.

So... Qwerkus, you still interested in a PCB? I need to build up 3 new ones soon (my bike, friends bikes) so I'll be ordering a small batch of partially smt'd ones from jlc in the next week.

qwerkus   10 kW

10 kW
Posts: 599
Joined: Jul 22 2017 4:00am

Re: New ground-up ESC - MESC_FOC_ESC

Post by qwerkus » Sep 04 2020 5:47am

mxlemming wrote:
Sep 04 2020 5:25am
Fixed the PCB, up and running again with sensible, correct pid loop values.

As promised, over the weekend I updated the PCB design to remove a few niggles, change the connectors for jst ph series, add the SWO line, remove the 0402 resistors... Best of all, it should now work with lm5163 so the whole board is 100V ready (hopefully 20s compatible considering voltage spikes). I've also populated a BoM with all the jlc little bits (resistors, small caps, diodes, mcu...)

The software is updated on github as well. It's still basic, but compiles and spins a bldc motor in 6 step with current control and has the currents and voltages ready to mess with FOC. Written in stm32 cube IDE for windows so piece of cake for everyday numpties to compile and run.

So... Qwerkus, you still interested in a PCB? I need to build up 3 new ones soon (my bike, friends bikes) so I'll be ordering a small batch of partially smt'd ones from jlc in the next week.
Sure - put me in for 2pc. you can contact me directly: qwerkus at gmail com

district9prawn   1 kW

1 kW
Posts: 324
Joined: Jul 20 2013 10:46pm
Location: Sydney

Re: New ground-up ESC - MESC_FOC_ESC

Post by district9prawn » Sep 10 2020 4:51am

Hey congrats on getting a motor spinning from scratch! Your project seems like a great way for people to learn motor about motor control. Arguably easier to get into than the available dev kits made for that very purpose.
Neu 8057 6kW left hand drive hardtail with 18 fet Vesc: viewtopic.php?f=6&t=96754

Post Reply