## Friday, September 8, 2017

### MTPA, MTPF, and Speed Range, Part 2

Previously on Motor Diddlers, we learned that interior PM motors spend most of their time under field weakening; namely, the maximum attainable torque is limited by inductance and available voltage, not necessarily by maximum allowable current. This post will cover the basic case of computing the MPTF trajectory in the absence of saturation and higher-order back EMF components.

Starting from the motor equations $$\begin{array}{lcl} \tau=\frac{3}{2}n_p(\lambda I_q+(L_d-L_q)I_d I_q)\\ V_d=R_s I_d-\omega L_q I_q\\ V_q=R_s I_q+\omega L_d I_d+\omega\lambda\\ V_s=\sqrt{V_d^2+V_q^2}\\ I_s=\sqrt{I_d^2+I_q^2} \end{array}$$ we note that in the voltage limited operating regime, maximum torque must be achieved when the voltage vector is on the boundary of the allowable area, in which case the optimization problem becomes an equality: $$\begin{cases} \frac{3}{2}n_p(\lambda I_q+(L_d-L_q)I_d I_q) = \tau_0\\ (R_s I_d-\omega L_q I_q)^2 + (R_s I_q+\omega L_d I_d+\omega\lambda)^2 = V_0^2 \end{cases}$$ If we ignore saturation, this system is the intersection of a constant-torque hyperbola (which is independent of speed) and a series of shrinking ellipses.

This system is polynomial (and in fact only a quartic) and can be solved in many ways. For example, one element of the reduced Groebner basis of the ideal generated by the two equations is the very long $$(L_d-L_q)^2(R_s^2+L_q^2w^2)I_q^4 + (L_q^2\lambda^2\omega^2+R_s^2\lambda^2+(L_d-L_q)^2(2R_s\tau_0\omega-V_0^2))I_q^2- 2\lambda\tau_0(R_s^2+L_d L_q\omega^2)+ R_s^2\tau_0^2+L_d^2\tau_0^2\omega^2$$ where we have included the factor of $$3/2n_p$$ in $$\tau_0$$ for brevity's sake. The roots of this polynomial are easily found with a variety of numeric or analytic methods; in the case of multiple real solutions the correct one is the $$(I_d,I_q)$$ vector with the shortest length.
Unfortunately, the system is no longer polynomial if the motor saturates (that is, $$L_d$$ and $$L_q$$ are functions $$l_d(I_d,I_q)$$, $$l_q(I_d,I_q)$$ of the axis currents). In order to solve the system in this case, we will have to turn to more complicated (and less reliable) numeric methods, the nature of which will be the subject of the next post in this series.

## Sunday, September 3, 2017

### Focusing on the Ground

Suppose we have a view camera and we wish to focus on a horizontal plane. More precisely, let the center of the lens $$O$$ be $$a$$ above the ground, and suppose the rear standard makes an angle $$\theta$$ with respect to the horizontal. We wish to find the angle $$\alpha$$ that the front standard must be tilted at to focus on the ground.

By the Scheimpflug rule. the rear standard, front standard, and horizontal intersect at a point $$S$$. By the hinge rule, the front focal plane, the horizontal, and the plane through $$O$$ parallel to the rear standard are concurrent; this is true if and only if the intersection point $$H$$ of the horizontal and the plane parallel to the rear standard lies at a distance $$f$$ from the front standard, where $$f$$ is the focal length of the lens.

We have:
\begin{array}{lcl}
O'S = a / \tan{\alpha}\\
O'H = a / \tan{\theta}\\
SH = O'S - O'H = a(1/\tan{\alpha} - 1/\tan{\theta}) = a \left( \frac{\cos{\alpha}}{\sin{\alpha}} - \frac{\cos{\theta}}{\sin{\theta}} \right)
\end{array}
This means:
\begin{array}{lcl}
f = SH\sin{\alpha} = a\sin{\alpha} \left( \frac{\cos{\alpha}}{\sin{\alpha}} - \frac{\cos{\theta}}{\sin{\theta}} \right)\\
\frac{f}{a} = \cos{\alpha}-\frac{\cos{\theta}}{\sin{\theta}}\sin{\alpha}\\
\frac{f}{a}\sin{\theta} = \cos{\alpha}\sin{\theta} - \sin{\alpha}\cos{\theta} = \sin{(\theta-\alpha)}\\
\theta-\alpha = \arcsin{(\frac{f}{a}\sin{\theta})}\\
\alpha = \theta-\arcsin{(\frac{f}{a}\sin{\theta})}
\end{array}
In other words, the angle between the front and rear standards is $$\arcsin{(\frac{f}{a}\sin{\theta})}$$. This is pretty neat; in particular, for small magifications we can say the ratio of  of the sines of the angles is approximately equal to the magnification of the camera.

