I had assumed since Cerberus has 4 PWM sockets that it would be possible to use more than 1 motorControllerL298 at a time on the same board.
I’m trying to drive 4 motors on a Dagu Rover 5 chassis, and I’m only able to get a single module functioning at a time. If I plug in both modules, only 1 will work (I think whichever one was initialized last).
Here’s the code I’m using (I’m using the IR receiver module for control):
void irreceiver_IREvent(object sender, IR_Receiver.IREventArgs e)
{
switch (e.Button)
{
case 11: // ignore AV/TV button
break;
case 12: // Power button - stop motors if they're running
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, 0);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, 0);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, 0);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, 0);
break;
case 13: // Mute button - spin;
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, -100);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, -100);
break;
case 16: // Right (vol) button - slide right
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, -100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, -100);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, -100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, -100);
break;
case 17: // Left (vol) button - slide left
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, 100);
break;
case 32: // Channel Up button - forward
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, -100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, -100);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, 100);
break;
case 33: // Channel Down button - back
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor1, 100);
motorLeft.MoveMotor(MotorControllerL298.Motor.Motor2, -100);
motorRight.MoveMotor(MotorControllerL298.Motor.Motor2, -100);
break;
default:
break;
}
}
Here’s the initialization code for the modules:
private void InitializeModules()
{
// Initialize GTM.Modules and event handlers here.
motorLeft = new GTM.GHIElectronics.MotorControllerL298(3);
motorRight = new GTM.GHIElectronics.MotorControllerL298(4);
irreceiver = new GTM.GHIElectronics.IR_Receiver(7);
}
Any notion what’s wrong?