Corn-Troller: Tassel

Look­ing around at the hop­pin’ elec­tric vehi­cle scene hap­pen­ing at cer­tain insti­tu­tions, I real­ized that pret­ty soon I’d be play­ing catch-up to more than just Jamo when it comes stuff-strut­ting unless I start­ed build­ing some­thing ridicu­lous, and quick­ly too.

So in typ­i­cal son-of-an-accoun­tant behav­ior, instead of build­ing my own scooter, I decid­ed to go the man­ic whacky sneaky route and build some­thing to sell to the scooter builders. So now I’m announc­ing the corni­est, trol­liest brush­less motor con­troller of them all: Corn­troller.

Corn­troller is a result of me com­plete­ly rip­ping off Shane Colton and Dan Strother to build an extreme­ly fea­ture-bloat­ed brush­less motor con­troller. All of the fol­low­ing will be devot­ed to dri­ving just a sin­gle motor:

  • Mod­u­lar corn-inspired design, stack­ing a log­ic board (called Tas­sel) onto a pow­er board (called Hex­Husk)
  • 10V–45V oper­a­tion with two switch­ing reg­u­la­tors for log­ic pow­er (LT3991-5, LT3970-3.3)
  • At least 40A of cur­rent capac­i­ty through IXYS GWM160-0055X1 3-phase MOSFET pow­er mod­ules
  • Way too much pro­cess­ing pow­er from a 100-pin STM32F103VG, one of the top parts in the STM32 F1 series of ARM Cor­tex M3 micro­con­trollers
  • Full volt­age and cur­rent sens­ing on every­thing (motor phas­es and pow­er bus), so I can imple­ment vec­tor con­trol or sen­sor­less­ness
  • Com­pact three-phase N-chan­nel FET dri­ving through ded­i­cat­ed gate dri­ver IC (A4935)
  • Motor hall sen­sor inputs to micro­con­troller cap­ture timer
  • microSD card slot inter­faced through SDIO (not MMC over SPI) for dat­a­log­ging
  • Full speed USB inter­face… just because
  • Two 7-seg­ment LED dis­plays… also just because
  • Full 9-degrees-of-mea­sure IMU (accelerom­e­ter, gyro­scope, mag­ne­tome­ter) with the some of the best dumb1 MEMS sen­sors (BMA180, IMU3000, HMC5883L) avail­able… just $@#%ing because

I’m only half-jok­ing about that last one; I designed Tas­sel, the log­ic board on Corn­troller, as a replace­ment for my (yet to be writ­ten up) Maizure Cor­tex M3/MEMS sen­sors board. Maizure has served as my gen­er­al dev board, and its suc­ces­sor is so full fea­tured and has such overspec’d com­po­nents because of that. But, I can choose to not pop­u­late com­po­nents for unused fea­tures. So when Tas­sel is used as a part of Corn­troller, it will not have its 3-axis MEMS sen­sor foot­prints pop­u­lat­ed2).

By the way, I start­ed nam­ing my projects after corn. Just—you guessed it—because.

Tas­sel was laid out with only sur­face mount com­po­nents (pre­fer­ring 06033 chip resis­tors and capac­i­tors), all on the top side. Lay­out was actu­al­ly fair­ly straight­for­ward, since a lot of the work required just rout­ing direct­ly from STM32 pins to head­ers (which I could reas­sign any­ways).

The hard part was fig­ur­ing out which periph­er­als I could route out of the STM32. The orig­i­nal plan was to use a 48-pin device; this grew to 64-pin and then 100-pin as I real­ized that all the “good” periph­er­als I want­ed in the STM32 were actu­al­ly shar­ing the same pins.

For exam­ple, USART1 and TIM1 (with its use­ful three-phase com­ple­ment­ed PWM with soft­ware dead­time inser­tion) shared the same pins. I had to spend a solid week assign­ing pins to their func­tion­al­i­ties, restart­ing all over each time I had to up the pin count and move to a big­ger device. Through all of this I also had to make sure to fan every­thing out prop­er­ly so wires route clean­ly from µC pin to head­ers and devices.