## Tuesday, August 22, 2017

### Obligatory 2017 Eclipse GIF

Somehow this endeavor went better than planned, I was able to not only get to the site successfully and make it through traffic, but also get the tracking mount to track.

There was an "urp" moment when I fumbled and disconnected my A7II from the remote shutter app during totality, and another "urp" moment when I panicked and complete forgot about proper exposure times and such, but 1/80 turned out OK and the raw files have enough exposure latitude to do a bit of HDR if need be...

 A7II and Celestron C5 w/0.63x focal reducer (~750mm f/6.3), Spectrum glass filter, 1/80s ISO 100

## Sunday, August 13, 2017

### Super Plumbing

The cadet racing kart chassis we were working with had no front brakes. This was a problem, because our stopping power was already traction-limited at the rear wheels, and more time spent stopping meant less time accelerating.

Front brake conversion kits exist, but are rather expensive. Undaunted, we bought some generic moped calipers, proclaiming that "we'll figure out a way to mount them".

Ben came up with a pretty good way to mount them:

The stock direct spindle mount front wheels were replaced with a set of hub-mount rear wheels, and new hubs with 17mm bearings were made to mount them to the spindles. The arm that holds the caliper is centered using the precision-machined spindle shaft (which is the only precision surface in the kingpin assembly). Finally, a cross-piece is made which bolts to the arm and prevents it from rotating around the spindle.

