December 2021

I bought a camera!!


Posted on December 16, 2021 by admin

Big life update: I bought a camera. I’ve wanted to buy a nice DSLR for literally 5 years or so, but only now with some side consulting could I justify shelling out the cash. Turns out, my great grandfather was a professional photographer. So, camera time…

I knew I would be using this camera for product photography on a near-daily basis, so I decided to go for a nice camera right off the block rather than putzing around with an APS-C with the plan to upgrade. All of my friends have Nikon’s so I chose to stick with them so I can steal my friend’s lenses. Many friends recommended the D850, but I stumbled upon the mirrorless Nikon Z series and instantly decided that was the way to go mostly due to the smaller size. The new Z series is even backwards compatible with the F-mount lenses with the help of an adapter (included in the kit I bought). The Z series cameras also have some strange features like “Supports charging over USB while the camera is on” (how did it take until 2021 to implement this???) and even taking pictures over bluetooth through Nikon’s app. I eventually settled on the Nikon Z6II, and with some mild credit card pain, I pressed the buy button. Never having owned a camera at all before, I wasn’t quite sure what to expect.

At the beginning, I was pretty turbo-bad at operating the beast, as the learning curve on ‘how to operate camera’ is steep. But as time went on, I started actually being able to produce some photos which weren’t complete garbage. So far, I have been consistently impressed- this thing rocks. I am by no means an expert in photography by any stretch of the imagination, but it’s pretty clear that this thing blows away any phone completely. I watched a ton of Youtube tutorials on how to do photography, and have slowly gotten better. Here are a few of my favorite photos.

didn’t know here about depth of field lol
shop-vac-ing the fire

A nice camera can make anything look beautiful. Like, for example, this mind bogglingly beautiful and aesthetic photo of nothing less than a heap of dung:

This was taken before I knew about bad lighting!

Or how about this well framed photo of a garbage can?

I eventually ended up with no less than five different lenses (four pictured below because I had to use one to take the photo):

Surprisingly I do not regret buying any of these lenses. The four pictured are all the NIKKOR Z-mount lenses, which everyone seems to love. In no particular order:

The classic 24-70mm F/4. This lens is perfect to take out into nature, where the best thing to have is a single versatile lens which isn’t massive. Changing lenses in the woods seems annoying. I bought this before Nikon released the 24-120, which is larger and heaver than the 24-70, but has an impressive 5:1 zoom. If I were to buy it again, I might have gone for the 24-120, but the 24-70 is lighter and more compact which is probably better for hiking so I don’t know which is truly better.

A weird one: Nikon recently released the 40mm F/2 compact lens. This is a perfect “social gathering lens” as it is wide enough to capture the whole scene in a relatively confined space, but not quite wide enough too be a wide-angle (which I am not a huge fan of). A more strange benefit of this lens is that, in general, people have an irrational fear of staring down the barrel of a large lens. Therefore, having a smaller lens generally is good for parties to avoid scaring people. It was also about half the price of the others which is nice, although the build quality is noticeably less good than the 50 and the 85 as a lot of the metal parts were replaced with plastic. Definitely still a great lens though. This lens is also wonderfully compact, and the full setup ends up feeling more like a point-an-shoot than a high end camera. This is kind of what I want for this lens anyways.

The 85mm F/1.8– also a weird lens. I got this after I got the 50mm, as I wanted something a bit tighter for project photography. It took me a while to get used to this lens, as it really does require setting up the tripod and moving some furniture to shove the tripod all the way on the other side of the room to take a photo of anything bigger than a banana. However, this lens has completely proved its worth for project photography. The photos out of a good lens with a longer focal length are just absolutely stupendous IMO. The 85 produces a photo with a much flatter view than the 50, and and also it is a lot easier to control the background without completely reshuffling my entire apartment. Changes are if I’m taking a nice photo I’m reshuffling the apartment anyways, but it is worth the results.

The classic 50mm F/1.8. This lens is pretty cool and an absolutely superb all-rounder. However, unfortunately I end up reaching for this lens relatively rarely, because I have other options which are usually better suited for the specific task I’m up to. I usually end up reaching for the 40mm when I’m taking the camera to a social event (because the 40 is a lot smaller), and end up reaching for the 85 for project photography. Still, definitely a good lens and it does find use on occasion.

