Dual VNH2SP30 MD03A with Arduino: Programming, PWM issues

Hi all,

I’m trying to use the Dual VNH2SP30 board to control two HG312 Geared Motors (http://www.robotmarketplace.com/products/0-HG312.html) and I ran into some troubles about circuit and programming.
I used the simple circuit from the post: Using Dual VNH3SP30 Motor Driver with arduino @ https://forum.pololu.com/t/using-dual-vnh3sp30-motor-driver-with-arduino/1497/1.

I bought two dual VNH2SP30 boards but they came in with crushed capacitors because of terrible handling of the courier. I wired everything according to the diagram shown above, with only 1INA, 1INB, 1PWM, +5V, GND connected to Arduino Duemilanove (ATMEGA328). I tested only one motor at a time and it turned out one is working and another is probably damaged during the shipping. Here are some problems I found:

1)Red Light vs. Green Light:
The motor is running fine and the processor is not over heated but the red LED on the board was on all the time and I’m not sure if it’s a good sign because I assume it is green light that is supposed to be on.

2)PWM doesn’t control the speed of the motor. Should I change the PWM pin frequency on the Arduino?
Here is my code:

int InA1 = 7;
int InB1 = 8;
int PWM1 = 3;  //PWM1 connects to pin 3
int PWM1_val = 127; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup() {
  Serial.begin(9600);
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop() {
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
    analogWrite(PWM1, PWM1_val);
}

3)Base on my circuit, how should I use EN/DIAG and CS pins and how should I program them?

4)For the Dual VNH2SP30 board that is not working. No LED was on when the left side was connected and here is the strange part: when I connected the right part, red LED on the right was on and the motor was not running but the processor on the LEFT side was over heated. Could someone tell me what went wrong?

This is part of project called “SmartSurface” currently in development at University of Michigan. Here is our website: http://www.smartsurfaces.net/Home check it out if you are interested.
Thank you!

Sleepingdust

Hello.

What voltage are you using? The datasheet for that motor indicates a 43A stall current at 12V, which is past the 30A peak limit of the driver. Because the over-current protection can kick in anywhere from 30 to 70 amps, it could account for the unit-to-unit variation you’re seeing.

Therefore, I recommend doing some tests at lower currents. Do you have some smaller toy motors around that you could use? Also, what is your power supply? At these kinds of currents, that and the details of the wiring can be quite important. The LEDs on the motor driver board just correspond to the direction. You could even start your test with just the LEDs (i.e. don’t connect a motor at all). You can use direct connections for the inputs instead of connections to your Arduino: make one direction input high, make the other low, and you should see that making PWM high makes an LED go on. Flipping the direction inputs should change the LED color. You’ll need the main supply and the 5V supply connected during these tests.

The diagnostic and current sense pins are somewhat optional and up to you, though with that size of motor, you could be tripping some of the protection features, so you might want to monitor that line with a digital input. Current sense should go to an analog input if you care to see what the current is doing. You can look at it on a voltmeter if you want to get an idea for what it reads for different motor currents.

- Jan

Thanks Jan,

I used a Digital Single Output DC Power Supply, 30V/1A and I managed to run the motor at about 12V, 0.6A (read from the power supply), very close to the nominal standard for the motor.

For PWM pins, I could only manipulate the speed of the motor to a very small extent. I can’t really tell the difference between the speed @ 0% and 100% duty cycle. I used Serial.begin(9600). Do you think I need to change PWM frequency? Should I expect the motor comes to a stop at 0% duty cycle? I remember the data sheet mention something about that.

I also used Serial.read() to change the duty cycle on the fly. The weird thing is that every time I put numbers that correspond to percentage of the duty cycle, such as 255 (100%) or 64 (25%), It seems the number were “translated” into three sets of number and printed on the serial monitor. Did I use the wrong frequency?

Below is the code I used for Arduino:

int InA1 = 7;
int InB1 = 8;
int PWM1 = 9;  //PWM1 connects to pin 9
int PWM1_val = 255; //(25% = 64; 50% = 127; 75% = 191; 100% = 255)

void setup() {
  Serial.begin(9600);
  pinMode(InA1, OUTPUT);
  pinMode(InB1, OUTPUT);
  pinMode(PWM1, OUTPUT);
}

void loop() {
    digitalWrite(InA1, HIGH);
    digitalWrite(InB1, LOW);
    PWM1_val = Serial.read();
    if(PWM1_val >= 0 && PWM1_val <= 255) {
      analogWrite(PWM1, PWM1_val);
      Serial.println(PWM1_val);
    }
}

-Sleepingdust

Your power supply is not that reasonable for the motor you’re working with.

Have you done the tests I suggested without the Arduino?

I haven’t used an Arduino, so I don’t know what your options are or what the functions do. I don’t see anything about frequency in any of what you posted. What frequency are you using? Is there any reason to expect Serial.read() to know how many characters you’re going to send and then convert them to an integer? Do you have any tools available to look at what the pwm line is doing?

- Jan

Hello,

I’m pretty sure the Arduino doesn’t have an DACs, so isn’t analogWrite going to correspond to a digital output? It’s going to output high for values 1 to 255, and low for 0 probably. In either case, I’m pretty sure the PWM pin can’t take an analog value.

EDIT: I should look up function definitions before I assume they do what their name implies. Apparently analogWrite generates a PWM signal! So you can disregard what I’m saying here.

- Ryan

Hey all,

I just received my MD03A. I’m powering it as described in the product page and am providing 32V in to power the motors.

I’ve checked the PWM value and the INa and INb values. However, my board doesn’t do anything. No lights (with or without the motor attached)

Any ideas?

-B

Ok. So it’s my bad. I neglected to read that the max Vin for the motor is 16V. That’s a shame. My motors prefer to run off of 32V.

I ordered a different hbridge circuit, that should work better.

-B