Everything was made on the MITERS CNC (a mid-90's Dyna-Myte converted to LinuxCNC), and the mounts worked great.

The next step was to fill the brakes. Initial attempts were made to drive the two front calipers and the rear caliper (which had two pistons) using a single master cylinder:

 Nope

This proved to be exceedingly unsuccessful; not only did the master cylinder have borderline displacement to drive four pistons, getting the air out of the loop and matching the piston travels proved to be nearly impossible. A day and a half into the ordeal, standards were lowered, and we decided to run the front and rear brakes off separate master cylinders actuated by a single pedal.

A word on the hoses: moped calipers take banjo bolts (hollow bolts sealed with crush washers). We used Earl's Performance braided lines to turn these into -3AN flares:

These connect to a 1/8" NPT tee:

The third arm of the tee is fitted with an NPT-to-compression adapter, which then goes to the master cylinder. A very unconventional setup, as compression fittings are not typically rated to brake line pressures. Go-karts get away with it with a combination of low pressures (hundreds, instead of thousands, of PSI) and short maintenance cycles (typically a couple dozen hours of runtime per season).

## Wednesday, August 9, 2017

### MTPA, MTPF, and Speed Range, Part 1

I had mentioned in a previous post that IPM's are almost always running in the field weakened regime. That is to say, $$I_d$$ and $$I_q$$ are injected not to maximize torque per amp, but to achieve a certain torque setpoint without exceeding the maximum available stator voltage.

Recall that a sinusoidally-varying motor is modeled by:$$\begin{array}{lcl} \tau=\frac{3}{2}n_p(\lambda I_q+(L_d-L_q)I_d I_q)\\ V_d=R_s I_d-\omega L_q I_q\\ V_q=R_s I_q+\omega L_d I_d+\omega\lambda\\ V_s=\sqrt{V_d^2+V_q^2}\\ I_s=\sqrt{I_d^2+I_q^2} \end{array}$$ Suppose we have unlimited back EMF, and we wish to optimize torque per amp. There are two ways to look at this. Firstly, we could $$\mbox{minimize } \begin{cases} I_d^2+I_q^2\mbox{ subject to}\\ \lambda I_q+(L_d-L_q)I_d I_q=\tau_0 \end{cases}$$ Or, we could $$\mbox{maximize } \begin{cases} \lambda I_q+(L_d-L_q)I_d I_q\mbox{ subject to}\\ I_d^2+I_q^2=I_0^2 \end{cases}$$ As it turns out, the second current-first approach results in much easier math (we only need to solve a quadratic, not a quartic) at the expense of being somewhat less intuitive (it is unclear what current corresponds to what torque).

There are several ways to solve the second problem; we use Lagrange multipliers here. The Lagrangian is $$L(I_d,I_q,u)=\lambda I_q+(L_d-L_q)I_d I_q-u(I_d^2+I_q^2-I_0^2)$$ where $$u$$, not $$\lambda$$, is the multiplier.
The system of partial derivatives is $$\begin{cases} \frac{\partial L}{\partial I_d}=(L_d-L_q)I_q-2I_d u=0\\ \frac{\partial L}{\partial I_q}=(L_d-L_q)I_d-2I_q u+\lambda=0\\ \frac{\partial L}{\partial u}=I_0^2-I_d^2-I_q^2=0 \end{cases}$$ This system is easily solved by a computer algebra system or by multiplying the first equation by $$I_q$$ and the second by $$I_d$$, giving $$\begin{array}{lcl} I_d=\frac{-\lambda+\sqrt{\lambda^2+8(L_d-L_q)^2I_0^2}}{4(L_d-L_q)}\\ I_q=\sqrt{I_0^2-I_d^2} \end{array}$$ where we have picked the signs knowing that $$I_d$$ is negative and $$I_q$$ is positive.

Armed with this information we can make some plots. Plugging in the HSG data $$L_d=0.0006$$, $$L_q=0.0015$$. and $$\lambda=0.053$$ (units: Henries, Volt-seconds), we have the following plot:

As expected, $$I_d$$ is about the same magnitude as $$I_q$$ at high currents.

Perhaps more interestingly, we can get a sense of how quickly the back EMF grows in an IPM. Using the MTPA setpoints computed above, we can plot back EMF vs stator current and speed:

 Worth noting: the hump in the blue region is caused by d-axis current on the MTPA trajectory canceling rotor flux
Roughly speaking, the blue region corresponds to back EMF's achievable on a 150V bus. It is evident at high currents, most speeds in the operating range are unachievable:

A slice of the graph at 180A shows that we are forced to exit the MTPA regime at about 800 rad/s (about 2500RPM on a 3-pole-pair motor).

Even more telling is a plot of maximum achievable current versus speed:

Speeds much above 1500 rad/s are straight-up unattainable, and between 800 and 1500 rad/s, available current rapidly falls off.

We conclude that at high currents (and therefore high torques), the maximum achievable speed is highly limited (the HSG is rated to 9000 RPM at 150V). In order to achieve high speeds (and therefore high powers) we must move off the MTPA trajectory and onto a "maximum torque per flux" trajectory.

This is also why IPM voltage and current scaling cannot be treated naively! I cannot emphasize this enough - a motor rated to 50Nm and 10000RPM on a given bus voltage cannot physically achieve both at the same time. On the other hand, increasing the bus voltage not only increases the maximum achievable speed, it increases the amount of torque available at lower speeds.

The next post in this series will tackle the problem of computing the MTPF trajectory, which, as we will see, is much harder and cannot be solved analytically.

## Tuesday, August 8, 2017

### Plumbing Electrons

"Wiring is like plumbing, but for electrons"
-me, 2017

One of the things I've come to dread in any project is wiring. This particular wiring job is by no means stellar, but works well enough to be worth writing about.

Starting at the front:

The steering wheel controls consist of an e-stop and a key switch. The e-stop is wired in series with the +12V line going to the logic and by extension, the 12V supply for the internal gate drives on the power module. Hitting the e-stop shuts down the microcontroller and gate drive, which safely floats the inverter phases.
The key is wired in series with the 12V going to the contactor control line - contactor power does not go through the e-stop. As interrupting high DC link currents damages the contactor, this switch is intended to act as a last line of defense in case the inverter has failed short or otherwise stopped responding to gate drive. In normal fault situations (throttle failure, firmware error) the e-stop suffices.

From the steering wheel, two runs of McMaster 8082K37 shielded cable connect the switches to a power distribution board...

...which I swear is the only reason the go-kart thinks about working at all. The sketchy CNC'ed board replaces what would be an even sketchier mass of wire junctions.

The HV contactor is a Kilovac Csonka EV200:

The datasheet claims it is rated for dozens of interruptions at 500+A but I don't believe it. The precharge resistor is bolted directly across the contactor, which has the benefit of precharging the DC link capacitor whenever the HV connector is plugged in, and the downside of slowly draining the traction pack should the HV connector be left unplugged.

The motors are wired to the inverter via 10AWG silicone wire stuffed inside a copper braid finger-trap shield:

I am not convinced the shield is doing much (it isn't terminated on either end, and terminating it didn't seem to affect noise), but keeping the phase leads in as small of a bundle as possible is important for reducing radiated noise.The shield is sealed to the wire bundle with 3M EPS-300 adhesive backed heatshrink, which upon heating forms a tough, watertight seal glued to the shield and wires.

Moving back to the inverter:

The phase lead bundles are attached to the bus capacitor tabs by zip-ties. As much of the exposed bus bar as possible is covered in liquid electrical tape to reduce the chance of inverter-induced incidents.

The capacitor itself is mounted via standoffs and slotted tabs to the inverter block:

The image above also shows the power module control cable, which is cut short and terminated in a DB-15 connector, then run through a 20" commercial shielded DB-15 cable to the logic board:

The Phoenix Contact cable was irritatingly expensive (~$50 on eBay), but it was rather difficult to find good shielded 15-wire cable. Finally, the throttle is actuated through a bowden cable attached to the original go-kart throttle pedal (which operated a mechanical throttle on a carbureted engine). The throttle sensor is a GM brake position sensor: The bowden cable is crimped to a standard copper ring terminal; please don't do this for an actual brake! It is only acceptable here because a cable failure causes the throttle to return to an off-position. ### Sonata Pack Module Testing  I'd upload a 3-angle view if Blogger had a working gallery function Dane was kind enough to run some tests on an 8S submodule from the Hyundai Sonata pack using is datalogging-enabled Hyperion charger. This pack is quite aged, showing only 4Ah out of the 5.3 rated amp-hours. However, pack impedance is promising, hovering between 10 and 15mohm for most of the SOC - not bad at all for a 5.3Ah 8S pack. The module under test was also extremely well-balanced: As would be expected from an automotive vendor with access to millions of cells. The conclusion: you probably want an A-grade pack, but a B-grade pack is completely usable, albeit with degraded performance. ### Fun with Interior Permanent Magnet Motors We are all taught as wee seedlings that motors, brushed or brushless, are governed by the following equations: $$\begin{array}{lcl} \tau=K_t I\\ \omega=K_v V\\ K_t = 1/K_v \end{array}$$ To a very rough approximation, these equations are true, and for hobby motors they work quite well. RC vendors usually quote $$K_v$$ as the RPM per DC link voltage under trapezoidal commutation. The above equations model the motor as a speed-dependent voltage source. However, a motor has both inductance and resistance as well. Taking a moment to blatantly ignore the definitions of 'inductance' and 'resistance' (there are several, depending on your conventions), a more accurate voltage equation might be: $$V = \omega/K_v+IR+n_p \omega L$$ Note the intentional lack of subscripts on $$R$$ and $$L$$; this equation is meant to be heuristic and should not be used to actually compute back EMF. Saliency and Reluctance Torque The brushless motors we typically see on the mass market are "surface PM" machines. In this configuration, the permanent magnets (PM's) are glued to the surface of a steel rotor. Torque is generated by rotating the magnetic field in the stator electronically, which in effect continuously "pulls" the PM's on the rotor towards the coils on the stator. Surface PM motors have relatively low inductance. This may seem somewhat counterintuitive, but remember, the relative permeability of a PM is about 1, so the air gap in the stator magnetic circuit is very large (the thickness of the PM). Furthermore, because the rotor geometry is rotationally symmetric, even within a pole pair, the stator inductance of a surface PM motor is constant within an electrical cycle. Current mass-produced electric cars not made by Tesla all use "interior PM" motors (IPM's). In an IPM, the magnets are inset inside the steel rotor. This seems rather counterproductive at first - moving the PM's further into the rotor would slightly decrease the PM flux seen by the stator. However, because the depth of the back iron changes within an electrical cycle as the rotor turns, IPM's have a property called saliency; the minimum inductance ($$L_d$$) and maximum inductance ($$L_q$$) are different from each other, sometimes significantly. One typically assumes that inductance varies sinusoidally with electrical position between these two extremes (there's no reason why this should be true, but everything is sinusoidal if you look at it from far away enough!). Saliency is useful because it generates torque. To put it one way, the rotor field tries to attract the largest mass of steel. Looking at it another way, the varying inductance results in a position-varying amount of stored energy, and the system will try to settle into a state of lowest energy (torque is the angular-position derivative of the co-energy). The motor equations Taking into account inductance, resistance, and saliency, the complete equations describing a sinusoidally-varying motor with sinusoidal commutation are: $$\begin{array}{lcl} \tau=\frac{3}{2}n_p(\lambda I_q+(L_d-L_q)I_d I_q)\\ V_d=R_s I_d-\omega L_q I_q\\ V_q=R_s I_q+\omega L_d I_d+\omega\lambda\\ V_s=\sqrt{V_d^2+V_q^2} \end{array}$$ Some extremely important notation: $$R_s, L_d$$ and $$L_q$$ are the resistance and inductance of one phase, $$V_s$$ is the peak AC stator voltage across one phase (which for standard SVM is equal to half the DC link voltage), $$\lambda$$ is the PM flux linkage, and $$n_p$$ is the number of pole pairs. $$I_d$$ and $$I_q$$ are the usual FOC axis currents. These equations tell us many things: 1. The importance of $$I_d$$ On an IPM, torque is generated by both $$I_d$$ and $$I_q$$. On some IPM's, the reluctance component ($$(L_d-L_q)I_d I_q$$) is significant; e.g. for the Hyundai HSG we have $$\lambda=0.053$$, $$L_d=0.6 mH$$, and $$L_q=1.47 mH$$. For high currents, reluctance torque is a huge fraction of the resulting torque... ...as evidenced by this stall test plot, where phase is practically equal to $$3\pi/4$$ (the point of highest reluctance torque for a given stator current) at very high currents. This is because reluctance torque grows as the square of current, but PM torque grows only linearly. Yes, the inductances do saturate, but the flux linkage also decreases as current increases, and in the end, the order of magnitude faster growth in torque favors reluctance torque at high currents. 2. Field weakening exists... ...and the equations tell us precisely what to do. We have to be careful as to what we call "field weakening" here. For a surface PM machine it's easy - as $$I_d$$ generates no additional torque, any current applied to the d-axis exists solely to cancel out the PM flux: $$V_q=R_s I_q+\omega L_d I_d+\omega\lambda$$ so applying a negative $$I_d$$ reduces $$V_q$$. For an IPM the situation is trickier; under normal operation, even at zero speed, there is some current on the d-axis already. At stall, the optimum operating point for a given stator current $$I_s$$ is given by the $$(I_d,I_q)$$ that maximizes $$\lambda I_q+(L_d-L_q)I_d I_q$$ subject to $$I_d^2+I_q^2=I_s^2$$. However, the maximum-torque-per-amp operating point becomes unattainable at high speeds because of the high stator inductances, which serve to limit the achievable currents at high electrical frequencies. Field weakening on an IPM starts at the speeds for which we can no longer operate at the MTPA setpoint. In fact, for commonly available IPM's, field weakening is extremely important for running at reasonable bus voltages. A 300V motor rated for 10,000RPM can only achieve that with significant d-axis current; the "base speed" (above which there are insufficient volts to run at the MTPA operating point) could be as low as 3000RPM. 3. IPM's have a broader speed range than SPM's This is oft-quoted in papers and design articles, and the equations make it easy to see why. There are two ways to think about it: 1. Field weakening current (on the d-axis) generates useful torque on an IPM, but only generates heat on a SPM. Furthermore, SPM's are double screwed by the fact that they have a high flux linkage and low inductance, which results in huge $$I_d's$$ needed to cancel the PM flux. 2. On an IPM, torque grows as the square of current, but back EMF only grows linearly. This means that for a given required torque, the controller runs out of volts more slowly. Alas, saturation comes into play at high currents, so the speed range of most IPM's is not infinite. In fact, for most of their operating range, IPM's are constant power, not constant torque, devices:  Power curve of a simplified HSG model, disregarding saturation Note how the 8,000RPM HSG (at the simulated bus voltage of 160V) is able to reach peak power at 2000RPM, and levels off to high-speed powers not much below the peak achieved value. For traction applications, this has the obvious (and huge!) benefit of removing the need for a gearbox. 4. SPM's have better performance at a single operating point For a given stator current, an SPM produces constant torque and linearly increasing power up to base speed. Achievable torque falls off rapidly after base speed. However, for static loads, SPM's have the highest torque per unit volume, since they have the highest flux linkage and the smallest airgap. For such loads (turbines, propellers, fans), a surface magnet machine is the correct choice. The quest to maximize the flux linkage per unit volume (which, in turn, minimizes the stator resistance required to achieve a certain $$K_v$$) leads to designs like the Emrax and Yasa, both of which are double sided, axial-flux outrunners with split stators for the largest possible airgap per kg/liter of motor. This is crucial for airborne applications, where the weight penalty inflicted by a speed-reduction system is unacceptable. The Curse of Saturation Saturation is a terrible thing. It reduces your field-weakening capabilities and limits your reluctance torque, and is what fundamentally limits the instantaneous torque capabilities of any motor. In addition to reducing $$L_d-L_q$$, saturation also reduces flux linkage, so even surface PM motors are not immune to it. Saturation is what makes IPM's notoriously hard to model. On a surface PM machine, saturation doesn't affect the optimum operating point - up to base speed, saturation only reduces torque-per-amp, but doesn't change that fact that all the stator current should be on the q-axis. In the field weakening regime, saturation affects how much d-axis current is needed to generate a given torque at a given speed, but this inductance is not position dependent and is easily measured with a stall test. In contrast, on an IPM, where much of the torque is reluctance torque and most of the operating range involves some amount of field weakening, correctly characterizing saturation is extremely important. To further salt the wound, the entire concept of $$L_d$$ and $$L_q$$ becomes somewhat tenuous as the motor saturates, as even a motor carefully designed to have sinusoidal inductance variation ceases to be sinusoidal when saturated. The best way to tune a saturated IPM is probably to put it on a dyno (or simulate it, if it is your design). That being said, there will be a few posts here in the future on trying to model saturation. ## Monday, August 7, 2017 ### Go-Kart plumbing Plumbing is hard. That's probably why plumbers get paid more than some engineers, and why Mario can jump so far. Sadly the go-kart has both watercooling and hydraulic brakes (plus lots of wires, which are pretty much plumbing for electrons), so there was a lot more plumbing involved than I cared to deal with... The loop is built out of PC-style cooling components. Cold water exits the radiator, flows through the inverter block and then through the motors before returning to the reservoir and pump. The reservoir is a Swiftech MCRES Micro Its main purpose is to facilitate filling by acting as a source of water when the bubbles are pumped out. It doesn't actually store water for operation (evaporation rates are low), but without it, filling the loop is pretty much impossible. The pump is a Swiftech MCP350-style unit pulled from a watercooled PowerMac G5. We were able to coax this one into turning on by pulling three of the wires (the rightmost three in the picture above) to +12V and one to ground, but I think the G5 pinout has varied over the years. The radiator is a standard-thickness 240mm one, pulled from some unknown piece of lab equipment (but also easily purchasable from your favorite computer vendor). We were having trouble with the screw mounts shaking loose on the road (the radiator doesn't have real holes in it, just sheet metal). We replaced them with zip-ties, which have worked great since. The fans are Dell Precision T5400 hard drive fans. They are much higher flow than a standard 120mm fan, but not loud enough to be annoying. Cheap too, under$10 a piece shipped from various eBay vendors.

The radiator is mounted between the driver's legs (under the steering wheel) with the fans pulling air through it and exhausting towards the rear of the kart. This allows the motion of the kart to provide some cooling assistance. We had a choice of mounting the radiator, inverter, or battery there, and the radiator was by far the safest.

The waterblock was made from a 8x12x1/2" piece of aluminum on a manual milling machine. No design went into the channel; the O-ring groove depth was selected using this chart, and groove width was done with the nearest available end mill, which worked out pretty well (the O-ring is quite squishy, so the widths don't need to be exact).

The block was fitted with G-1/4" rotatable computer fittings. These seem to hold up to loop pressure alright, though screwing the BSPP thread into the NPT tapered thread proved quite the challenge (but doable). The rotary fittings made routing the tubing much easier.

The thicker tubing is PrimoChill PrimoFlex. This stuff is expensive, but boy oh boy, it's worth it - super supple and able to make sharp bends without kinking. With a little bit of heat-gunning it also stretches nicely over the HSG fittings.

Overall it is remarkable how much heat the little Swiftech pump and 240mm radiator can move. Or not - a single 240 is easily good for a 300W GPU and 150W CPU under continuous duty with dinky little low-noise fans; the Dell blowers and natural go-kart airflow should be good for a solid 1KW+, and while the peak dissipation of the go-kart is high (each motor, stalled, is 3KW), the average dissipation on short courses is low.

### New Go-Kart!

 The falloff at the corners is artistic, right?
Firstly, credit where credit is due. This project is a collaboration between myself, Ben Katz and Jared DiCarlo, with assorted contributions from Michael DeTienne, Nick Kirkby, and Fred Moore, and moral support from Austin Brown.

For the past year or so, a bunch of us at MITERS had been working on a new go-kart, built around a commercial racing kart chassis. The goal was to finally use hybrid car parts in a project which was stable enough to be fun to drive (the motorcycle was not very pleasant to ride, and the battlebot had rather serious technical issues).

It all started with this and this. ORNL had done some tests on the hybrid starter-generator ('HSG') from the Hyundai Sonata/Kia Optima hybrids. The Sonata uses a unique hybrid system amounting to what is essentially a Honda IMA combined with a GM BAS, the difference being Hyundai's IMA pancake motor is much larger (30KW) and is capable of powering the car for a few miles in full electric mode. After dealing with remounting the rotors and stators from various Prius-derived hybrid transaxles, the HSG seemed like a dream come true - it had a housing, a water jacket, and even mounting feet.

 Locally known as an 'Altermotter'
The motors are mounted via clamps to the frame and are watercooled using standard computer watercooling parts. Power transmission to the axle is via Gates Micro-V belts, soon to be replaced with PolyChain Carbon GT synchronous belts - maintaining belt tension on the 46" outer belt has proven to be quite the challenge, as the forces involved are enough to warp the frame.

The back view shows the big pile of electronics. Instead of an enclosure, the control boards are conformal coated, and the exposed HV busbar is covered in liquid electrical tape. This has done us remarkably well, even on grimy Cambridge roads. Logic is powered by a A123 12v7, which is good for about 4 hours of operation on a single charge (the converters inside the power module draw about an amp at 12V). Also visible is the rear brake (stock go-kart caliper with a 200mmx3mm Amazon moped disc) and the traction pack. The Amazon brake disc is made of some unknown alloy that discolors and warps severely under heavy load, and doesn't seem to be fit for any application.

The traction pack (42s LiPo) is made of 14 Admiral Pro 4000mAh in a 7S2P configuration. The Admiral Pro's have excellent performance when they work, but out of the original 18 we bought three have already failed - two had physically leaky cells and one has severely low capacity. The pack seems to work OK once the bad packs have been weeded out, but a 16% DOA rate is not really OK for what claims to be a premium battery...

Last but not least, a front view showing the steering and front brakes. The front caliper mounts are custom, as the cadet cart chassis we built around had no front brakes.

Key Specs:
• Motor: 2x Sonata HSG, 20KW@270V, 50Nm@180A. Please don't read into these numbers like you would a hobby surface PM motor, as IPM's are very nonlinear in what they can achieve due to their high saliency and phase inductance.
• Reduction: 3.5:1 using 7-groove Gates Micro-V belt (~25mm wide) with 4.5/10.0-5 racing slicks.
• Inverter: in-house FOC firmware running on a pair of STM32F446RE's, driving the power stage out of a Gen 2 Toyota Prius.
• Battery: 42S 8000mAh LiPo, conversion plans are in progress for 72S/5300mAh automotive cells.

Upcoming Posts:

Whew, this is a big project! Posts will be broken into two categories, construction and science, including...

Construction
• Motor mounting
• Brakes, including front brake conversion
• Water loop and inverter block
• Wiring and connectors
• Circuit boards and resolver decoding
• Chasing down noise
Science
• IPM specific motor theory
• Analytic stall torque computation from motor parameters
• Optimizing high-speed operation
• Real-world stall testing
• Real-world motor tuning, including the variety of bugs we ran into

## Friday, August 4, 2017

### An interesting scope trace

 Ch1 Voltage, Ch2 Current (20mV/A)

While debugging a laptop the other day I had a chance to throw a hall effect current probe on the DC input while it was running a game (NieR: Automata, just kind of chillin' around in the Resistance Camp). The trace is rather interesting - my interpretation is that there is that there some relatively low-power setup (the short dips to 6A on the cyan current trace), followed 8mS of lower-power GPU work (that has to be the GPU kicking in, the CPU (i7-4800MQ) can't possibly get close to 190W!), and 8mS of higher, but variable, GPU load.

Knowing Automata's rendering pipeline (which involves a lengthy, and costly, GI step), I would venture to say the 10A phase is the global lighting computation (which should, on a 200KHz current probe, appear to draw constant power), and the highly variable phase is generates the actual frame (the different power draws correspond to different stages and/or tricks involved in lighting the final image).

### Hyundai Sonata Hybrid battery pack teardown

We (Ben, Charles, Dane, myself)  recently acquired a 2011 Hyundai Sonata battery pack to go with our Prius parts and Hyundai Sonata motors. The voltage (270V nominal) and capacity (1.4KWh) looked promising for medium-sized vehicles, the power capabilities were rather high (almost 60KW, according to INL), and the price was exceptional ($260 from LKQ for a 'B' grade one,$350 for an 'A' grade one).

Idaho National Laboratory had done some testing on the battery as part of the DOE AVTA program. The full report is here, but the gist of it is:
• 72S 'Lithium Polymer' (3.75V nominal, 4.2V max)
• 5.3Ah (1.4KWh) capacity
• 400mohm pack resistance, ~5mohm per cell
• 60KW peak source (at full charge, 40C), 46KW peak sink (at full empty, 30C)
• 46KW average source (30C), 30KW average sink (20C)
5mohm on a 5.3Ah cell is not bad, on par with the best ("60C") R/C batteries on the market. The complete pack was rather heavy, but hopefully we could shed half or more of that weight by removing the steel armor. Without further ado, let's dig in!

The first thing everyone seems to notice: the enormous blower cooling the pack. Hyundai is very proud of its air-cooled pack design, and boy is that a mighty blower. I wasn't personally interested in the fan, but it could be useful for long-term traction duty.

Ignoring several ominous warnings and removing the HV safety cover, we are greeted by the contactor assembly (more on that later), and...

...the BMS! This one is interesting enough that we'll investigate more at the end of the post.

Moving on, lifting the main cover off the pack reveals the guts of the battery:

It's hard to tell from the photo, but the big silver bars (two on top, one underneath the modules) hold the pack in compression via the end-plates, which are padded with high-density foam.

The modules bear a 'GreenPower' label; there are several power companies going by that name, but none of them seem to make hybrid batteries.

Removing a few dozen screws and unplugging the balance connectors liberates the modules. Not shown: make sure to remove the safety disconnect before servicing the pack internals!

The modules are conveniently sized; each one is 8S/5.3Ah and weighs a hair over 2.5kg (2.6, to be exact). Sadly there is a whole lot of empty space in each module, presumably for airflow, and as a result energy density is quite poor.

Moving on to the contactor box, undoing a large number of plastic snaps reveals two adorable little 400VDC/80A contactors:

I have no idea how they get 35KW through an 80A contactor...

A Detour: the BMS

The BMS is remarkably straightforward inside - in fact, entirely made of off-the-shelf components.

The big IC is a microcontroller. The good news? It has a datasheet! The bad? It is some sort of godforsaken Infineon part, built on a custom uArch and costing \$22

Come on guys, how hard is it to use an ARM?

The actual balancing assemblies are built around the LTC6802 stackable battery monitor. Each chip monitors its own module, resulting in nine chips daisy-chained into each other.

Communication across the LV/HV isolation barrier happens via a pair of  Texas Instruments ISO7241C digital isolators, powered by a pair of 1W board-mount DC-DC converters made by Mornsun (I've never heard of them? Have you?). These seem to be clones of the popular CUI 1W modules.

The strange-looking package above the micro is an Infineon TLE6220 - some sort of SPI-controlled switch for controlling the precharge and main contactors.

THE VERDICT

The good:
• Rather low ESR and high discharge ratings - 40C peak for 10s is about as good as anything gets.
• Convenient packaging; modules are a reasonable voltage and capacity and constrain the prismatics to some extent, requiring only a simple external clamp to maintain compression.
• BMS is built out of off-the-shelf components, giving some hope for reverse-engineering and/or reprogramming.
• Very cheap; the equivalent pack from a Chinese hobby vendor would be well over a thousand dollars.