Hi!
We recently started doing mechatronics for a school project, and I’m fairly new to this, so sorry if my questions are stupid.
We got a Pololu Dual G2 24v18, but I can’t seem to get it to work. I’ve connected it to an Arduino Uno as a shield, with a 14V battery to the controller itself and uploaded the demo code. It gives feedback to the serial monitor about the current, but I can’t seem to get it to drive motors. The M1 and M2 onboard LEDs won’t light either.
I’ve included the demo code here.
#include "DualG2HighPowerMotorShield.h"
// Uncomment the version corresponding with the version of your shield.
//DualG2HighPowerMotorShield24v14 md;
// DualG2HighPowerMotorShield18v18 md;
DualG2HighPowerMotorShield24v18 md;
// DualG2HighPowerMotorShield18v22 md;
void stopIfFault()
{
if (md.getM1Fault())
{
md.disableDrivers();
delay(1);
Serial.println("M1 fault");
while (1);
}
if (md.getM2Fault())
{
md.disableDrivers();
delay(1);
Serial.println("M2 fault");
while (1);
}
}
void setup()
{
Serial.begin(115200);
Serial.println("Dual G2 High Power Motor Shield");
md.init();
md.calibrateCurrentOffsets();
delay(10);
// Uncomment to flip a motor's direction:
//md.flipM1(true);
//md.flipM2(true);
}
void loop()
{
md.enableDrivers();
delay(1); // The drivers require a maximum of 1ms to elapse when brought out of sleep mode.
for (int i = 0; i <= 400; i++)
{
md.setM1Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());
}
delay(2);
}
for (int i = 400; i >= -400; i--)
{
md.setM1Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());
}
delay(2);
}
for (int i = -400; i <= 0; i++)
{
md.setM1Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());
}
delay(2);
}
for (int i = 0; i <= 400; i++)
{
md.setM2Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M2 current: ");
Serial.println(md.getM2CurrentMilliamps());
}
delay(2);
}
for (int i = 400; i >= -400; i--)
{
md.setM2Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M2 current: ");
Serial.println(md.getM2CurrentMilliamps());
}
delay(2);
}
for (int i = -400; i <= 0; i++)
{
md.setM2Speed(i);
stopIfFault();
if (i%200 == 100)
{
Serial.print("M2 current: ");
Serial.println(md.getM2CurrentMilliamps());
}
delay(2);
}
md.disableDrivers(); // Put the MOSFET drivers into sleep mode.
delay(500);
}