Commit ef6e62ac authored by Jake Read's avatar Jake Read

structure, first good test

parent f6679490
# MachineKit BLDC Driver
See: [Circuit Development](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/tree/master/circuit), and [Code Development](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/tree/master/embedded)
## Background, Motivation
This project is largely a follow-on to [my Teensy-Powered Brushless Motor Controller](https://github.com/jakeread/tesc), 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](https://learn.sparkfun.com/tutorials/motors-and-selecting-the-right-one/dc-brush-motors---the-classic)
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](https://www.youtube.com/watch?v=oFI7VW6WGR4) - 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. This is ongoing work!
\ No newline at end of file
# MachineKit BLDC Driver
# Machine Kit BLDC Driver: Circuit Development
## Background, Motivation
This project is largely a follow-on to [my Teensy-Powered Brushless Motor Controller](https://github.com/jakeread/tesc), 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](https://learn.sparkfun.com/tutorials/motors-and-selecting-the-right-one/dc-brush-motors---the-classic)
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](https://www.youtube.com/watch?v=oFI7VW6WGR4) - 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.
Warning! Train-of-though documentation!
#### FET Selection
......@@ -151,6 +108,46 @@ And completed - looks nice!
![fab smd complete](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/fab-smd-complete.jpg)
## Testing
Here's my setup:
![test getdown](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/test-stand.jpg)
And I'm using a 24V Supply - I designed & rated this to 83V (capacitors are largely 100v, 83v rating comes from the DRV8302 and the FETS). But I want to stay safe and steer clear of burnouts for now.
I carefully checked all of my pinouts and double-checked that I was sending a PWM signal that I liked, then I turned it on! I had some success, and then a stall. I *thought* I saw some smoke, so not sure what's up.
I also noticed the power lines to the ATSAM chip started to flash - so I am having a power supply issue to my brain-board. This whole situation is more complicated than it needs to be. The DRV has a 5V Buck regulator, and uses that 5V Signal on a few pins... so I can't just throw it out. The ATSAM board has a 5V line, that it passes through a regulator to get the 3v3 it needs.
I imagine the 5V Buck Regulator on the DRV8302 is unhappy - it's actually a fairly complex thing, using some feedback loops to control a PWM cycle, that then is filtered with an LC on the output to generate a smooth 5V. I imagine this is going unstable.
What I did to diagnose the whole thing was connect my logic analyzer to the 5V line, 3V3 line, and to my three phases. Note - not *directly* to my three phases, as they will be being driven to 24v, and I'm quite sure I would fry my logic analyzer. I already have voltage dividers setup for the microcontroller to read the phase voltages, so here I'm just reading off of those. Nice.
![test getdown](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/test-buck-unbuck.jpg)
The first three are my gate voltages - they're being driven very nicely, thanks very much. The bottom two lines are my 5V (Channel 3) and 3V3 lines (Channel 4). So, this is dropping, the pwms are becoming very sad, and this oscillation starts.
It looks like I can remedy this by just supplying also 3V3 with my UART Cable - although I know I'll be introducing basically conflicting 3V3 lines, which is bad. We'll give it a go.
OK, great success! First thing's first, my motor turns:
![test first turns](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/test-first-turns.gif)
This is good news. Better news, I can read all of my phase voltages, and it looks like I'm getting satisfactory reading on my current sensing circuitry as well.
The traces here are: (0) Phase U Voltage, (1) Phase V Voltage, (2) Phase W Voltage, (3) 5V Line, (4) 3V3 Line, (5) Phase V Current, and (6) Phase W Current.
Here we see happy PWM cycles above, and what looks like a chopped sinusiod (of current) below.
![test getdown](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/test-all-sensing-one.jpg)
Zoom in:
![test getdown](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/raw/master/images/test-all-sensing-two.jpg)
I sped this up some and it looks more like a chopped sinusoid - this means I should either dial down the sense amplification (I think the two options are gains of 10 and 40), or put smaller shunts on - right now I have 0.005 Ohm shunts (I wanted a more sensitive measurement for smaller currents).
## Incremental Notes
- 2.2uF @ 100v -> 1206 smallest available package. Can replace with 1uF or up package.
- Would via to heat-pad underneath fets, next time. could also go to 2oz copper but have to push out to 0.2mm spacing.
......
......@@ -140,10 +140,6 @@ Here we go, a sinusoidal PWM:
I think I'm ready to check all of my other motor controller IO's - like, do I need to assert, also, an enable pin? I forget. Then I'll plug it in, and flip the switch, ho-ha! Yep - I just have on extra PIO to add, an Enable Pin. Set this up.
I also took a minute to make this test stand, wire up all of the high power lines etc...
- img
## UART
OK, I'm going to bring up the UART. I have a block of code for this from my networks project that I'll try bringing in.
......@@ -191,6 +187,6 @@ Note - the handler does not distinguish between an RXReady event and the other i
Some ARM Documentation is [here](http://infocenter.arm.com/help/index.jsp) - navigate to Cortex-M7 Documentation, the latest revision, and look for NVIC.
## Hardware, Awaken!
From here, I brought up the hardware - a satisfying adventure. Go [here](https://gitlab.cba.mit.edu/jakeread/mkbldcdriver/tree/master/circuit) for that.
OK, this is satisfactory, for now, for register banging. I'm going to try bringing the hardware up now, i.e. turning the motor on.
\ No newline at end of file
Then I worked (briefly) on implementing a control interface for this using mods. That should be [here](http://fab.cba.mit.edu/classes/863.17/CBA/people/jakeread/) in week 12.
\ No newline at end of file
......@@ -135,7 +135,7 @@
:100850007F43C7F8283259F825309B01A8FB0323B2
:10086000DB09043323F07F43C7F8483259F82630B8
:100870009B01A8FB0323DB09043323F07F43C7F864
:1008800068324FF2CE10194B98470D48184B9847D5
:10088000683241F2F820194B98470D48184B9847A9
:100890000028C3D00A48174B9847C2E7C10340005D
:1008A0002D02400050180E40EB0140007D06400034
:1008B0006906400070144020000E0E40F301400015
......
......@@ -19,21 +19,21 @@ Idx Name Size VMA LMA File off Algn
CONTENTS, READONLY
7 .debug_info 00009e32 00000000 00000000 000214c3 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_abbrev 00001541 00000000 00000000 0002b2f5 2**0
8 .debug_abbrev 00001532 00000000 00000000 0002b2f5 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_loc 00001263 00000000 00000000 0002c836 2**0
9 .debug_loc 00001263 00000000 00000000 0002c827 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_aranges 00000430 00000000 00000000 0002da99 2**0
10 .debug_aranges 00000430 00000000 00000000 0002da8a 2**0
CONTENTS, READONLY, DEBUGGING
11 .debug_ranges 00000390 00000000 00000000 0002dec9 2**0
11 .debug_ranges 00000390 00000000 00000000 0002deba 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_macro 00017323 00000000 00000000 0002e259 2**0
12 .debug_macro 00017323 00000000 00000000 0002e24a 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_line 0000656d 00000000 00000000 0004557c 2**0
13 .debug_line 0000656d 00000000 00000000 0004556d 2**0
CONTENTS, READONLY, DEBUGGING
14 .debug_str 0006cca6 00000000 00000000 0004bae9 2**0
14 .debug_str 0006cca6 00000000 00000000 0004bada 2**0
CONTENTS, READONLY, DEBUGGING
15 .debug_frame 00000964 00000000 00000000 000b8790 2**2
15 .debug_frame 00000964 00000000 00000000 000b8780 2**2
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
......@@ -1366,7 +1366,7 @@ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
40087a: f023 437f bic.w r3, r3, #4278190080 ; 0xff000000
40087e: f8c7 3268 str.w r3, [r7, #616] ; 0x268
delay_us(period * 10);
400882: f24f 10ce movw r0, #61902 ; 0xf1ce
400882: f241 20f8 movw r0, #4856 ; 0x12f8
400886: 4b19 ldr r3, [pc, #100] ; (4008ec <main+0x1b4>)
400888: 4798 blx r3
if(pin_get_state(&stlr)){ // ?
......
......@@ -3573,7 +3573,7 @@ OUTPUT(atsams70-bldc.elf elf32-littlearm)
.debug_info 0x000072eb 0x55b src/ASF/sam/utils/cmsis/sams70/source/templates/system_sams70.o
.debug_info 0x00007846 0x25ec src/main.o
.debug_abbrev 0x00000000 0x1541
.debug_abbrev 0x00000000 0x1532
.debug_abbrev 0x00000000 0x12d src/tinyport.o
.debug_abbrev 0x0000012d 0x230 src/ASF/sam/drivers/wdt/wdt.o
.debug_abbrev 0x0000035d 0x232 src/pin.o
......@@ -3583,7 +3583,7 @@ OUTPUT(atsams70-bldc.elf elf32-littlearm)
.debug_abbrev 0x00000dca 0x1a4 src/ASF/common/boards/user_board/init.o
.debug_abbrev 0x00000f6e 0x153 src/ASF/sam/utils/cmsis/sams70/source/templates/gcc/startup_sams70.o
.debug_abbrev 0x000010c1 0x102 src/ASF/sam/utils/cmsis/sams70/source/templates/system_sams70.o
.debug_abbrev 0x000011c3 0x37e src/main.o
.debug_abbrev 0x000011c3 0x36f src/main.o
.debug_loc 0x00000000 0x1263
.debug_loc 0x00000000 0xca src/tinyport.o
......
......@@ -135,7 +135,7 @@ S21440084059F824309B01A8FB0323DB09043323F02B
S2144008507F43C7F8283259F825309B01A8FB03236D
S214400860DB09043323F07F43C7F8483259F8263073
S2144008709B01A8FB0323DB09043323F07F43C7F81F
S21440088068324FF2CE10194B98470D48184B984790
S214400880683241F2F820194B98470D48184B984764
S2144008900028C3D00A48174B9847C2E7C103400018
S2144008A02D02400050180E40EB0140007D064000EF
S2144008B06906400070144020000E0E40F3014000D0
......
......@@ -181,7 +181,7 @@ int main (void)
startupflash();
uint8_t scalar = 64; // 0 -> 255 (these will be chars from serial)
uint8_t period = 255; // us between ++ in phase
uint8_t period = 20; // us between ++ in phase
uint32_t phaseu = 0; // 0 -> 1023
uint32_t phasev = 341; // advanced 120 degrees
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment