Sunday, October 16, 2016

Electric Boat using a SEVCON espAC motor controller

It all started with a donation by Sevcon.  They gave some people at MIT some motor controllers, but they were difficult to turn on, and don't work with very many motors, so the controllers eventually trickled down to MITERS.  The controllers are 80V controllers, though they will drive motors from 44 to 116V. It is one of the most robust motor controllers I've ever seen - the battery inputs are protected against reverse battery connection, and the phase outputs are protected from phase to phase shorts at any time and phase to battery shorts at power on.  They're current limited to 600 amps for 1 minute, meaning you can get 48 kW at 80 volts, or 66 kW at 110 volts.  While this is a lot of power, it's at a relatively low 80 V.   Most motors (like the common hybrid car motors) like to be run at 400 V or so.  It's much more efficient to run at a higher voltage, and generally cars have enough cells and boost converter to get to a high voltage.  This might be why Sevcon had a few extra controllers. The controller also has 8 digital inputs, 12V and 5V rails, 2 analog inputs, 2 isolated potentiometer inputs (to avoid voltage drop from massive amps messing with your throttle), and 6 voltage controllable contactor outputs that can provide 6A peak, 3A continuous.  The whole case is rated for 2kV isolation, and is IP66 rated, meaning it's very water resistant.  It's been tested to 50 g shock, and 3 g vibration, 5 to 500 Hz.  I'm not familiar with any of their drop or EMC testing standards, but I'm assuming this controller is quite good.  It's designed for fork lifts, airport ground support vehicles/tow tractors, golf carts, scooters, and 'marine'.

There are a few drawbacks:
1). The controller is physically large.  It weighs 25 lbs and is 1 ft wide.
2). It is difficult to turn on.  More on this later.
3). There's no great way to interface with it - there's really only an analog input that has lots of filter and is difficult to adjust, so there's no way to update the torque setpoint very quickly.
4).  It requires a lot of things to be plugged in for the controller to work.
5).  It only can drive induction motors, no brushless permanent magnet motors
6). The controller needs to be tuned to each motor used with it, which is a difficult and involved process
7). It takes forever to set up.  Peter, Bayley, Dane, and I worked on this terrible thing for a whole week from 7 pm to 3 am each night to get it to an acceptable state.
8). The software has lots of weird bugs.  This is probably because ours says 'engineering prototype: do not operate' on the label.

Dane took apart one of the controllers to see what was inside:

The heatsink is a nice aluminum extrusion that's connected to the board with all the FETs.  There are a TON of FETs in this device, each with their own BJT gate drive.  The FETs are relatively high resistance (19 mohms I believe).

The logic board on this controller is equally impressive/bizarre:


Bayley, who enjoys searching the internet for interesting motors from cars, found the first car part for this project: a nice 'eAssist' induction motor from a Buick LaCrosse for around $100 that was roughly sized to work on this controller.  It claimed to be a 15kW motor, but it can do much more for a short period of time.  It's also nicely sealed and comes with a resolver and is water cooled.

We started by building a test load for the motor: a supercharger from a Buick ????.  

In the end, we were able to put around 10 kW into the supercharger.

Dane ordered a collection of connectors and pins to plug into the Sevcon.  Over the course of roughly a week, Peter, Dane, Bayley, and I managed to trick the controller into spinning the induction motor.

Debugging the controller was a massively annoying process that included:
  • Reading and writing x86 assembly
  • Programming a nucleo to scale down a high resolution encoder
  • Cross compiling code for STM32's on linux because mbed compiler website was down
  • Fiddling with linux usb interrupts
  • Hooking up a large water cooling loop from the MITERS sink to the electronics bench
  • and many other strange activities
We don't fully understand everything there is to understand about these controllers, but the some of the knowledge we gained in the process might be useful to others.  This next section is formatted more as a list of helpful information.  The debugging process is too boring to blog fully. 

