Main Site Documentation

Problem of Motor Driver L298 Module


#1

Hi,

I try to drive DC motors by L298 module but it doesn’t work correctly.

I execute following code

motorControllerL298.MoveMotor(MotorControllerL298.Motor.Motor1, 80);

I think this code drives side of Motor1 only but both motors are drived.
Is this code wrong?

I use .NET Gadgeteer Fez Spider.
Please let me advice.

regards,


#2

Please post some diagram on how you have wired the motors and the complete code.

Welcome to the community.


#3

I wired as picture and whole code is


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            
            int speed = 10;
            MotorControllerL298.Motor motor1Id = MotorControllerL298.Motor.Motor2;
            while (speed <= 100)
            {
                motorControllerL298.MoveMotor(motor1Id, speed);
                Thread.Sleep(1000);
                speed += 20;
            }
            motorControllerL298.MoveMotor(motor1Id, 0);

in ProgramStarted Method of Program class.


#4

Never a good idea to sleep in the ProgramStarted method. Try controlling the motor in a separate thread.


#5

Also try the motor module on a different P socket, just in case.