Magnetic Encoder Speed Limit

First off, this community has been very helpful. Thanks to everyone involved here. I’m currently working on converting a project from a DC gearmotor to BLDC and looking to use magnetic position sensing for a number of reasons. I have never used magnetic position sensors before. My concern is this note on the hardware page:

Encoder CPR: Rule of thumb for Arduino UNO

For Arduino UNO, the maximum number of pulses/second should not exceed 20,000. After this value it start to have execution issues. Please take this in consideration when choosing the encoder and especially if using more than one motor.


If your CPR value is 10000, you will be able to spin your motor with max velocity 120rpm - 2 rotations/second

For my application, I need to achieve about 250rpm, but also smooth control near 0rpm. For the AS5047U with 16384CPR, 250rpm would create 68,000 pulses/second, which is far too many per the above note. I also want to avoid adding a secondary shaft and gearing to read the position.

My understanding of the sensor is that it is “absolute” and outputs a voltage from 0 to supply corresponding to its position, unlike other incremental encoders. Do I need to worry about breaking the speed limit with the sensor? Is there a way to configure the sensor to use less pulses? How would you go about using a magnetic encoder at 250RPM?

Thank you,

The AS5047u supports ABI, SPI and PWM modes. i.e. you have at least 3 ways of getting hold of the angle data.

In your first paragraph you are right if you use it in ‘encoder mode’ i.e. using the ABI interface. This works identically to optical encoders. You’d typically use an interrupt to detect each pulse. Whilst the magnetic sensor is capable of absolute measurements - using ABI, you are losing this information. I therefore wouldn’t recommend ABI when you have better alternatives.

In the second paragraph you have switched to talk about ‘analog mode’ which some sensor support. I don’t think the AS5047 supports analogue but it does support PWM which I guess is similar. Again you’d probably use an interrupt and this time would measure the duty cycle and frequency of PWM signal. From that you’d get an absolute value. The Analog or PWM interfaces are going to introduce additional errors as you have a conversion from digital to analog and then back again. So again, I’d prefer an all digital interface. Also SimpleFOC doesn’t support PWM mode yet.

Magnetic sensors typically support I2C or SPI. The AS5047U support SPI. This is a 4 wire interface (SCLK, MOSI, MISO, CS) + vcc and gnd. Sounds complex but it isn’t too bad. Finding out which pins to use for your board is the hardest part. So with SPI you are getting the actual digital values read by the sensor and you get them whenever you request them (you’re not counting pulses!). A fast mcu will be able to read 10,000+ times a second - but as it’s busy doing complex FOC maths typically only reads 800-5000s of times a second (depending on performance of chip). The speed will remain accurate at high speeds until you get close to 1 read per second (I’d like to read 3+ times). So lets say we were using a crappy atmega328p (like on the uno) then the loopFOC() could manage 800 loops (and sensor reads) per second. Then we might be able to get reasonable speed accuracy up to 800 * 60 = 4800rpm. Amy faster than that we are in danger of missing entire rotations!

Excellent. I will buy my hardware with the intention of using SPI. Thank you very much Owen. Keep up the great work.

What board are you going to use? Are you starting with a SimpleFOC board? Pairing the BLDC drivers / MOSFETs with your (hopefully low Kv) motor requires a bit of research.

There are some good info on the hardware page:

1 Like

I will use an UNO with the SimpleFOC Board. I noticed that the iPower brand is sold at iFlight with the AS5048A already mounted: iPower Motor GM3506 Brushless Gimbal Motor w/ AS5048A Encoder
I’ve seen a lot of use of these iPower motors on this forum and they look quite nice. Have you had experience with the pre-mounted magnetic encoder version? I am thinking this would be convenient.

I see the internal resistance is marked as 5.57Ω. There is a note on the hardware guide that gimbal motors are >10Ω. Would this cause problems?

They report the torque as 600-1000 g cm or 0.059-0.098Nm. My motor will be driving a spool of cable tensioned from the opposing end with 2.3N, so I just need to keep my spool diameter under 50mm to overcome that force at the high end of speed where I assume the minimum torque occurs. I am wondering now about where they get the 600-1000 g cm values. I am assuming that is the min and max torque at 12V 1A inside their max RPM. Also, I was considering downsizing to the 2208 90KV Gimbal motor but I cannot find torque specs on that one.

Hi @bruhman

It will not, just make sure you set an appropriate voltage limit and an appropriate voltage to align the rotor as to not draw more than 1 amp.
Something like:

//BLDC motor power supply voltage
motor.voltage_power_supply = 12;
// Aligning voltage
motor.voltage_sensor_align = 3;
//Voltage limit - 5V/5.57ohms = 0.8976 A
motor.voltage_limit = 5;

I see there is no KV rating for this motor, but you should be able to calculate the theoretical torque of a brushless motor with the following equitation:

Torque [Nm] = (60/2PI)(I[A]/KV)

Keep in mind that motors are far from ideal so consider the torque to be around 80% of what you calculate.

1 Like