POWERING ON THE CONTROLLER
The startup sequences is initialized by providing low current fused (5A I think) power to the logic board.  If it decides to enter the 'operational state', it will precharge the bus capacitors then turn on a contactor to provide power to the DC bus.  The controller will try to enter 'operational state' unless it was manually transitioned to 'preoperational (preop)' before being turned off.  If there is an error, the controller will go into preop automatically, but it will still attempt to go into operational the next time it is turned on.  Going into operational state when the controller is not properly configured can dump a huge amount of current into the motor without the motor spinning or applied throttle, so be prepared!  We used an 80V 25A power supply, which often current limited and browned out the controller during testing.  It doesn't take long for 2 kW to heat up even a large motor, so external cooling is recommended during testing.

It's very important that you don't use a 'smart' contactor that goes and lowers the coil voltage once powered on.  The sevcon contactor driver will go into an overcurrent state and prevent the controller from entering operational mode.  We also encountered a strange issue where our 80V power supply wasn't quite isolated properly and floated a few volts above ground, causing random overcurrent faults on the contactor.  Properly grounding the controller fixed this issue.  The sevcon also has adjustable settings for contactor voltage, as well as the ability to lower the contactor voltage after a few seconds if you don't want to burn out your contactor coils.
3 switches, contactor, and enable switch
You also need to provide an additional three switches - forward, seat switch, and throttle switch, to get the controller to drive the motor.  The I/O section of the configuration tool must be used to map these switches.

We also encountered strange behavior where we were able to read an analog channel, but the throttle position in 'driveline' wouldn't update.  I currently don't remember what the fix was, but I hope to update this section once I have a chance.

The sevcon connects to the computer through an IXAAT USB to CAN adapter and is programmed with DVT.  The DVT installer can be found on the internet if you look hard enough (it's a little tricky - the download link appears in an image of a PDF document) and can also be acquired from SEVCON customer support if you ask nicely.  Their engineering department is super awesome and gave us software called MOTOR-WIZARD, which installs firmware on a device to allow it to characterize a motor and generate configuration data for the specific motor.  Unfortunately, MOTOR-WIZARD goes and flashes some new firmware onto your motor controller that replaces the default firmware. We didn't have a copy of the original firmware for our controller, so installing MOTOR-WIZARD permanently turns the controller into a motor characterization device.  If you only have one controller, this will be a problem - you can't use a MOTOR-WIZARD flashed controller as a normal controller.  It might be that sevcon engineering will give out firmware to restore your controller, but you should definitely check before you flash your controller with DRIVE-WIZARD firmware. If you are interested in getting the configuration file we created with drive wizard or have questions,  leave a comment with your email address and I will send it to you.

 DVT comes in many different flavors - there's a generic customer version DVTC, several versions customized for specific customers with specific device support and customized window titles, and DVT engineering, which has the most settings.  It doesn't look like license codes are different between software versions, but your license code is tied to a single computer.  License codes can be obtained from sevcon technical support for a single computer in some cases, but are only valid for lower 'customer' access level.  The CAN packets are built/decoded in a single dll that also implements their licensing and 'access level' code, which can be fiddled with to make work if you are desperate, but it's much more pleasant dealing with helpful sevcon engineers than x86 assembly...    Even if you manage to "validate" your license (either with a license key or with some clever fiddling),  the license reading code in the dll needs to do additional checking to determine your access level.  Again, some amount of clever "fiddling" can adjust your access level to let you modify certain "advanced" settings, but again, dealing with Sevcon engineers is better than trying to outsmart the software.  The highest possible license is 5, which is the SEVCON engineering level.  This lets you change every setting of the controller, including ones that are stored in device configuration files (.dcf's) that might go and blow up your controller if they are incorrect.  We found that having access level 5 gives you very few new settings - I believe we only changed a level 5 setting once, which turned out to be not needed.

