I am using 2x VNH5019 motor drivers (#2507) with an Arduino Mega to drive 3x 37D gearmotors with encoders (#2507) at 12V. The code I am using is relatively simple, comparing current encoder position with a “set point,” and spinning the motor in the right direction until the “set point” has been reached within a given tolerance. When it is 2.0 and 0.5 turns away from the “set point” respectively, the motor will slow down to a slower and then minimum speed. Originally, this was working perfectly and I was able to get the motor to seek my “set point” within a tolerance of 5 counts.
Because I am planning to have a eventually have long connection between the drivers and the motors (~15 feet of wire), I then soldered two additional 330uF 35C capacitors (#882) onto each driver, as well as a 0.1uF ceramic (#2451) across the poles of the motor. However this is when my issue started.
Now, running the same code, once the motor has neared the “set point,” it begins to bounce, oscillating between backwards and forwards 3-5 times before stopping. Right now, it will still settle and stop eventually, but if I increase the minimum speed it will seemingly oscillate indefinitely.
My guess is that adding capacitance to the system has created an lag between the Arduino issuing commands and them reaching the motor, which might be causing the oscillations. Is that likely? Is there another explanation, and/or workaround for this?
So far I have tried (with the issue persisting):
- Decelerating the motor earlier, further away from the “set point”
- Increasing the tolerance around the “set point”
- Decreasing/increasing the minimum speed
I am using the updated Arduino library specifically for driving 2 of these shields (DualVNH5019MotorShieldMod3). While I have shuffled around some of the GPIO pins, the PWM pins remain at their defaults.