Hi,
I’m using the dual MC33926 motor driver shield with arduino uno to power 2 linear actuators for a standing desk. I’ve used 2 toggle switches to change direction of either linear actuator.
When I connect the 12V (6A) power source to the shield and run the program, the LEDs on the shield light up as expected on the board and the M1A/M1B terminal runs one linear actuator perfectly. However, the M2A/M2B terminal only provides 4V when I try to use it (LEDs still light up) so the 12V linear actuator does not work. I’ve switched the two linear actuators over and it is the same result for the M2A/M2B terminal.
What can I do to troubleshoot?
Code:
#include "DualMC33926MotorShield.h"
DualMC33926MotorShield md;
//add toggle switch states to arduino pins
const int LEFT_UP = 11;
const int LEFT_DWN = 13;
const int RIGHT_UP = 2;
const int RIGHT_DWN = 3;
// fault program from sheild demo
void stopIfFault()
{
if (md.getFault())
{
Serial.println("fault");
while(1);
}
}
void setup()
{
//define pin modes for toggle switches
pinMode(LEFT_UP, INPUT);
pinMode(LEFT_DWN, INPUT);
pinMode(RIGHT_UP, INPUT);
pinMode(RIGHT_DWN, INPUT);
// from sheild demo program
Serial.begin(115200);
Serial.println("Dual MC33926 Motor Shield");
md.init();
}
void loop()
{
int L_UP; //variables for loop, int makes analogue pins digital
int L_DWN;
int R_UP;
int R_DWN;
L_UP = digitalRead(LEFT_UP); //to read the pin states
L_DWN = digitalRead(LEFT_DWN);
R_UP = digitalRead(RIGHT_UP);
R_DWN = digitalRead(RIGHT_DWN);
Serial.print("M1 current: ");
Serial.println(md.getM1CurrentMilliamps());
Serial.print("M2 current: ");
Serial.println(md.getM2CurrentMilliamps());
Serial.print("Left Up: ");
Serial.println(L_UP);
Serial.print("Left Down: ");
Serial.println(L_DWN);
Serial.print("Right Up: ");
Serial.println(R_UP);
Serial.print("Right Down: ");
Serial.println(R_DWN);
if(L_UP==LOW && R_UP==HIGH && R_DWN==HIGH){
md.setM1Speed(400);
md.setM2Speed(0);
stopIfFault();
Serial.print("LEFT_UP");
}
else if (L_UP==LOW && R_UP==LOW && R_DWN==HIGH)
{
md.setM1Speed(400);
md.setM2Speed(400);
stopIfFault();
Serial.print("LEFT UP");
Serial.print("RIGHT UP");
}
else if (L_UP==LOW && R_UP==HIGH && R_DWN==LOW)
{
md.setM1Speed(400);
md.setM2Speed(-400);
stopIfFault();
Serial.print("LEFT_UP");
Serial.print("RIGHT DOWN");
}
else if(L_DWN== LOW && R_UP==HIGH && R_DWN==HIGH){
md.setM1Speed(-400);
md.setM2Speed(0);
stopIfFault();
Serial.print("LEFT DOWN");
}
else if (L_DWN==LOW && R_UP==LOW && R_DWN==HIGH){
md.setM1Speed(-400);
md.setM2Speed(400);
stopIfFault();
Serial.print("LEFT DOWN");
Serial.print("RIGHT UP");
}
else if (L_DWN==LOW && R_UP==HIGH && R_DWN==LOW){
md.setM1Speed(-400);
md.setM2Speed(-400);
stopIfFault();
Serial.print("LEFT DOWN");
Serial.print("RIGHT DOWN");
}
else if(R_UP==LOW && L_UP == HIGH && L_DWN==HIGH)
{
md.setM1Speed(0);
md.setM2Speed(400);
stopIfFault();
Serial.print("Right Up");
}
else if(R_DWN==LOW && L_UP==HIGH && L_DWN==HIGH)
{
md.setM1Speed(0);
md.setM2Speed(-400);
stopIfFault();
Serial.print("Right Down");
}
else {
md.setM1Speed(0);
md.setM2Speed(0);
stopIfFault();
}
delay(2000);
}