Estimating motor winding temperature without a sensor
Every hobby servo I own has the same blind spot. Hold the horn against a stop and the motor keeps pushing as hard as it can, and nothing inside the servo knows the winding is cooking. Smart servos fix this with a thermistor on the board or the motor can. I wanted OpenServoCore to know how hot its winding is with no extra part on the motor at all.
My first plan was to use the winding itself as the thermometer. Copper gets more resistive as it warms, and the servo already measures its winding’s resistance, so it looked like a free thermometer. That plan didn’t survive the bench. What ships in the firmware today is an estimate built from the current, and the resistance only shows up as the ruler I check that estimate with.
If you’re new here, OpenServoCore is my effort to turn cheap MG90S-class servos into networked smart actuators with sensor feedback, cascade control, and its own single-wire bus protocol. This is the last of three posts that each ask whether a cheap servo can reliably observe one thing about its own motor. The first one was brush contact resistance, the second one was back-EMF speed, and this one is the motor’s temperature. Everything below ran on MG90 clones on the rev 2A dev board, which carries a CH32V006 (WCH’s sub-20-cent RISC-V microcontroller).
TL;DR
If you only care whether your servo will cook itself, here’s where I landed.
- The servo can’t read its winding temperature live. On a brushed motor the measured resistance includes the brush contact, and the contact moves more than the copper does.
- So the winding resistance is measured once, with the rotor held, during identification. After that a heat model carries the temperature. It’s the board’s thermistor plus two heat nodes driven by the current squared.
- The model runs the other way too. It hands the rest of the firmware a resistance for the current temperature, instead of the firmware measuring one.
- The estimate is a protection number, never a thermometer. Its only job is to shut the motor off before the winding gets too hot.
- Letting the servo find its own thermal constants didn’t work, so you enter them in the servo’s profile, like the gear ratio.
- On one locked-horn test the 90 °C cutoff fired with the copper at about 85 °C. The estimate read a little hot, which is the safe side. It’s one test on one motor though.
Why Not Just Tape a Thermistor On
I did, actually, but only as a reference to check against. The thing that burns in a stalled servo is the enamel on the winding. On these little brushed motors the winding is on the rotor, spinning inside the can with an air gap around it. A sensor on the can only sees that heat after it crosses the gap and warms up the whole can.
The MG90 teardown showed how bad that lag is. I heated a bare rotor in open air with a thermocouple taped right into the winding, and the thermocouple caught only a small part of the copper’s rise, and well after the fact. That’s with the sensor touching the copper, no can in the way. Also, OpenServoCore is going to be a swap board for a servo you already own, and nobody wants to glue a sensor to a motor can.
So whatever the servo knows about the winding, it has to work out from the inside.
Copper Is a Thermometer, on Paper
Copper’s resistance goes up by a fraction of a percent for every degree it warms. That slope is in every handbook, and it’s the same for any copper wire. The MG90’s winding is plain copper, and the servo measures its winding resistance anyway during identification. So in principle, you take one reference reading at a known temperature, and after that the ratio of any new reading to the reference tells you how far the copper has warmed. Nothing to fit.
I checked it on a real MG90 by baking the whole servo in a filament dryer, with a thermocouple on the can and a multimeter across the motor wires (notebook 17). The dryer holds long enough that the can and the winding end up at the same temperature, so the can is an honest reference there. The meter landed right on the handbook slope. The winding is copper, and the handbook is right.
The servo’s own readings were a different story. The first couple of sets of the day read a few percent high, which is worth several degrees of heat that wasn’t there. It went away after a while in the dryer and never cooled off like a warm rotor would, so it didn’t look like heat at all. At the time I wrote it off as something to work around, by re-taking the reference after the motor had rested. It turned out to be the whole story.
Ruling Out the Current Sense
Resistance is volts over amps, and the amps come through a shunt resistor and the CH32V006’s on-chip op-amp. If the op-amp’s gain drifts with the board’s temperature, that looks exactly like the winding warming up. So before blaming the motor, I swapped it for a resistor grid and baked just the board (notebook 15).
In the op-amp’s high-speed mode the gain drifted enough to fake a lot of winding heat. In normal mode the drift was small enough to ignore, so the firmware runs normal mode only now, and a later repeat on a second board agreed. So the current reading was fine, and the problem was somewhere else. I’ve been burned enough times that I check the ruler first now, before I blame the thing I’m measuring.
R Is Only Good Against Itself
The next version I shipped didn’t trust the resistance as an absolute anymore. It took the board thermistor as the base, and only used the resistance as a change, the ratio of R to itself while the shaft held still (notebook 19). Then I graded it, and found out the resistance depends on where the rotor stopped.
I call each place the rotor comes to rest, with the brushes sitting on some spot on the commutator, a seat. Take the same motor at the same temperature, let it settle on a few different seats, and you get a few different resistances. The spread was several degrees worth of copper, at one stop, with nothing else changing. Every so often a brush bridged two commutator segments, shorting out part of the winding, and the resistance read about a fifth low for a few seconds. Notebook 19 has a plot of every seat at that one stop, and the dots that should all sit on one line just don’t.
I went into why the brushes do this in the first post of this series, so here is just the short version. On a brushed motor the resistance you measure is the copper plus the contact between the brushes and the commutator. The contact changes every time the rotor moves, every time the current steps, and sometimes on its own. While the rotor turns it’s even worse, and the number isn’t really the winding at all. So the resistance can only be read with the rotor held still, and then it’s only good against itself, on that one seat.
On one seat it’s actually a lovely thermometer, good to a fraction of a degree. But a servo moves between seats all the time, that’s its job. I don’t think a thermometer that only works until the next move is much use. This is where I decided, the hard way, that reading temperature off the winding’s resistance is a brushless motor thing. A brushed motor needs a model.
What a Heat Model Is
The idea is pretty simple. Think of the winding as a bucket and heat as water. The current pours water in at a rate of the current squared times the resistance. The bucket has a leak into its surroundings, and the leak gets faster the fuller the bucket is. So at a steady current the level climbs and then settles where the leak matches the pour. The level is the temperature over the surroundings.
Two constants describe one bucket. The thermal resistance, in degrees per watt, is how high the level settles for each watt you pour. The time constant is how fast it gets there. That’s one heat node.
A real motor is more than one bucket. The copper pours into the rotor iron, the rotor into the can, the can into the air. Each of those is a bucket draining into the next one at its own speed.
The thermistor sits at the far end of that chain. By the time it feels anything, the copper has already done its warming. That’s the lag from the teardown, drawn as buckets.
Letting the Servo Find Its Own Constants
A model needs those constants for each servo. My plan was for the servo to find them itself, as one more step of identification. Hold the rotor, heat it, watch the resistance ratio climb on one seat, fit the curve.
It didn’t repeat. Each run gave a wildly different thermal resistance. The reason was the same contact problem again. Inside one hold the contact drifted by a big share of the heat I was trying to fit. You can’t fit a curve when the ruler moves that much while you’re measuring.
I took that pretty hard at the time, because self-identification is a big part of what I want OpenServoCore to be. But a constant that comes out different every time you measure it is worse than a constant someone typed in, since you at least know where the typed one came from. At that point I paused all the thermal work for a while.
Protection Is Not a Thermometer
When I came back to it, I asked what the firmware actually needs (notebook 21). It needs to keep the winding from cooking itself. A winding temperature on the screen is a nice extra, but the servo doesn’t need to know the exact degree. It needs to know when to stop, and if it’s going to be wrong, it should be wrong early.
That changed the whole question. The resistance thermometer had grown into a big pile of firmware, all to chase seats. Meanwhile the kernel already kept an I²t sum for the current limit. I²t is a leaky running sum of the current squared. Since the winding’s heat is the current squared times its resistance, that sum is basically the bucket from the last section in disguise. Add it to the board thermistor with one constant and you have a winding estimate. One multiply replaced the whole thermometer.
The resistance didn’t go away completely. I still needed something to check the model against, and the only thing that touches the copper is the copper’s own resistance. So it got a new job as ground truth, the measurement I grade the model with. It’s only used where it actually works, as a ratio on one seat inside one hold, offline in a notebook on the bench. It never goes into the firmware.
Two Nodes, and What the Fast One Is
One bucket wasn’t enough. The heating curves clearly had a fast part and a slow part, and a single node fitted somewhere in the middle read too cold at the higher currents. Too cold is the dangerous direction for a protection number. So the estimate grew a second node, a fast one for the copper and rotor, and a slow one for the can and the board.
The fast node settles in a couple of seconds. At first I decided that was the brushes and threw it out. That turned out to be wrong.
When I fit it carefully in the stage 4 notebook, the heat capacity behind it came out tiny, only a small slice of the rotor. Several motors agreed on it, and one of them was the bare rotor from the teardown, with no brushes in the circuit at all. So the fast node is the copper itself, dumping its heat into the rotor iron it’s wound on. That’s also why a sensor anywhere outside the rotor is so far behind.
The catch is how much of the curve the data actually checks. All of stage 4’s holds were short, so it only grades the first few seconds of a drive from a rested motor. The slow node, the one that decides where the winding ends up after minutes of holding, comes from earlier work on another MG90, and that work left two quite different readings of it.
The stage 4 notebook has a plot of every candidate model against time. They all agree for those first few seconds and then go their own ways. At the higher current the low and high readings end up tens of degrees apart, and nothing in stage 4 picks between them.
I could have hidden that by plotting one line. But for a protection number, knowing where the data stops and the borrowed model starts is the whole point. Inside the graded seconds I trust it. Past them, I pick whichever reading errs hot, and I say so.
What Ships
Here’s how the estimate runs in the firmware today. The full description is in the control theory doc.
The first direction is current to temperature. Every short period the firmware squares the current it measured and feeds it into both buckets. Each bucket is a leaky average with its own time constant, and each has a gain that says how many degrees its level is worth. The winding estimate is the board thermistor’s reading plus the two bucket levels. The input gets warmed by copper’s slope too, so a hotter winding heats a little faster at the same current, the way real copper does. The leaks are picked so the whole thing is a few multiplies and shifts, which matters on a chip where every cycle counts.
The second direction is temperature to resistance. The firmware never measures the resistance live. Identification measures it once with the rotor held, and stores it scaled back to a standard room temperature with copper’s slope. After that the firmware runs copper’s slope forward at the estimated temperature, and that gives it R̂, the resistance the winding should have right now. R̂ goes to the back-EMF speed observer from part 2 and to the current loop when the current is too small to read. A warm winding read at its cold resistance shows up as fake speed in the observer, so this matters more than it looks.
Here are both directions in one picture.
The resistance the firmware uses only ever comes out of the model. A measured resistance shows up on one arrow, the dashed one from the bench, and that one lives in a notebook, not in the servo.
There’s one limit. When the estimate reaches 90 °C, an overtemperature fault latches and the drive goes off. There’s no derate and no soft approach inside the servo. A host that wants one can read the estimate over the bus and back off on its own. 90 °C is only the default, and like every limit it’s a field the host can change. If the thermistor itself reads like it’s open or shorted, the servo faults at boot and never drives.
The thermal values, two time constants and two gains, live in the servo’s profile. You enter them like the gear ratio, and identification won’t finish without them. For my MG90 the profile uses the higher of the two plateau readings. It was the only one that reads at least as hot as the constants the servo already had, in every case I worked out, so switching to it couldn’t loosen the protection anywhere. Thermal identification is shelved for now.
Checking It on a Locked Horn
All of that grading covered a few seconds. The one live, end-to-end check I have is a lock hold. I clamped the horn of one MG90, held a moderate current for a few minutes, then stepped it up and left it there until the firmware’s own cutoff fired. The truth was the copper’s resistance, as a ratio on that one seat.
The cutoff latched with the copper at about 85 °C. So the estimate read a few degrees hot right at the moment it mattered, and the winding never saw 90. That error is about the same size as the old resistance thermometer’s disagreement with itself from one seat to the next. The difference is that this one sits on the hot side, where it trips early, and the seat error could land either way. Along the way the estimate ran a little hot most of the time, a little cold for one short stretch early on, and never far off either way.
And of course the brushes showed up. When the current stepped up, the measured resistance jumped almost instantly, worth several degrees of heat. Copper can’t warm that fast, so it was the contact again, probably the seat shifting as the extra torque wound up the gear train. If I hadn’t caught it, the copper would have looked like it crossed the cutoff before the cutoff fired, and the estimate would have looked dangerously cold. This is exactly why I keep saying the resistance is only good against itself.
The board thermistor was basically no help at this time scale. Over the whole hold it barely moved while the copper climbed nearly all the way to the cutoff.
The hold also gave this motor its own constants. They fit the hold better than the stored ones, and the stored set reads hot mainly because its slow node is bigger. I left the stored values alone anyway. Making the slow node smaller makes the cutoff fire later, and I want a few more holds on other seats before I move anything in that direction.
What I Still Don’t Know
- Nobody has put a sensor on the copper of an assembled motor. Every “winding truth” in this post is the winding’s own resistance, the exact quantity the brushes mess with. The lock hold is the best I have, and it’s one hold on one motor, at one seat, with one contact step caught and taken out. Everything from it is a candidate until it repeats.
- The contact jump at the current step isn’t root caused.
- A power cycle resets the estimate to the thermistor, so a hot motor that reboots forgets its heat.
- The slow node, which decides where the winding ends up, rests on earlier work and that one hold.
- The dev board’s thermistor sits in room air. On the swap board it will sit on the can, and the slow node goes away. That setup hasn’t been graded yet.
What’s Next
The lock hold needs repeats, at a couple more seats, with a step down as well as up. If those agree, the stored slow node can come down to match the motor. I’d still like the servo to find its own thermal constants one day, but only if I find a way that doesn’t stand on brush contact. Until then, a few numbers in a profile works fine.
So for heat, the answer to this series’ question is a mixed one. The servo can’t read its winding temperature directly, because the winding’s resistance is too tangled up with the brushes to read live. But a simple heat model, checked against the copper the one way the copper can be trusted, is good enough to protect it. On the one hold I have, the 90 °C cutoff fired with the copper at about 85 °C, a few degrees early and on the safe side. I’ll take it.
The stage 4 data and fits are in the winding-temperature notebook, and the older notebooks are in the OpenServoCore repo. If you’ve measured the copper of a tiny brushed motor some other way, or you know what MG90 magnet wire is actually rated for, I’d love to hear about it!