Motion becomes erratic after a few minutes

I’m using SimpleFOC on a Nucleo-64 with an (AliExpress) SimpleFOC shield, in position mode.

When I give it a series of positions which it can get to, it seems totally fine.

But, if I increase the rate at which the same set of positions is requested, so that it is unable to ever reach its target, it works well for a few minutes then becomes erratic & twitchy. Shortly after that it either stops moving or goes into a steady spin.

I’ve tried logging the PID last_error values to see if the controllers were suffering some kind of windup, but they don’t seem to grow ridiculously.

I’ve looked at the encoder position values in the bad state, and they seem sensible.

Tracing out the motor voltages show that they are not changing when it is in the bad, stopped state.

After a reset, everything works again, so I don’t think this could be a thermal problem.

I’m at a bit of a loss for where to look next. Any thoughts ? Thanks!

Sounds like PID or low-pass filter is getting fed a bad value at some point. What kind of encoder are you using? If hall sensors, then it’s probably a bug that I found and Runger has fixed in the dev branch HallSensor.cpp volatile access bug #244 by runger1101001 · Pull Request #250 · simplefoc/Arduino-FOC · GitHub
There was a condition where velocity measurement could divide by zero and return infinity. I think it was the low-pass filter that would get stuck returning infinity afterward.

Thanks - it’s a
MagneticSensorI2C sensor = MagneticSensorI2C(AS5048_I2C);
which I guess is not that ?

I’ll add some tracing of the filter values somehow, see if I can see any badness.

… no smoking gun in the get_y_prev values in the low-pass filters, for whatever that is worth.

The way you describe the error it sounds like the motor is losing alignment to the magnet… when the misalignment reaches a certain level all the current gets put into the D axis instead of the Q, and the motor stops moving. Don’t leave it for long in this state or it will get very hot and break…

Is there any chance that the rapid motions you command might be causing the magnet to slip out of position?

1 Like

That’s an interesting question. I’ve never looked at the magnet in this assembly, it was put together by a student. I’ll just do a bit of dismantling.

Yes! The magnet was in a 3d printed adapter, which rotated pretty freely in the motor. I suspect it was PLA and had been deformed in an earlier overheating incident.

I’ll print it a new and better adapter in ASA and see if the problem is fixed.

Many thanks for the suggestion, I was just going to keep looking for a software problem.

1 Like

New adapter has fixed it.

Sorry for all the malarkey, and thanks for your help. I’ll be more mistrustful of the hardware next time.