For one of my robots, I am using the Feetech SG90 microservo with DRV8835 dual motor shield…When I set the DC motors at max or any intermediate speed they function fine. But when I set any of the motor speed to be zero, or both motor speeds to be zero the DC motor/motors instead of being stationary, still run at low speed.
I included the servo library in my code and the microservo is connected to a digital pin on the Arduino which isn’t used by the motor shield.
I don’t know why it is behaving this way, can anyone please help me out with this?
Thanks in advance.
If you are using the Arduino library for the DRV8835 Dual Motor Driver Shield and the Arduino Servo library, you are likely seeing a conflict since they both use Timer 1.
Depending on which Arduino you are using, you might be able to use the examples shown in the Zumo shield’s user’s guide for controlling a servo without the use of Timer 1. If you are using an Arduino Uno, the “Controlling a servo with an Arduino Uno” section of the Zumo shield’s user’s guide shows how to control a servo with Timer 2. If you are using an Arduino Leonardo (or A-Star 32U4), the “Controlling a servo with an Arduino Leonardo or A-Star 32U4 Prime” section shows how to modify the Servo library to use Timer 3.
Thank you Brandon for your reply.
I forgot to mention this earlier, I am using an Arduino UNO. Is there any way I can control the DC motors using the DRV8835 with the PWM code instead of using the DRV8835 library?
I am not sure what “PWM code” you are referring to. Can you be more specific about what you are asking?
By PWM code I meant that the code we use for controlling the speed and direction of two dc motors when connected via an H bridge.
So my question was instead of using the DRV8835 library is there some way by which I can use the regular code(mentioned above) to run and control the motors via DRV8835 motor shield.
It sounds like you might be confused about how our Arduino library for the DRV8835 shield works. It uses PWM signals for controlling speed and digital high and low signals for direction like you described; the PWM signals are set up by configuring Timer 1. I am not sure what you mean by “regular code” but you could certainly write your own code that doesn’t depend on Timer 1 to control the DRV8835 shield.