I have 2 motors (JGA25-370) with hall-sensor encodes. They emit about 90-100 interrupts every 100ms, so 1000 a second. Which means I have an interrupt happening every 1ms.
The motors are driven by PCA9685 PWM board and L298N H-Bridge driver.
It's all being operated from Raspberry Pi using a program written in Rust. It starts 2 threads for sysfs interrupts and emits events when rising edge is detected.
Now, the problem is that the readings are not as consistent as I expected. I have another thread where I take measurements every 100ms. This is an example of the results:
90
81
90
90
85
90
89
79
89
89
79
87
80
88
90
90
79
89
The motor is not under any load, just holding it in my hand.
The problem for me are those random jumps from 89 -> 79 -> 89 event though the motor is not under load (except for a built-in gearbox). It makes PID control very hard when I'm adjusting for a 10% drop, but the motor did not slow down.
So I guess my questions are:
1. Is it just a normal thing and hall effect sensors are just not that precise?
2. Is it caused by Raspberry Pi not being able to handle interrupts in an accurate manner?