Random Direction Switch - High-Power Motor Driver 18v15

Hi There,

I have exhausted my capabilities trying to solve this problem, so hopefully someone can help.

The problem: Using the 18v15 driver my motor will randomly switch directions (without me touching wires or anything of that sort).

The setup: Using an R3 Arduino Uno I have the driver connected. The driver GND pin is connected to my Arduino GND pin. The driver PWM pin is connected to a PWM pin on the Arduino. The driver DIR pin is connected to another digital pin on the Arduino. Motor and Power supply are connected.

The code:

int DirPin = 2;
int RefPin = 9;

void setup()
{
    pinMode(DirPin, OUTPUT);
    pinMode(RefPin, OUTPUT);
}

void loop()
{
    analogWrite(RefPin, 30);
    digitalWrite(DirPin, HIGH);
}

Things I’ve tried:

  • Pretty much all the various PWM and digital pins.
  • A different Arduino.
  • A different 18v15 driver.
  • Connecting the DIR pin of driver to either GND or 5V on Arduino. In both cases the motor is rock solid.
  • Different wires.
  • Measuring the Motor input. The absolute voltage is always solid but the polarity changes (obviously).
  • Soldered wires directly into the driver board to make sure there was no flaky signal.

So I’m hoping someone can help me resolve this issue. It is very strange behaviour indeed.

Thanks!

Hello.

Can you post an in-focus picture of your setup that lets us verify all your connections, and possibly another one of your solder joints? How are you powering everything? Do you know the stall current of your motor? When the direction of the motor changes, how long does it continue spinning in the new direction? Does the speed stay the same when the direction changes?

- Ben

Hi Ben,

I will post a picture tomorrow morning as soon as I get back to the office. I would like to think the solder joints are good as I’ve tried a couple Arduinos (with the stock soldering of course) and a couple of drivers with my own soldering, of course could be a coincidence!

Right now the driver is powered off of a 12V-10A power brick (can’t remember the brand). The arduino is powered via a USB from my laptop and the laptop is connected to the same wall socket as the power brick, so there is a common ground through it all on the AC side. Stall current of the motor is way up at 85 A (from BaneBots: http://banebots.com/pc/MOTOR-BRUSH/M5-RS550-12). The no load current however is down at 1.4A, in these tests I would be running the motor with minimal load (just the friction throughout a 16:1 BaneBots gearbox).

The direction changes are very random. Occasionally it will change rapidly and the motor will sort of grind at a halt moving slightly in each direction. Other times it might spin 10s one way and 5s the other way.

At any point, once it starts moving in a direction the speed is very constant and measuring the motor voltage at the terminals shows a very steady voltage. This is what makes me think that the PWM pin is alright but the DIR pin is… off.

One other note. Earlier today I had it in a stage where moving my hand anywhere close to the signal wires appeared to trigger a direction change (and I definitely didn’t touch the wires!). When my hand was close it would spin the wrong way, when my hand was removed it would spin the right way. This makes me feel like there is some lack of pull up as this is the same behaviour I would see if I just left the direction wire floating.

Anyhow, I will post up the pictures in the morning.

Cheers.

Hi Ben,

Here are some pictures of the setup and soldering.



Alright well I seem to have resolved the issue and I feel pretty dumb on this one. The code I put up in my OP was written from memory (always a bad idea I guess). Anyhow, the real code back in the office had:

pinMode(OUTPUT, DirPin);
pinMode(OUTPUT, RefPin);

Instead of the correct:

pinMode(DirPin, OUTPUT);
pinMode(RefPin, OUTPUT);

This of course is a terrible mistake! In the first case I am not even enabling the correct pins. Not sure what the Arduino’s behavior is expected to be but it seems to explain the random things I was seeing.

Thanks for your time.

I’m glad you figured things out, and thanks for letting us know what the problem was. It really sounded like you had a floating pin or a ground issue somewhere, but I wasn’t seeing anything from your pictures or code.

- Ben