Because the sensor does not require a command to read the angle. Every 16 bit read contains the angle - unless it is the response to a register read/write request.
For me - commenting out this block improves main loop performance from 4kHz to 9.6kHz.
Could we have a flag in MagneticSensorSPIConfig_s for āDonāt write commandā, where it skips this block?
Something similar was discussed whereby the library remembers the previous command (register) and if new read is for same command then it know that the SPI read contains correct data so only one transfer16 is needed. There were concerns that this might lead to sample read being prepared on last loop/sample and thus being āoldā but this was speculation.
Iām about to launch into a refactoring of the sensor code. MagneticSensorSPI will be refactored in this process. There is also a problem with STM32 chips in that code.
Thanks for finding that - I will try to include that change, but the MagnetSensorSPI class has to be kind of generic and general, so it probably wonāt be the optimal solution for any given sensor.
I have a bunch of sensors lined up for testing (either on my desk or arriving from PCBWay or Mouser this week ):
It would be great to see a comparison of all the sensors and see how much difference a sensor makes to SimpleFOC. Maybe run them all with the same motor, and also have the most precise known sensor also attached to the motor - recording jitter, velocity?
(2021 SimpleFOC sensor roundup )
I was planning to use the same MCU, same driver, same motor and same magnet throughout the tests. The code has to necessarily be a bit different for each sensor, but that is part of what gets tested in the end. A sensor will only be as good as the code that reads it.
I will try to make the sensor diagnostic information available in the driver implementations, so obviously the sensors own diagnostics and error measurements are one data-point to collect.
The maximum attainable speed in open-loop and in velocity mode would also be interesting, to see if the sensor introduces any limitation (e.g. like the MA730 seems to).
But Iād really appreciate it if people have ideas for what/how to test and measure.
For example, I was thinking about whether the jitter could be measured optically, for example with a laser pointer or mirror attached to the motor. I havenāt come up with a good plan for that yet though.
I think a ĪAngle-ĪTime scatter-plot might be interesting, kind of showing the discretisation and error on the time and angle at the same time. I would expect certain characteristic patterns to emerge depending on the control-mode, MCU loop speed, MCU timer resolution, sensor resolution and sensor stability.
For example good sensors in position mode would have all the points near zero, probably in 2 small clouds to either side, as the motor vibrates around its set-point. Bad sensors would have this cloud more random and spread over larger areas.
Discretization problems might show as visible bands/concentrations of the points. And āoutliersā would indicate communication issues, timer issues, numerical precision issues, and other things that cause unexpected zero or out-of-band values.
Iām really interested in the ideas people have, and would be more than willing to run peopleās code on a bunch of different sensors - so if anyone wants to send me something that they want tested, please feel free!
@runger - Iām very excited to hear you are taking this on!
A couple of ideas.
effective resolution - whilst a sensor may say it is 14 bit, sometimes the last 2 bits are just noise!
max sample rate - related to spi/i2c clock speed but there might be some faster sensors. Can sensors speed be traded with resolution.
hardware velocity register - some sensors e.g. ma730 allow you to read velocity. This has the potential of being less noisy. Unfortunately the scale is often not great e.g. rubbish resolution at slow speed.
Lowest stable Tf whilst when PID is tightly tuned. Some sensors seem to work with 0.0001 Tf others (AS5600) is more like 0.05.
Look at measured velocity standard deviation at constant speed 5 rad/s with fixed or zero Tf.
Ok this is very āfrom the left fieldā but, hereās a a idea: use a mouse sensor for quasi static tests. Some mouses have awesomely precise optical sensors.
To evaluate sensors you need a gold standard.
For dynamic tests, optical encoders are great but that implies a complicated quadrature decoding setup
Any update on this topic? Looking into using either the AS5048A, AS5047U, or AS5047D for accurate angle measurement. Is the code for reading the data and configuring the sensor using SPI roughly the same?
Iāve used all three, and they all worked well and were easy to use. Thereās some differences between them, I believe the AS5047U is the ābestā due to its filtering features.
The AS5047 in general has the advantage of also offering ABZ as well as SPIā¦