Hi Pete,
I think this is a very common observation, and generally also my experience. It’s more with some motors and less with others.
Not knowing more about your setup I would agree that this is a good explanation. You could further test it if you add some weight (well centred) to the motor.
I think cogging is a good candidate. Other candidates include:
- off centre mounting of either the sensor or the magnet
- mechanical inaccuracies of the motor, e.g. in the bearing
- sampling issues
- sensor noise (which we agree should be less than the error you’re observing)
- PID tuning issue
Playing with the PID and LPF can make quite a difference. In an project I’m working on that is aiming for smooth, constant speed rotation tuning the PID and LPF reduced the velocity errors from about 5% to 0.5%.
But of course raising the filter too much makes the system less responsive to changes, so it depends on your needs and application.
Cogging should show up as a regular pattern in the velocity, that repeats in the same way for each rotation. If it is cogging it should also mean that the speed measured at lower bandwidth (e.g. below the time needed for one rotation) should be more stable, while the speed within one rotation is “wobbly”…
Sampling issues (from my point of view) are caused by things like the lag you have over SPI, and the fact that we’re not running in exactly constant time-steps. Of course we account for the time in the algorithms, but doing so requires using the MCU’s clocks to measure time, which aren’t 100% accurate and are themselves subject to sampling effects.
So in sum you have inaccuracies in the measurements (due to lag, sensor error, etc) and inaccuracies in the timestamps, both of which are fairly small quantities (since we have high loop frequencies), and which are differentiated to obtain delta-Timestamps and delta-Angles. IMHO this situation can easily lead to cases where errors in velocity get amplified, and small amounts of position-jitter lead to large errors in the velocity signal.
I’ve been thinking for a while about ways to mitigate this, if indeed this is the problem people are having.
Unfortunately the AS5048A only has SPI output, so you will need a second sensor if you want to measure the velocity independently of the SimpleFOC code… with some other sensors you can use their other outputs “in parallel” to measure the velocity from another MCU/computer. Or you can use SimpleFOC monitoring to get a picture of what’s going on, but this is not ideal because the monitoring output affects the system’s performance, and also the output can only sample the signal at a much lower rate due to Serial speed limits.
Please let me know any results you find, or if you have any further questions 