I’ve created a device that is basically a SimpleFOCMini + AS5048A + tiny motor. I have several copies of them, they work very well.
The settings are as follows:
// Motor phase resistance. If set, used to calculate current limits based on
// voltage limits. Value in Ohms. In a star configuration:
// Phase-to-phase resistance = Phase resistance * 2
// https://docs.simplefoc.com/phase_resistance
// The datasheet gives the phase-to-phase resistance (or "line resistance") in
// ohms.
this->phase_resistance = 12.5f / 2;
// Motor KV rating, RMS value.
// KV rating is called "speed constant" in the datasheet
this->KV_rating = 108;
// Phase inductance, in H.
// The datasheet gives the phase-to-phase inductance in mH.
// In a star configuration: Phase-to-phase inductance ≈ 2 * Phase inductance
this->phase_inductance = 1.15 / (1000 * 2);
Yesterday, I received a new copy of the device, which doesn’t work: the motor is noisy and runs amok as soon as I touch it or set any non-zero velocity.
What could be the reason?
Clues:
If I don’t set the KV_rating, the device works as expected
If I double the phase_resistance, the device works almost as expected (small instability)
The measured phase resistance of the motor hasn’t changed
When adding KV rating, BEMF is being compensated using the measured velocity:
In your case it might be overcompensating.
If pole pair, KV rating and phase resistance of the motor are same, it could be a problem with the measured position/velocity, or a problem with the driver ?
It probably just needs some finetuning. If doubling the resistance works, do it. I’m pretty sure I always used the measured resistance between two motor wires, so 2x resistance of a single phase. Although it’s been a while, so it’s possible the code has been changed since then. The inductance code is also fairly new, and I haven’t messed with it much. I’d recommend leaving the inductance unspecified, at least until you get it running well. And start with MotionControlType::torque so you don’t have the velocity PID involved. The target will be in amps, so it should accelerate to full speed with a fairly low value, since it will continue applying torque until back emf equals the voltage limit. And it should come to a stop if you set target 0. If it won’t stop, you need to adjust kv up or down (can’t remember which).
@Candas1 Yes, the code is the same and the calibration is successful.
@dekutree64 Following your advice, I got back to torque mode, which made me changed my understanding of the problem.
In fact the problem occurs on all my devices. As soon as I set both MotionControlType::torque and KV_rating, the motor gets crazy. With MotionControlType::velocity and MotionControlType::angle, everything works fine.
It originally happened on one device only because of my startup sequence: MotionControlType::torque was left as the default value, and I changed it to MotionControlType::velocity a few milliseconds after starting the motor loop. On some device, this delay was enough to trigger the problem, on some other it was not. Setting MotionControlType::velocity at init time was enough to solve the problem.
However, I would like to understand the underlying issue. Is MotionControlType::torque supposed to work with KV_rating? If it is, what am I doing wrong?
As said in my previous post, torque mode should accelerate to full speed with non-zero target and come to a stop with 0 target. Higher target should accelerate more quickly, and very small target may not move at all, or may not reach full speed, but on a tiny motor the differences will probably be too small to notice. As soon as it gets enough current to move, it will zip to full speed almost instantly, and when you set target 0 it will come to a stop almost instantly.
In my case, the motor goes crazy just after init, even with zero target. The target has no effect. If I set the target to zero and stop the motor by hand, it restarts immediately to full speed as soon as I let it go.