Unfortunately, the DVT GUI doesn't expose all the settings necessary to program the controller to work with a motor.  .dcf's are stored as plain text and contain lots of useful settings, though you will need to decode the hex values and scale by the appropriate amount and deal with endless 'param dyn range' errors.  This error means that you have entered some value in the .dcf that doesn't make sense or is out of range.  I highly recommend changing one setting at a time, power cycling, and checking for param dyn range errors to avoid having to remember the last 20 changes you made trying to figure out how you broke the incredibly fragile configuraiton data.  DRIVE-WIZARD will spit out a .tcl script that can be loaded with "File->Source" to go and change the settings to work with the motor.  This is the best way that we found to configure the Sevcon.

The workbench
We also needed to provide encoder position feedback to the controller.  It needs to be a quadrature signal that's not too fast.
Peter's soda can/hot glue coupling worked great!

Unfortunately, this encoder was high resolution and generated quadrature signals in the 100's of kHz range, which was too fast for the slow TI brand DSP on the Sevcon logic board.  Using some of the encoder code created by Ben, we tricked an STM32 nucleo board into becoming an encoder divider.  My implementation of the encoder-divider is available here: LINK

The nucleo's 3.3V outputs weren't enough to drive the Sevcon inputs, so we added some transistors

The board is taped to the table so it doesn't fall off.
Amazingly, all this nonsense worked, and the motor spun up.  Here it's spinning at around 2000 rpm, out of a maximum of around 8000.
At full speed it sounds like this: 


which is absolutely terrifying.  We had to hook up water cooling from the sink to keep the motor at a comfortable temperature. 

The next stage of the project was completed extremely quickly and with few pictures taken, so documentation is brief.  The "outboard" uses an alternator belt from a Kia that runs in the water to drive the propeller.  This actually worked, but only with extreme tension on the belt.  Dane performed a small miracle, and somehow determined the spline on the propeller was the same as the spline on a Fiat 500 steering wheel, so we used steering parts from a Fiat as the propeller shaft.  Rob Reeve created a beautiful copper coil for the cooling loop, which was driven by the amazing brushless Toyota Prius water pump.  

Peter and I mounted the sevcon and created some more legitimate wiring:


Sevcon in boat

Box of Switches
battery
Motor on boat
4 of these packs should be enough...
Loaded boat

The boat worked moderately well.  Unfortunately, our pulley ratio was off by a factor of two.  Our motor could only spin at a very low speed, in a range where it can give us only around 9 kW, instead of the 30 we designed for.  The boat did not plane, which also might have been because it was a small aluminum fishing boat, not a speedboat.   We were unable to increase the motor velocity because the controller was operating at the 600 amp phase current limit.  At this low speed, we were only at around 20% DC bus utilization, but we could not safely put any more volts across our motor.  The mechanical disadvantage from the incorrect pulley ratio would have caused the phase current to exceed the limit.   At full speed we could only put 9.6 kW into the motor, which was enough to get to 8 mph.

See a video of the boat in action here:
https://vimeo.com/182904726
questionable underwater alternator belt.


Sunday, September 11, 2016

PMTH Build Reports

PMTH began some time early in December, when Alex and I decided we should try to build a battlebot.  We didn't really know what we were doing, and the project turned out to be mostly a failure, but it was a great introduction to battlebots.  We began with some ideas and material.
Ideas


Material
At first, we were planning on building some sort of automatic flywheel powered flipper, but we would later scrap the idea due to complexity and lack of space/time.  We used many parts from Alex's class project, which was supposed to be a speaker, but actually was a battlebot drivetrain in disguise.

Almost all of the material shown came from the Stata loading dock.  On December 8th, I found some sort of giant old industrial motor controller with some large heatsinks.  As far as I can tell, they were machined from solid 6061 aluminum.
Controller board on floor of Stata dock
Cabinet with microwave

After lots of CAD, we decided we'd have more fun if we designed the robot as we made it, so we threw our designs in the trash and got to work making parts. 

