I used the information found in this article to set up a rotary position monitoring system for a BLDC motor. The only difference with my setup is that the hall effect sensors in the motor are also being fed into the motor driver to be used for control. Everything seems to work fine if I rotate the motor by hand while the driver is powered. In other words, I grab the motor shaft with my fingers and rotate it and the Arduino tracks its rotation well. The problem comes when I actually drive the motor via the controller. When I do this, the Arduino reports crazy things happening. The rotation usually jumps by huge values and the direction always reports the same, even when the motor is actually spinning in different directions. What might be causing this?
Welcome to the Forum! My first question is which version of Arduino are you using?
The Teensy 3.5 (DEV-14056) used in the article you mention runs at least 7.5 times faster than an Arduino Uno. Depending on which version of Arduino you are running, this may be enough to make the difference, as it may not be able to process instructions fast enough for anything other than very slow motion.
This is running on an Arduino Leonardo which runs at 16MHz. Would you expect that to be too slow? The motor is running at pretty slow speeds (under 20 RPM).
The Teensy 3.5 runs at 120MHz and uses a 32-bit processor rather than 8-bit, which means that in addition to a much higher clock speed, it gets more done per clock. So, it is far faster.
20 RPM’s is pretty slow, but there is a lot that has to get done between Hall readings. Also, with such a low RPM, I would not be surprised if it is geared down, which would mean many more pulses per revolution than the final shaft speed would indicate.
Wow I can’t believe I forgot that the motor was geared. It has a 150:1 reduction. I was thinking that there was no way the speeds I was spinning at could be too fast for the arduino but with that big gear ratio it seems way more likely than I originally thought. I’ll get a Teensy 4.1 and give it a shot. Thanks!