That’s real­ly how I end­ed up with 7-seg­ment dis­plays; switch­ing to 100 pins meant I had a lot of I/O pins left over that I didn’t want to go to waste. With the dec­i­mal point, each King­bright 0.2″ dis­play fills up 8 pins: per­fect for half a GPIO port, and thus nice to con­trol in soft­ware.

Plus, 7-seg­ment dis­plays and resis­tor arrays are way eas­ier to sol­der than indi­vid­u­al 0805 LEDs and 0603 resis­tors.

So I end­ed up with a long list of nets to route well before even start­ing a schemat­ic in EAGLE (see appen­dix)!

Since Maizure had a bit of prob­lems with noise and sta­bil­i­ty, I made Tas­sel a four-lay­er design. This means extra lay­ers of cop­per on which to route sig­nals, but more impor­tant­ly to serve as ground planes for sur­face sig­nals. This isn’t nec­es­sar­i­ly need­ed, but it cer­tain­ly lends me extra noise immu­ni­ty I fig­ure I’d want on such a dense­ly rout­ed board.

A four-lay­er design meant I had way few­er choic­es in PCB fab­ri­ca­tion: I went with Dork­bot Portland’s group PCB order, but also con­sid­ered 4PCB’s/Advanced Circuits’s $66 each ser­vice and BatchPCB’s 4-lay­er group order. For me, Dork­bot­PDX just turned out to be the best bang for the buck.

Why do I just have pho­tos of unpop­u­lat­ed boards? Because (a) they’re pret­ty and (b) I sent the­se out before I fin­ished design­ing the pow­er stage, in an attempt to pipeline the pro­to­typ­ing process. I want­ed to send the­se out, com­plete Hex­Husk, order parts for both from Digi-Key, and have the com­po­nents before Tassel’s boards arrived. That didn’t hap­pen… the Digi-Key order is just now in the mail. Guess I failed at pipelin­ing.

Design files for every­thing and a Hex­Husk post are com­ing. I promise.

Appen­dix
Par­tial pin assign­ments:

Outputs
=======
# Q1
15 PC0 V_P
16 PC1 V_A
17 PC2 V_B
18 PC3 V_C
23 PA0 I_A
24 PA1 I_B
25 PA2 I_P

# Q2
26 PA3 AN_0
29 PA4 SPI1_NSS
30 PA5 SPI1_SCK
31 PA6 SPI1_MISO
32 PA7 SPI1_MOSI
- V+
- V-

- 3.3V
39 PE8 PWM1~ # remap
40 PE9 PWM1 # remap
41 PE10 PWM2~ # remap
42 PE11 PWM2 # remap
43 PE12 PWM3~ # remap
44 PE13 PWM3 # remap

# Q3
68 PA9 USART1_TX
69 PA10 USART1_RX
# Q4
86 PD5 H1 # 5V
87 PD6 H2 # 5V
88 PD7 H3 # 5V
92 PB6 I2C1_SCL
93 PB7 I2C1_SDA

JTAG
====
- 3.3V
PB4 JTRST
PA15 JTDI
PA13 JTMS
PA14 JTCK
PB3 JTDO
NRST RESET
- V-

USB
===
PA11 USB_D-
PA12 USB_D+
- V+
- V-

SDIO
====
PC8 SDIO_D0
PC9 SDIO_D1
PC10 SDIO_D2
PC11 SDIO_D3
PC12 SDIO_CK
PD2 SDIO_CMD

MEMS
====
PB10 I2C2_SCL
PB11 I2C2_SDA
PB12 SPI2_NSS
PB13 SPI2_SCK
PB14 SPI2_MISO
PB15 SPI2_MOSI
  1. Read: non-intel­li­gent, where “intel­li­gent” is a tech­ni­cal term []
  2. Or may­be it will… what elec­tric vehi­cle could use an IMU? ; []
  3. That’s 63 mils by 31 mils or 0.063″×0.031″ []