On January 21st, we went to MITERS to begin construction of the robot. We clamped the heatsink to the table of the Bridgeport, and removed the fins.
Heatsink on mill table
Heatsink with some fins removed
The next day, we made some motor mounts.  They have little slots milled in them to fit around the plastic gearbox housing.  We also made shafts from the really awesome 1/2" 7075 Hex shaft from Vex Pro.
The shaft is in the background.
After that, we made bearing blocks for the wheels that weren't driven by the motors.  I started by making a rectangle
Shiny!
then bored a hole for two bearings.
There are two bearings in there.

I goofed and didn't get a good press fit, so I added some bearing retaining screws.

Two bearing blocks on MITERS bench
The next step was to cut up the heatsink plate and put holes in it.
Victor Mill with lamp and aluminum plate
We ordered sprockets from Vex Pro, which were received by a man(?) named MICHEEEL

The plates also needed to be modified to let the chuck of the drill fit.

Cutting Fluid removes Sharpie, so this was a bad idea.
Suddenly, it began to look like a robot.
I should have used a flycutter.

Our next challenge was to create the weapon drive.  We looked in the large bearing drawer at MITERS and found some gross looking bearings that seemed suitable.  At first, we couldn't even get the bearings to turn, but we were able to get them rolling after a bath in acetone.


Questionable Bearings.
Finding a suitable shell was difficult too.  All the woks were flimsy, so we went with a really small cast iron skillet.  Unfortunately, it is very small, so getting everything to fit will be a real challenge.
Robot Soup.
We also encountered an extremely unusual left-hand end mill.


WHY?
To drive the weapon, we are using an NTM Prop Drive 50-60 380KV motor with a bored out skateboard wheel.
The motor is rated for 2600 watts
At first, we didn't support the shaft, but we later created a little block that held everybody's favorite 8mm ID 22mm OD skateboard bearing.

Another questionable bearing.
To make an axle for the weapon, we used a 304 stainless steel pressure vessel we found at the loading dock.  304 is not one of the free machining stainless steels, and part temperature quickly became an issue on the MITERS lathe.
We needed to remove almost 2 lbs of material.
The chips were beautiful shades of blue, gold, and purple.
I finished the axle on one of the lathes in the FSAE shop that has flood coolant and a more powerful spindle. They currently use only one type of insert, which is terrible for stainless, so I dug through the collection of damaged/used up inserts and found something good for stainless. Running flood coolant, I could get around .100" off the diameter in each pass.  This was the limit for this lathe - any more and the servo drives would give errors.
Shiny!
I put a 3.25" diameter bolt circle in the skillet by clamping it to the table of the Bridgeport.
This wasn't the first time somebody has machined a pot at MITERS.

Cast iron is cool.
We needed a way to attach bearings to the pan, so I made a set of bearing blocks.  Looking back, these are probably the two best parts made in this project, and I'll likely find some better use for them in the future.  The first operation was to bring the stock to size
I used the flycutter this time...


I started to create the bearing bore using the boring head on the mill, but this was too slow, so I switched to the lathe.
I gave up.

Dialing in the part was a massive pain.
Shown without bearings or bolts


On the final night before leaving, everything was very rushed.  We added an idler wheel for the shell,