Finally, the lens that I got first, which isn’t pictured in the first photo as I used it to take the picture: a Sigma 105mm F/2.8 Macro lens. This lens is the only macro I have, but probably the only one I will ever need. This is an F-mount lens, so it needs the trusty little FTZ adapter. I got the adapter in the kit I bought, so it was no problem. The adapter does make the lens stack a lot longer, but this is no problem for macro stuff where I usually use a tripod anyways. However, annoyingly, the FTZ adapter does not support the type of autofocus in this lens, so manual-only for this one. Not the worst, as again I usually tripod it anyways, and macro photography is probably 90% manual focus anyways. This is the perfect lens for taking pictures of all the PCB-related projects I do.

The bottom line: If I’m taking pictures of people in an indoor setting, I bring the 40 or 50, and if outside, the 85 is the way to go. However, if I had to buy just one lens, it is hard to go wrong with the 24-70 for its versatility.

In terms of other lenses I considered, I also considered the 24-70 F/2.8, but ultimately decided it wasn’t worth the price hike. After watching a bunch of Youtube tutorials, I found that the depth of field and bokeh difference between the F/4 and the F/2.8 is not actually that noticeable. However, the difference between the F/2.8 and the F/1.8 is extremely noticable. Another note on bokeh- I have an extremely cluttered apartment, so if I use a lens with more bokeh, I have to clean up less of the apartment to take the same quality photo…. oho…

Next up- time to do some photgraphy.

The thing object photograph was the small dyno, which proved to be WAY more challenging than I thought. Firstly, it is made of aluminum, which was polished to be highly reflective. This proved to be extremely annoying, as I don’t have any light spreaders. Secondly, it is a effectively a stack of two layers, and capturing both layers in one image proved difficult.

First up, I just took some straight-up BAD photos. Here, I had a TV in the background with some graphs, but this just ended up making the dyno very backlit.

Put the dyno on a cutting board I found on the side of the road, set on top of some electrolytic capacitors.

The apartment also developed into a thorough dumpster fire.

Slowly, I began to realize that my pain was really twofold:

  1. the dyno was blending into the background, as all the aluminum parts on the dyno were reflecting the ambient light just as well as the background was. A lot of tutorials immediately jump to “you need a white background” which just proved to not work, at all, for the aluminum parts on the dyno as they just completely blend in.
  2. The electronics plate was casting a huge shadow, making the torque sensor look kind of dull. Additionally, the black anodized motors are literally black holes in the photograph.

I also ended up with a lot of salmon-colored dyno photographs as I attempted to use some horrible worklight to illuminate it as hard as possible. More light is NOT better sometimes.

Very visible in this photograph that all aluminum parts on the dyno are INDENTICAL in color to the background, therefore the dyno felt as if it was just blending in.

The solution here was twofold. I found some excellent videos on youtube which detailed how to photograph metal objects, including an extremely helpful one which detailed how to take a picture of a very shiny cheese grater. The takeaway here was that shiny metal objects do not have a color- they simply reflect light, and therefore copy the colors around them. The key here was to very selectively angle the lights to only light up the dyno itself, and avoid casting as little light onto the backdrop. I ended up moving the lights to a more top-down position, and I also installed some little blinders to minimize light cast on the background wall. This had the desired effect of turning the background into a grey rather then the pure white it was before, while the aluminum parts where kept lit. Simply adding more light was NOT the answer- originally, I had a bunch of lights pointed straight at the dyno in an attempt to light up the torque sensor, which had the unintended consequence of brightly lighting the background as well, which was why everything was blending together.

The second problem was that the electronics deck was casting a shadow, basically completely blacking out the torque sensor and motors. This had the effect of making the center of the dyno kind of a black hole, even though the torque sensor and test motors were really what I was trying to highlight all along. The solution here was to stick the light inside the dyno, right under the torque sensor. I stuck a bit of LED strip right inside the dyno. I didn’t have any warm white favorite, so ended up just throwing in some cool white. This had the effect of making it look even more sciencey, so I kept it. Cool!

With all that done (and the apartment a COMPLETE garbagepile) I finally got a really wonderful photo.

After this I did some touch-up in a combination of Nikon Studio and GIMP to make the photo more balanced, and to remove the spot on the wall. I decided this photo was “good enuf.”

