So, I bought a DRV8835 (from one of your Canadian distributors). I plugged it into a breadboard I have set up with an Arduino Nano, a servo, a pot, and a 5 volt regulator.
The whole thing is run off a 7.4 volt Lipo, which feeds into the 5 volt regulator (1 amp, switcher). The 5 volt output from the regulator (I’ll call it Vcc) powers both the Nano, and the servo. It also feeds into Vcc on the DRV8835, but I had BATT+ going into Vin.
The code looks like this:
#include <Servo.h>
#include <Metro.h>
#define POT_PIN 0
#define MOTOR_PWM_PIN 5
#define MOTOR_DIR_PIN 4
#define RUDDER_SERVO_PIN 3
#define LED_PIN 13
Servo rudder;
Metro heartbeatTimer = Metro(250);
int ledState;
void setup() {
rudder.attach(RUDDER_SERVO_PIN);
digitalWrite(MOTOR_DIR_PIN, 0);
analogWrite(MOTOR_PWM_PIN, 0);
ledState = 0;
}
void loop() {
int potPosition = analogRead(POT_PIN);
int servoAngle = map(potPosition, 0, 1023, 0, 180);
int motorSpeed = map(potPosition, 0, 1023, 0, 255);
rudder.write(servoAngle);
analogWrite(MOTOR_PWM_PIN, motorSpeed);
if (heartbeatTimer.check()) {
digitalWrite(LED_PIN, ledState);
ledState = !ledState;
}
delay(50);
}
I powered it up, and the motor started running for a few seconds, and then stopped. After that, it has been completely unresponsive. I checked, and I’m definitely getting PWM input into BENBL, and BPHASE is low. I also tried switching channels (from B to A), but the results were the same (nothing).
The motor I’m using is a Tamiya motor from one of their submersible pods. It does not have any gearing, and there shouldn’t be a lot of load on the motor, so the current shouldn’t be too high.
Should I be adding some protective diodes on this setup?
- Jon