Skip to content
Snippets Groups Projects
Select Git revision
  • master default
1 result

README.md

Blame
  • Machine Kit BLDC Driver

    Background, Motivation

    This project is largely a follow-on to my Teensy-Powered Brushless Motor Controller, and with this new work, may the TESC project RIP. A moment of silence.

    TESC, April 2016 - August 2016
    As the world turns,
    so did those motors,
    once around is never enough

    Eulagies aside, I am still motivated to do this. Brushless motors are the go-to motive force for electromechanical systems. By that I mean that just about any time you see a robot-like thing, or machine, moving about, there's a big likelihood that the thing doing-the-moving has a brushless motor in it's guts - or some variant thereof (stepper motors count as BLDCs in my books).

    A few things to understand:

    (1) Electric Motors move by rotating a magnetic field - we have something with magnets, and something else with electromagnets, we use the electromagnets to rotate the field, we pull the magnets along. Rotating the field is called Commutating or Commutation.

    (2) Brushed Motors rotate the magnetic field using 'brushes' - these are mechanical switches that use the motor's own rotation to change the magnetic field. Super neat. Here's a link to Sparkfun's explanation

    And a GIF. While the rotor rotates, different switches are connected to current, and the coils - to - pads relationship is set up such that the current will cause the motor to rotate. Pardon my abbreviated explanation.

    ![brushed-dc]((https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/brushed-dc.gif)

    Brushes are awesome - and make motors very simple. You just pump voltage (so current) through the rotor, and things happen. However, there are resistive losses at the brushes, as well as friction losses.

    With the advent of transistor technology (for switching logic AND for switching big power) we can do this electronically - use a computer (or simple timer) to switch the phases.

    (3) Brushless Motors rotate the magnetic field with switches - so we can make the coils stationary, and 'artificially' switch the direction and timing of current flowing through them. Here's a nice GIF of sinusoidal commutation (where phase currents follow a nice, smooth wave).

    ![bldc-animation]((https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/bldc-motor-vectors.gif)

    We can see the three current vectors (that translate into a combined magnetic field vector). We also have a simpler type of switching, where we only turn two of the three phases on at a time. You can see an example of that here - including a nice diagram of the switch setup.

    Where it gets complicated:

    • Circuit design to switch big voltages / currents
    • Closed loop control on current in motor
    • Sensing: rotor position, electrical phase, offsets, shunt amplifiers oh my!

    Towards accessible robotics

    Mostly the motivation for me to go through this is (1) to train myself in the field, and (2) to help others along a similar journey, not just cobbling bits together, but understanding how and why they work. Also, providing better tools / kits / examples to others who are putting robotic systems together.

    Circuit Design

    This page is incomplete - I'm going to violently segue into a roughly train-of-though design process now.

    FET Selection

    Using 2x20 pin header on ATSAMS70 Switch -

    I want to use these fancy DirectFets because I know they can handle really big currents in astoundingly small packages - aiming at a 2kW spindle here. The PN1 I found is IRF6648TRPBF, switches 60v at 86a - this is rated by the silicon2, so won't really get that close, but it's a big number nonetheless - and even at ~ 40% of that I'm running near 2KW (also, power is switched with 6 - so load is a bit split up, though the picture is not so simple - i.e. during moments of the phase only one is 'full on' on the top - or bottom - side of the phases.)

    I also found an eagle library for this package, nice.

    These are apparently a pain to solder - you need reflow. I'm OK with that, as I think reflow ovens are not hard to build... I know it makes it a little bit un-fabbable, but it makes me stoked about this project. So here we are.

    Now - an aside, to introduce you to Ben Katz a researcher at MIT's Biomimetic Robotics Lab, who is an expert in motor control, and keeps this great blog about it. Also, this is Benjamin Vedder3 - who's project is hugely popular in the Electric Longboard community. Niche. Great software, great board design.

    Layout

    I start by laying out the Three Half-Bridges that drive the Motor. The FET I am using actually has multiple pins per connection - so I pulled those out on the symbol to make it clearer what I needed to connect. Here's my schematic for the gates:

    gates schematic

    A few notes - I'm using Labels instead of directly 'routing' on the schematic. This helps keep things diagrammatic... And not messy. You'll notice my Shunt symbols have separate legs for sensing - you'll get that when you see the layout. I also pull out a pin from the low-side of the gates that the gate-driver uses to sense the voltage there (actually not ~ exactly ground). I also have a few voltage dividers setup on phases, which is useful when doing closed-loop sensorless BLDC or FOC control. Not something I imagine I'll have time to implement in code, but good to have.

    Now I try a first-shot at the gate layout on the board, to get a sense for generally where things will end up.

    gates single layout

    This is really just to figure out what the topology is - what wraps around what. When I really route the big juice, I'll be drawing big polygons that I can do copper pours in. I like this particular layout because I have a 'side' for each big current pull - my shunt is happy with a big tail to some groundplane I'll lay down over there, the phase (in between the FETS) gets a nice edge to face-out to where I'll put motor lines (and that pesky voltage divider), and I have another happy, big edge to dump VCC on. I can even sneak the gate-drives in without any vias, nice.

    Next I'm going to draw the DRV8302 Schematic and Footprint. Oy.

    drv device

    TI Provides an excellent example layout - I'm using this as a reference as I draw the circuit.

    drv reference

    I got the DRV8302 all schematic'd out, and put a rough plan in place on the board. This looks a bit complicated .... That's because this DRV8302 packs a lot of circuit into one die. I'm actually not sure if it is only one die... You can see this all here:

    drv blocks

    Here's my schematic block for just the DRV

    drv schematic

    There's gate drivers - that's the real business that we're after - this comes with a swath of external capacitors. Critically, BST_x and CP1, CP2 connected capacitors are Charge Pump caps - these are what the DRV uses to crank voltage into the high-side gates - very important that these find a good home really close to the DRV.

    GVDD and DVDD are still a bit of a mystery to me - internal voltages in the DRV that want external bypass capacitors.

    There's also the current sense amplifiers - the bottom chunk of the chip. These amps TODO: explain current sensing and they get a tiny filter on the inputs, a reference voltage.

    On the 'top' of the chip is a buck voltage regulator, a world into itself. The buck gets a whole whack of support - a BST_BK capacitor, a whole bunch of R_Sense circuitry, etc.

    And then there are a few fault outputs (that I connect to LEDS for super-simple debugging, but should properly trigger interrupts on a microcontroller), some settings-related pins, etc. It's a lot, and with more time I would write my process for this up in detail. Wrestling with this chip taught me a lot about EE.

    OK. Next, I'm going to try to reconcile the pin-inputs I need for this driver with the pin-outputs I've developed for Machine Kit. Briefly, I know I'm going to need 6 PWM Pins (3 phases x hi/lo) and 5 ADC pins - two for current sensing TODO: explain kirchoff's summing, and 3 for phase voltage measurement. Actually 6, because I want to measure the input voltage as well. So I already know I need (want) another ADC pin on the MK Header. This is a lot of analog (er, PWM-ish) circuitry! I'm glad I have this test case in developing the MK Switch. Turns out I am maxed on the analog pins available on the ATSAMS70. So I have to jettison measuring source voltage, which is OK when we are not running on batteries - but kind of a bummer to have that hardware limitation. Could open one phase to high and measure then, I think, but wouldn't be able to do it continuously during operation. That's fine.

    I'm also going to add a header / plug for 'other things' - I'll use the SPI pins, that I think I can set as GPIO as well - I want to be able to talk to SPI devices (sensors, etc) and / or ABI input encoders. Wow. I am biting off a lot.

    Also - I want to push 48v into this chip (I am planning on most machines running at 48V, the power supplies are readily available, and 48v is the right amount for a KW spindle - says reasons?). This means I have to push a bunch of big capacitors onto the chip - 10uF at 100v (next step up) is a 2220 package - big !

    OK - I finally got my schematic dialed down where I wanted it, and footprints worked out. I'm going to start routing.

    Routing

    routing begins

    I have one ground plane (bottom trace) and three voltage planes on the top - a VCC (motor voltage, will be nominally 48v), a +5V (the output from the buck regulator, also - turns out I need this on some SPI / encoder devices, nice bonus) and a +3V3 - that's my logic level - the DRV uses 5v logic, but, all good.

    I got started routing the inputs to the DRV, working over to the drive side. Once there, I focused on making the FETS and Caps etc... power side... work well. I'm also keeping an eye on my ground plane - a big problem with two-sided routing is that you can 'pinch' the plane out in some cases. This was a big issue when I routed that 100-pin switch, here it seems a bit easier - there's less going on overall - the scale is a bit different.

    routing halfway

    I got this routed, and I'm feeling good about the board. I turned on only the layers that will actually show up in fab - so the solder mask, traces, holes, etc - really I want to take some time now to make a decent silkscreen - this can make component placing much easier!

    routing presilk

    For adding silk, I tried to go about doing it by adding silk to the components - not just drawing them on the board.

    OK, actually I want to keep the silk really clean. Things should be beautiful.

    I sent these out, and sent an order to digikey for parts. Now some waiting. Here's a list of notes, as they occur, for next time.

    Incremental Notes

    • 2.2uF @ 100v -> 1206 smallest available package. Can replace with 1uF or up package.

    Footnotes

    1. Part Number. Searching Digikey (or octopart, or what have you) for bits is an art, kind of. It's intimidating, but offers much gold at the end of the rainbow.
    2. This means that this is where the FET breaks down at the transistor level. The real constraint has more to do with heat - there is some resistive loss in any transistor (spec'd as RDS_on) - that resistance turns into heat, and if at 86A that can be a lot of heat, and if you aren't able to get it out of the package fast enough it will break down due to high temperature. THIS is why the directFET package is cool - rather than being wrapped in plastic (not conductive) it is wrapped in a metal tin (conductive) so it's easier to really suck the waste energy out of it.
    3. Both are Ben. Both control BLDC. A coincidence? Consider that.