There are a few things I would change about this photo- a close eye will notice that the left side of the photo is rather blown out, as the lighting on that side was too direct. I don’t have any light spreaders, so that’s just what I got. Good enuf.

Anyways, all that said- camera, fantastic object. I use this object almost every day, and have now averaged 20 photos per day. Would buy again 10/10.


0

Saturating the Prius Inductor


Posted on December 15, 2021 by admin

The good ole’ 2nd gen Prius boost inductor. Extra large, extra cheap. I was unable to find a measurement of the saturation current of this inductor on the internet, so I set out to measure it myself.

This inductor is one of the beefiest I’ve ever set my eyes upon, at about 400uH, and I estimated it had a saturation current somewhere between 150 and 200 amps. I measured the line-to-line resistance at 19 milliohms. At 150 amps, this equates to over 400W of resistive losses alone. I plan on using this inductor for the big dyno, where it will need to handle peak DC bus currents of around 150 amps.

The usual strategy for measuring saturation current is to charge up a cap, then instantly connect the two and observe the LC ringdown. The electrical engineer’s way of doing this measurement would be to use a large IGBT plus a diode for the reverse current. I did not own a large enough IGBT to build this device. Therefore, it was time to build the device using mechanical engineering, and mechanically switch in the capacitor. I ended up using a 420uF film cap, as an electrolytic won’t work here as the inductor will force a reverse voltage across the capacitor. In order to really push the inductor into saturation, the cap needed a good 250 volts.

The craparattus in question. A paint stick kept a thin piece of aluminum separated from a bolt sticking out of the inductor. The paint stick was pulled out quickly, and a rubber band forced the aluminum stick into the bolt. The pop generated here was actually pretty quiet, because it’s not cap-on-cap but rather cap-on-inductor so the instantaneous current is zero. Enough to create some sparks though. I used a 300A LEM current sensor. The current ran through 10 gauge wire, with the alligator clips just being used for charging the cap through a resistor.

Of course this was a great excuse to take some long exposures.

Here is the ringdown. The current sensor gain equates to a gain of 75 amps per division. Noticeable saturation is present in the first few peaks. It is also clear that the saturation is rather soft, on the second peak (about 240A), it is clear that although saturation has occurred there is still some amount of inductance left. All saturation has disappeared below 150A. Cool!

A shifted view. It is clear that below 150A no saturation is present.

Bottom line: Saturation begins to occur around 150A, but there is still enough inductance to keep things in line up til about 200A. Additionally, the resonant frequency of the system is 400 Hz. Therefore, the inductor has an inductance of about 380 uH if the capacitor was indeed 420 uF, which the label guarantees it is to within 10%. Cool! Next up: time for some big power converters.


0

Quantifying a Motor: the IPM Dyno


Posted on December 9, 2021 by admin

The land of motor ratings is pretty dubious. All too often, people say, “yes, this motor has a stall torque of 11.8 Nm and a no-load speed of 16krpm- therefore this motor produces TWENTY THOUSAND WATTS.” Alright then…

But did you actually measure that? How do we even measure power of a motor in the first place? What even is power? Let’s get into the physics…

An electric motor is a device which converts electrical power into mechanical power, usually through a magnetic field. The same device is also a generator, when the flow of power is reversed and the mechanical power is converted back into electrical power. This is also referred to as “regeneratively braking.”

Most of the time, the power we care about is the mechanical shaft output power produced by the motor. Torque is measured in newton meters and speed in measured in radians per second, so when multiplied the answer comes out in watts.

\[P_{mech} = T*w\]

Electrical power is also useful to know. Volts is measured in volts and amps is measured in amps, and when multiplied the resulting answer comes out in watts.

\[P_{elec} = V*I\]

These equations cannot simply be set equal to each other to find the remaining variable, because there will always be losses in the system. These losses are dissipated as heat. Due to conservation of energy, the full equation is:

\[P_{elec} = P_{mech} + Q\]

Efficiency for motoring operation is mechanical power divided by electrical power. A normal brushless motor might reach a peak efficiency around 90%, but will be less efficient across most of its operating range.

\[Efficiency = \frac{P_{mech}}{P_{elec}}\]

Motors are not very efficient at some operating ranges, most notably at low speed and high torque setpoints. 1 kW could be coming out of the battery, but if the motor is stalled, the speed will be zero, and therefore the efficiency will also be zero- this means the motor will be generating 1 kW of heat and will quickly catch on fire. Anyways- the four variables to keep track of here are: torque, speed, volts, and amps. In order to characterize a motor, we must measure these four parameters with high accuracy.

One final note is worth mentioning before we enter the practical realm. As most motors these days are brushless, we have to measure not only the efficiency of the motor, but of the inverter as well. My opinion on this matter is that measuring either one individually is almost completely useless. The efficiency of a brushless motor completely depends on how well the inverter drives it. For example, lowering the switching frequency of the inverter would reduce inverter losses, therefore increasing inverter efficiency. However, this will reduce motor efficiency as ripple current increases. Therefore, I always think of the motor and inverter as a system which is a mated pair.

Moving on to the practical stuff.

It’s generally not too hard to measure electrical power, but measuring mechanical power is a bit trickier as we have to accurately measure the torque produced by the motor. Additionally, we need create a load for the motor to apply torque against. The most intuitive and vaguely real-world situation I’ve seen is to test with an inertial load. This is what a lot of the car dynos do: the vehicle is rolled onto a set of heavy rollers, and load is provided my the roller’s own inertia.

\[T = I*\frac{dw}{dt}\]

Just measure the speed of the roller, differentiate, multiply by the roller MOI, and you get the torque. The measurement will be noisy, but good enough for ballpark testing. I’ve seen a lot of Battlebot teams do this by cutting out massive steel disks and spinning the disks up and down. This is probably the best way to go on a budget, as its easy and not incredibly dangerous. That being said, its not great, as you can’t hold speed constant, and if anything does go wrong, you are still stuck with roughly 20-80 kJ of metal spinning at 200 MPH.

Equally as important to creating a load is the ability to precisely measure said load. Measuring speed is easy, but torque is harder. If using an inertia disk, differentiating the speed can get you somewhere, but probably not better than a few percent accuracy as differentiating a noisy measurement isn’t great. A better option is to use a real torque sensor to directly measure torque produced by the motor. A variety of methods exist for measuring torque. At a high level, they can be split into either reaction-based sensors or spinning, on-shaft sensors. Reaction sensing torque sensors are easier to build, and perhaps more accurate as there are no slip rings or transformers. However, the dynamics of having your load or test motor supported on a flexure are a bit strange, and so the industry-standard way of measuring torque seems to be the on-shaft method. The MITERS go-to is the Himmelstein torque sensors, which have a strain gauge bridge on a shaft and a set of rotary transformers to connect to the not-spinning world. Other, stranger torque sensors exist, including optical-based sensors and even slip-ring based sensors (“please open your sensor after every 100k rotations to clean out the brush dust.” Excuse me?!?!?). I found a Kistler torque sensor for $65 on Ebay. The bearings were smashed, but with some replacement Ebay bearings we were back in business. Aaron found the weird German connector for this sensor also on Ebay.

Hypothetically, just the motor under test, this sensor, and a huge chunk of aluminum could be used to perform a fairly accurate torque and power measurement. However, I wasn’t exactly thrilled about having a 25 kJ hunk of metal spooled up in my apartment. With the power of technology, we can do better!

The instrument we are looking for is an electric motor dynamometer. Instead of an inertia disk as a load, we can simply use another electric motor, which regen-brakes just as hard as the test motor is producing torque. The load motor technique is quite good, and opens a lot of doors, as the motor can be programmed to simulate any load imaginable: constant speed, constant torque, inertia, inertia plus friction/air resistance, etc. The motor can even be programmed to simulate a changing load, like driving up and down a hill. Wikipedia has an excellent writeup on dynos. Ben Katz also made a dyno a while back, which is quite cool. After a while of bumbling around with various motors, I too concluded that I needed to build one of these instruments, especially with Battlebots right around the corner. A good excuse to turn up the watts. Here is what I ended up with:

