Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Rc ppm to arduino to 24v14 timing issues?

#1

I’m having trouble getting the 24v14 running with this arduino rc ppm code I’ve cobbled together.
it gives me an m1 fault no matter if I have the driver board connected or not.

#include <DualG2HighPowerMotorShield.h>
DualG2HighPowerMotorShield24v14 md;
#define RECEIVE_PIN 2
#define CHANNEL_AMOUNT 8
#define DETECTION_SPACE 2500
#define METHOD RISING

int ch[CHANNEL_AMOUNT + 1];
int move; // Forward/Back speed
int turn; // Turning Factor
void setup()
{
Serial.begin(115200);
pinMode(RECEIVE_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(RECEIVE_PIN), ppm_interrupt, METHOD);
}

void loop()

{
  md.enableDrivers();
  delay(1);  // The drivers require a maximum of 1ms to elapse when brought out of sleep mode.
md.setM1Speed(move);
  //  stopIfFault();

md.setM2Speed(move);
 //   stopIfFault();    

    move = map(ch[3], 1000, 2000, -400, 400); //center over zero

    turn = map(ch[1], 1000, 2000, -400, 400);

    if(turn>0){md.setM2Speed(move-turn); md.setM1Speed(move);};
if(turn<0){md.setM1Speed(move-abs(turn)); md.setM2Speed(move);};


ppm_write();
}

void ppm_write()
{
static unsigned long int t;
if (millis() - t < 100)
return 0;
for (byte i = 0; i < CHANNEL_AMOUNT + 1; i++)
{
Serial.print(ch[i]);
Serial.print("\t");
}
Serial.print("\n");
t = millis();
}

void ppm_interrupt()
{
static byte i;
static unsigned long int t_old;
unsigned long int t = micros(); //store time value a when pin value falling/rising
unsigned long int dt = t - t_old; //calculating time inbetween two peaks
t_old = t;

if ((dt > DETECTION_SPACE) || (i > CHANNEL_AMOUNT))
{
i = 0;
}
ch[i++] = dt;
}

  

sketch_may19b.ino (1.5 KB)

#2

Hello.

In your code, it looks like you are using pin 2 on your Arduino board as an interrupt to detect a PPM signal. If you are using the Dual G2 High Power Motor Driver Shield 24v14 as designed without any modifications (e.g. cut traces or remapped pins), pin 2 on the Arduino is used to control one of the driver’s sleep pin, specifically the sleep pin for motor 1. You might find looking at the table under the “Control and feedback pins” section of the Dual G2 High-Power Motor Driver Shields for Arduino User’s Guide helpful. The table lists the connections between the Arduino pins and the driver pins when the driver is used as a shield.

Also, I noticed in your code that the stopIfFault() functions are commented out. How do you know you are getting a fault on M1 when the G2 High Power Motor Driver (G2 HPMD) shield is not connected?

Have you tried running the unmodified Demo sketch in the DualG2HighPowerMotorShield library with your setup? I recommend running the example first (if you have not already) to verify that your setup is working with just the G2 HPMD shield and letting us know the results of the test. Additionally, can you post pictures showing how everything is connected in your system and close-up pictures showing the soldering on your G2 HPMD shield? Also, what are you using to power all your devices?

- Amanda

#3

Thanks for pointing the pin usage out. I have tried the example code and also used the code as it is (minus the RC code) with an analog joystick mapped accommodate the driver boards -400 to 400 this worked correctly. The fault code was omitted for testing.

I guess I’ll have to rework it to an available interrupt pin and try again.

#4

after reassigning the input pin to digital 3 interrupt 1 it still gives me the same error. I switched to an uno and a new driver board as the original driver board failed first time testing a previous version of the code.
on this new setup I have ran the demo code and it works fine driving the motors forward and reverse as it should, I have not tried this updated code with the driver board yet as it fried it last time (previous code) but trying it with just the uno and rc receiver it gives me the m1 fault code still. do i have to have the driver board hooked up to test the code?

sketch_may19b.ino (1.7 KB)

#5

Sorry we missed seeing your post and for the delayed response.

It looks like you forgot to call md.init() in your setup() function in your code, which enables the internal pull-up resistors for the two fault lines (!M1FLT and !M2FLT) as well as configures the correct pin modes for the rest of the motor driver’s pins. Can you add that line to your code and try running it again without the driver connected? Please let us know the outcome.

- Amanda

#6

Thank you, I will try that shortly… sorry I’m still quite a newb with the Arduino coding.

#7

ok the good news is that fixed the issue. bad news is it ran for a second and stopped. this fried the uno and caused the driver board to put out m1 fault again (after installing a new uno). I think I found the issue though, these motors are reading .37 ohms this comes out to over 60 amps at 24v.

new question is will this driver board run these if current limiting (is that a thing)is applied?

#8

It sounds like you might not know that the dual G2 HPMD shield has an active current limiting feature. (You can find more information about current limiting from this Wikipedia page.) By default, the active current limiting threshold for the dual G2 HPMD 24v14 shield is approximately 40 A and can be adjusted lower by connecting an additional resistor between the VREF pin and the adjacent GND pin. (You can find that information in the motor driver’s user’s guide under the “Control and feedback pins” section.) The current limiting feature is practical for cases where the motor might draw only a few amps while running but can draw many times that amount when starting, however, your motors sound like they’re much higher-power than what we would recommend our G2 HPMD (and controllers) be used for. I suggest looking at the RoboClaw Motor Controllers, specifically the RoboClaw 2x60A Motor Controller (V6) version, which is probably better suited to run your motors.

- Amanda