With delrin wheel
added some holes in the plate for mounting the weapon shaft,
Add caption
made a pocket in the bottom of the weapon shaft (I don't remember why the larger pocket is there, but the bigger one is to hold the nut from turning),
Shown from the inside of the weapon shell

chamfered the inner bearing block and removed the square part to avoid interference


it was still scarily close!
and finally put the whole frame together!

We tested it: 
and brought it to Motorama, where we tested it again: 

Unfortunately, PMTH was a terrible failure of a battlebot, losing both of its matches at Motorama.  The drive system was absolutely terrible and the center of gravity was too high, making the robot difficult to control.  It would also destabilize and dip into the ground, causing it to tip over and roll around.  The 'shell' was made of cast iron, which cracked and chipped with every impact.  Currently, I don't plan to build another robot for the next Motorama, but there's always the chance that Alex and I will be inspired for the next Motorama and we'll build another.

Saturday, February 13, 2016

Reactor Chamber Machining

My friend builds nuclear reactors, and didn't want to spend a small fortune at MIT's Central Machine Shop getting parts modified, so I offered to help him out.  You can read more about his crazy projects on his blog.  I started this project with access to none of MIT's machine shops, so I could only work at MITERS, the only shop on campus that's open to absolutely anybody. All the other shops required safety training, or thought the parts were too complicated. 
The reactor chamber is made from a 304 stainless 6" diamter hollow hemisphere with .125" thick walls.  My job was to put 5 holes, each 1.500" in diameter, in the hemisphere.   The end product should look like this:
I didn't have access to a boring head or a chuck large enough to hold the sphere, so I had to get clever with a rotary table.  The first step was to align the axis of rotation of the rotary table with the center of the rectangular stock. To make it easier, I put a collet block with the same thickness as my stock in the vise and dialed that in.  The vise didn't quite fit on the rotary table, so one bolt (not shown) goes through a slot in the middle of the vise with a bunch of washers.


Once the block was in the right spot, I used an indicator in the spindle to set my zero on the DRO as the center of the collet block.  
The fixture I made has a circular edge that rests on the inside of the hemisphere and a tapped 1/2-13 (same as typical Bridgeport hold down) hole for bolting the hemisphere down.  This single bolt attachment was a little sketchy, but I never had any trouble with the part moving.

I first tried to put a hole in the center of the hemisphere with one of the MITERS center drills.  Unfortunately it was very dull and caused work hardening even with a lot of force – I was worried I would break the tip of the center drill if I pushed harder.  In the end, I used a 3/8” 3 flute carbide end mill with a small corner radius in the lathe tailstock, but a sharp center drill would work too.
Next, I bolted the hemisphere to the fixture and set it up in the vise with a 45 degree angle block.  Indicating the sphere was frustrating because the hemisphere was not perfectly spherical.  When rotating around any diameter of a sphere, the indicator should not move, but I was seeing .01” maximum deviation near the edges.  I also didn’t see the typical high/low pattern that normally appears with a spherical/cylindrical part being turned eccentrically, meaning the sphere must have some weird distortion.  The hemisphere appears to be formed, so this isn’t too surprising.  I found it useful to put a 1/2" diameter steel rod in the drill chuck and line up the sphere so that the plane of the bottom of the rod is tangent with the sphere to get an approximate location of the sphere before using the indicator.

-Notice the bolt holding down the vise!
The hemisphere is a terrible shape for ringing and chatter, so I had to go quite slow.  I found that at a certain feed rate the part would make a pleasant ringing noise similar to a tuning fork.  I was using one of my end mills – MITERS had nothing that could cut stainless.  I used a ½” carbide six flute coated end mill.  I was taking .05” to .10” wide passes at 1100 rpm and around 3 ipm or so.  The chips created were sharp and got stuck in my hands, which was very annoying.  The finish left behind was quite good.

Once I had one hole done, I walked in to the Edgerton Student Shop, which has nice equipment, and asked if I could continue machining the part there. After showing the instructor there that I was able to make one of the holes, they were much more willing to let me work there. The guy there did not like my fixture, so he suggested that I use a very small end mill to reduce cutting forces.  I used a 3/16” 3 flute carbide end mill to make a .01” undersize hole first using a CNC ez-trak Bridgeport.  It was one of the fancy 3 axis ones that had a canned helix cycle, so I set it up to continuously ramp down as it cut the circle.  I used a .04” deep cut at 6 IPM.  It was completely happy slotting at this depth, but sometimes chattered before the cutter was fully engaged.  As I did more holes I cheated it down so the cutter would be fully engaged sooner.  I got a great surface finish with a .005” wide finish pass at full depth and 8 IPM.