This dyno consists of two rehoused air conditioner motors and the 10 Nm Kistler torque sensor. Mechanically, the dyno consists of a 3/4″ plate of Mic6 I acquired cheaply, with some rubber feet on the bottom. Two 8020 rails allow for any length of motor to be easily mounted. Even better, a 3 jaw chuck allows most inrunners to be easily mounted. For outrunners, the chuck can be removed and the plate behind it has a bunch of different bolt patterns. The torque sensor free-floats between two diaphragm couplings to avoid overconstraint. All of the electronics bolt to a plate on top of this whole thing (not shown) which is mounted on wubs. The electronics on top situation was an interesting move. I figured I’d be reprogramming the inverters and changing wiring a lot more often than I’d be changing out motors, so I wanted easy access to the electronics. This worked out great, although it does make the dyno a bit uglier. Here was the first go at wiring the dyno:

After some wiring cleanup, and a proper photoshoot:

The Details

Electronics

In terms of electronics, there are two identical inverters, both based on STM32G431s and 50A FNB35060T bricks. A STM32F446-based hub board talks to the absorber inverter over isolated CAN and to the test motor over isolated RCPWM (although CAN is supported as well). Both inverters are heat-sunk to the 1/4″ aluminum electronics plate. The torque sensor is read by an ADS1220 ADC, which is a quite a good ADC with an integrated low-drift reference and even a PGA. The ADC is powered by an isoladed DC/DC with a 3-stage RLC network after it, and talks to the hub board over SPI through a digital isolator. A very large 400V 2.7 mF buscap is also mounted to the electronics plate. I added this to keep the bus voltage ripple as low as possible, hopefully improving accuracy of efficiency measurements. It isn’t really clear what happens to efficiency if bus voltage is if it is oscillating wildly, so keeping voltage stable here is in our best interest. The DC bus voltage is divided down by a resistor divider made of 0.05% resistors, and then also fed into an ADS1220. DC bus current is to the test motor is measured by a large 1 milliohm 4-wire shunt, which I measured using a precision milliohm meter to be 0.998 milliohms. The shunt voltage is measured by a third ADS1220, this time with a PGA gain of 16. Both the volt and amp ADCs are also powered by an isolated DC/DC, again with a 3-stage RLC filter after it, and also talk to the hub board over isolated SPI. There are ferrite beads on every wire here to prevent common-mode noise, “the more beads the better.” A 100A semiconductor fuse also is in series with the test motor, hypothetically preventing explosions due to sketchy firmware.

Before the wiring cleanup, I had a ton of trouble with electrical noise. As soon as the bus voltage was increased above 50 volts, 1.7 Nm of bonus torque appeared on the torque sensor for no reason. Tons of noise isn’t really all that surprising, as I’ve got two motors running on high voltage and everything is all bolted to the same aluminum plate. The solution to this was to stick isolated power converters everywhere, as well as ferrite beads wherever they would fit. This solved the noise issues more or less completely, and as I found out made the final measurements extremely clean.

Controls

For the majority of testing, the absorber motor runs in velocity mode and the test motor runs in torque mode. The exception to this is in inertia simulation mode, where they both run in velocity mode, but the absorber velocity setpoint changes as a function of torque. I tuned the absorber velocity loop to be extremely snappy. Additionally, I set up the main hub board to feed-forward the torque sensed at the torque sensor to the absorber motor, which reduces the velocity loop settling time. The velocity loop runs on the absorber motor inverter to minimize propagation delays.

Lets generate an efficiency map!

For data gathering, I run the main loop on the hub board at 500Hz. I set up the ADS1220 ADCs to update at 600Hz, so they just barely finish when the hub board requests new data. The biggest thing which helps make the data here as smooth as possible was the use of moving averages throughout the entire sampling period. Ben also suggested an interesting technique where data is averaged over an integer number of rotations. I did not use this as it matters less the faster you spin. However, I will likely activate this for testing at speeds below 1000 RPM.

For generating this efficiency map, I ran 21 speeds and 31 torques, with a settling time of 300ms and a data collection time of 500ms. I expected this to be nowhere near enough sampling time, but to my complete surprise, the data came out 100% beautiful and smooth on the first try. Complete miracle. I also only turned up the motor to about 50% power, with more power reserved for future work. Peak efficiency was 90.6%±1%. The small jump in efficiency at high speeds occurs as the inverter switches to a different commutation mode at high speeds. I’ve theorized that this would gain a percent or two in efficiency, but I’d never had the tool to verify this. Turns out, it works!

