Speculations on speed limitation for I2C or PWM magnetic encoders

Antun I am just wondering what your thoughts are on using the AS5200/AS5200L which only uses I2c or PWM if I would to implement that into the Library(you probably thought of this already)
What do you think the speed limitations/RPM of I2C or PWM for 3 simulations BLDC motors on the stm32(blue or blackpill) would be?

The AS5200L has plenty of resolution and is quite a lot cheaper

Hey Adam, it is a very good question and I am thinking about implementing the I2C support as well. It is not a huge change (effort) but I was not sure about the number of people actually using it.

The PWM support is also possible, I did not really go much deeper in it.

So regarding the performance, for me the biggest problem of the I2C communication is the electrictro-magnetical noises. I have used it moslty with IMUs before and each time I wanted to make my project small and compact (or just run the I2C wires close to any type of motor) this would generally lead to terrible communication problems. And in our case, the motor and the sensor cannot be closer together.
So I a a bit skeptical in that sense, but in terms of execution time, that will depend of your exact setup. I really do not know how much time would it take to read a value.

What I can tell you is if you can have a loop() running under 2ms ( what is a lot ) you will be fine.

If you have a code of reading the I2C sensor with an Arduino of Bluepill let me know and I’ll try to implement it in future version. :slight_smile:

1 Like

Hey Adam

The highest speed of IIC is 400k. If the delay that IIC must have in the process of writing and reading is not considered, and the operation time of the register is not included, then the time to read or write each bit is (1 / 400 * 1000) = 0.00000 25 seconds, then it will take 0.00004 seconds to read a 16 bit byte = 40us

In addition, the IIC device’s communication process, first write command, then read data, there will be a delay in this process, so roughly estimate, IIC completes a read a 16 bit byte data, and ultimately costs at least 200us (at the highest speed of 400k).

So, when you read very few bytes, I think IIC can theoretically meet the requirement of less than 1ms.

1 Like