Hi All,
I’ve started playing around with a BLDC motor that I have laying around and am doing the following:
Hardware:
Arduin Uno + SimpleFocShield v2.
Steps:
- I run the example: voltage_control
- In void_loop i’ve added: Serial.println(encoder.getVelocity()) and changed the function slightly to show ‘pulse_per_second’ to rule out if it had to do with cpr/ppr mismatch.
- I’ve also added my scope to the AB signals of the encoder.
Outcome:
Ony my serial monitor the pulse_per_second → ~16500-18500 pulse/s
On my scope I see a period of 160 us → 4pulses/160us = 25000 pulse/s
This is a geared motor and if I measure the revolution time of my output shaft, the calculation of the scope is correct. Any idea’s where the issue could lie? Is the Arduino Uno not fast enough?
Edit: my calcs / scope reading
Regards,
Jeroen
Please output the motor.shaft_velocity
not the encoder.getVelocity()
.
When using the sensor with the BLDC motor the encoder is used to update motor variables and the velocity is calculated inside as well.
The getVelocity()
is measuring the time in between the calls and it is called once in motor.move()
and if you call it once more in the loop()
the time in between two calls is not long enough to measure the velocity correctly. 
So use rather:
Serial.println(motor.shaft_velocity);
1 Like
BTW. 20,000+ impulses per second is a lot for Arduino UNO. In my experience Arduino will start having problems around 20,000 interrupts per second.
Thant also could be the issue. 
What is your enconder impulse count and what is the speed that your’re spinning the motor?
When the issue is the arduino uno’s processing performance (too many interrupts per second) then, as the arduino has too many interrupts to handle it doesn’t measure the time well and that might the be the reason of the wrong count per second number.
Hi, thanks a lot, this did the trick. I was not aware the position was already called in the motor.move() function. I also noticed that that the getVelocity call inside the move() function uses a low pass filter, that is also nice to smooth the data bit.
After your first reply I also found this rule of thumb somewhere on the site! I do seem to get a bit smoother result as I go slower. Currently I have roughly 23000 count/s, it doesn’t seem to give a problem yet. My target voltage is already set to 1.5V, if I go much lower the motor also doesn’t seem to like it.
The high count has to the with the required shaft output after a 66:1 gearbox reduction.
I also have an ESP32 laying around, I may give that one a go to see if it improves. But currently happy with the results! One step at the time 
Thanks again for your help.