We can also look at the mechanical power, the electrical power, and the power losses. Peak mechanical power is about 1830W. Due to the IPM motor, we get high power all across the RPM band! The white area in the upper right is power attainable only with more volts. The high speed mode simply attempts to do the best it can with the volts available, allowing a small boost in power.

Elec power. Fairly similar to mechanical power.

Power dissipation. More or less completely as expected. It is interesting to note however how power dissipation at high speeds and zero torque is above 100W, most likely due to a combination of windage and resistive losses due to field weakening.

All of this testing was done with a bus voltage of 160V. This test really 100% proves that 160V is nowhere near enough for these motors, as field weakening becomes necessary at only 2500 RPM, which is pitiful. These motors would really cook on 400V.

A Note on Accuracy

The target I set for accuracy on this system was knowing the efficiency of the motor within a percent, so ±0.5% accuracy in the full system. The torque sensor is 0.2% accurate, and it is unlikely that all components will be 0.2% off spec all at once. So, I shot for 0.2% accuracy on each of the four measurements. Three of the measurements are taken by ADS1220 ADCs, which are quite fantastic actually, having a typical gain error of ±0.015% and a integral nonlinearity of only ±6 ppm of the FSR. The reference inside the ADC is even good for ballpark 0.025% accuracy (typical, looking at the graphs). At the moment, the least accurate part of this system is the speed measurement, which is done by differentiating the encoder measurement on the absorber motor every sample period. The resonator on the absorber motor controller is only 0.5% accurate and furthermore the absorber PCB experiences large temperature variations so it is likely to drift. The Kister torque sensor actually has a built in encoder, but for whatever reason it does not work. Eventually I will add a separate encoder just for speed measurement. So, right now I trust the efficiency measurements to ±1%. Really, Ben and I need to dyno some motors and see if we get different results…..

I do know of some people that have access to some high precision voltage and current sources, so these should be pretty easy to calibrate to achieve higher accuracy. Speed is pretty easy, as with a crystal and a good encoder its hard to be wrong. Torque is the hardest to calibrate, but I actually did buy another Himmelstein torque sensor which I will have to use to calibrate this Kistler one.

Buck Converters?

This dyno isn’t terribly useful at the moment for motors other than rehoused automotive air conditioners, because everything really requires 200V to operate. In order to rectify this (no pun intended!), I will need an extremely large buck converter. So far, I have not yet built anything remotely this big, but it is in the works. Stay tuned!

Tips and Tricks

One of the hardest things to figure out on a project like this is which thing will be in command, and therefore what handles the time-critical tasks. For this, the big question was whether to make the F446-based hub board in command, or whether to make some GUI which would handle timing. I chose to make the micro in charge of timing, because micros are inherently good at that sort of thing. When I do eventually make a GUI for this thing, this GUI will probably function much like a slave device where the micro handles requesting for the next data point from the GUI rather then the GUI commanding a sequence of setpoints.

One interesting problem here is that I’m running two identical motors and inverters, which means that one could out-torque the other if commanded to do so. This comes up pretty often, as I continually upload firmwares to the test motor which produce more and more torque. To prevent runaway, I simply capped the test motor to 95% torque, which worked out well enough for testing, and simplified making everything as all the components are the same. If a firmware did indeed produce more torque on the test motor, I just uploaded it to the absorber motor and continued development. The real limiting factor here is the 50A phase current limit on the load motor inverter, so eventually I’ll probably lay out a 75A inverter for the absorber motor.

One of the really cool things about a dyno like this is that it it’s a wonderful display of conservation of power. The test motor takes in electrical power from the DC bus, and converts it to mechanical power on the shaft. The load motor takes mechanical power from the shaft and converts it back to electrical power on the DC bus. So if the system is running at 5 kW mechanical power and both motors are 90% efficient, we will only consume about 1kW from the battery, which is pretty cool!

For this dyno, so far I’ve done all my testing with the dyno powered off a battery. This is a bit annoying because I need to precharge my huge buscap, and also dangerous because there is no current limit. I haven’t really found a good solution other than a battery, because if the dyno unexpectedly regens, it could potentially regen at the full 200V, 50A which is quite a bit of power to put somewhere. The classic solution seems to be a resistor bank, but the resistor bank ends up being about as big as the dyno. As I don’t really have a power supply that can run everything anyways, battery it is for now.

Some more fun photos


0