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

Pololu Forum

G2 High-Power Motor Driver 24v14

Is there any condition to cause the shield + A-Star 32U4 Prime SV to fault when not powered and no motors attached? I loaded some code derived from the github demo code which caused a blue led to light up and now the 32U4 is bricked. The code didn’t access any pins directly, all it did you flip M1 every 3 seconds and some of the enable drivers/ set speed moved to setup(). Could it be stuck in an infinite loop when calling the demo fault function?

Hi, jba.

Sorry to hear you are having trouble with your motor driver shield and A-Star. Did both boards initially work fine for you? Could you post the program that you tried running as an attachment or in a code block, and could you also post some pictures showing your setup and how you have everything connected? How are you powering your system?

Are you able to program the A-Star if you disconnect the motor driver shield? If not, could you also try following the procedure described in the “Reviving an unresponsive A-Star” section of the user’s guide to see if it works?

Kevin

Thanks Kevin,
Don’t worry to much about resolving the issue it annoying but hardware failures are expected sometimes. I just wanted to ensure the program cannot destroy the A-Star.
I don’t have access to the device, I send the code over email. The device was working with the github demo code as soon as this code was loaded it bricked - at least appears to be. The only thing I am concerned is I don’t disable the drivers like in the demo code. I don’t think that should be an issue.


#include "DualG2HighPowerMotorShield.h"

// Uncomment the version corresponding with the version of your shield.
DualG2HighPowerMotorShield24v14 md;

void stopIfFault(const char * str)
{
  if (md.getM1Fault())
  {
    md.disableDrivers();
		delay(1);
    Serial.println(str);
    while (1);
  }
  if (md.getM2Fault())
  {
    md.disableDrivers();
		delay(1);
    Serial.println(str);
    while (1);
  }
}


unsigned long M1_timing = 0;
unsigned long M2_timing = 0;
const int max_duty_cycle = 400;

void setup()
{
		Serial.begin(115200);
		Serial.println("Dual G2 High Power Motor Shield");
  
		md.init();
		md.calibrateCurrentOffsets();

		delay(10);
	
		md.flipM1(false);
		md.flipM2(false);
		
		md.enableM1Driver();
		delay(1);  // The drivers require a maximum of 1ms to elapse when brought out of sleep mode.

    md.setM1Speed(max_duty_cycle);

    stopIfFault("Setting M1 speed to max");

		M1_timing = millis();
}


const int amp_steps[] =           { 500,1000,1500,2000};
const unsigned long amp_time[] =  {6000,4000,3000,2000};
const int data_len = sizeof(amp_steps) / sizeof(int);
const int max_M1_milliamps = 3000; 
const unsigned long M1_flip_time = 3000;
const unsigned long M1_flip_back = M1_flip_time + 4000;
const int M2_max_duty_cycle = max_duty_cycle*0.4;

bool M1_dir = false;

void loop()
{
		
		unsigned long now = millis();

		if(now - M1_timing > M1_flip_time && !M1_dir ) {
			Serial.println("Switch M1 after 3 seconds");
			M1_dir = true;
			md.flipM1(true);
		}

		if(now - M1_timing > M1_flip_back) {
			Serial.println("Switch M1 Back after 3 seconds");
			M1_timing = now;
			M1_dir = false;
			md.flipM1(false);
		}

		int m1_amps = md.getM1CurrentMilliamps(); 
		
		if (m1_amps > max_M1_milliamps) {

				stopIfFault("M1 Current Over Max Amps");
		}

		for (int i = 0; i < data_len; ++i) {
			if (m1_amps <= amp_steps[i] && M2_timing !=0 ) {
				md.enableM2Driver();
				delay(1);
				
				M2_timing = now + amp_time[i];
				md.setM2Speed(M2_max_duty_cycle);
				stopIfFault("Setting M2 speed to max");
				break;
			}		
		}

		if(now > M2_timing) {
			M2_timing = 0;
			md.disableM2Driver();
		}
}

Could you explain more about what you mean by “bricked”? Is the system no longer driving the motors, is the A-Star not responding to attempts to load a new program (in which case the procedure I mentioned in my last post would be appropriate to try), or something else?

I didn’t look too carefully at your code, but one possible issue that stands out to me is that in this block:

		if(now - M1_timing > M1_flip_time && !M1_dir ) {
			Serial.println("Switch M1 after 3 seconds");
			M1_dir = true;
			md.flipM1(true);
		}

you are not updating the value of M1_timing, which means once M1_flip_time has elapsed, that block will start being executed every loop iteration. Trying to print too much and too quickly over serial can result in the A-Star becoming unresponsive, so that might be the cause of your issue.

Are you able to load our example program back onto your A-Star and get it to work again? If so, I would suggest starting from that and making smaller incremental changes toward the behavior you want so that you can check it is still working at each step.

Kevin

Thanks Kevin,
Really appreciate it.

I am flying blind just like you are, I simply emailed my code to someone else and they reported back that when they uploaded my code a blue led light came on on the G2. When they went to load the previous example code they couldn’t and it wasn’t being detected by the computer, so it looked like the code I posted 'bricked the A-Star - whether it is I don’t know but they are adamant they cannot upload anymore.

I was told no external power-supplies or motors were connected when the code was uploaded. They were planning on just looking at the LED which indicate direction.
The println statements were not in the code I sent them, that was just for my testing purposes. The M1_timing = now get evaluted in the next if statement. The timing is not exactly a three second cycle as the print statement suggests.

As long as you think the posted code is safe and there nothing inherently dangerous I am satisfied.

They are sending me the A-Star - they bought another one. If you want I can provide comprehensive information for possible quality issues later if I can repeat the behavior of course.

From what I saw, I don’t think there’s anything inherently problematic about your code that would lead to hardware damage. If you are able to continue troubleshooting later and find out more about the problem, please let us know.

Kevin