Hello,
I was trying to work with the MotorControllerL298/MotorControllerL298 module in NetMF4.3. Having used the module in NetMF 4.2, couple of methods I could not find was
MoveMotor and MoveMotorRamp [and the corresponding blocking/non-blocking versions].
It seems the methods may have been replaced by the motoControllerL298.SetSpeed(motor, speed, ramp-time) method. I tried a few simple examples and I could not figure out how the SetSpeed method really works. I am sorry if there are any documentation available, I could find only examples specific to NetMF 4.2.
I attached the motorController module in the socket 11 of my Spider and my example code is as follows. All I am doing is observing the behavior of the motor when I execute each commented line one after the other.
void ProgramStarted()
{
motorDriverL298.DebugPrintEnabled = true;
Thread test = new Thread(motorDriverTest);
test.Start();
}
private void motorDriverTest()
{
Debug.Print("1");
motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 1.0);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 0.99);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, 0.9, 20);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 0.5);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, 0, 20);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, -0.2);
// motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, -0.4, 10);
Debug.Print("2");
}
Behavior:
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 1.0);[/em] : Line is executed but motor does not move. I would have expected the motor to move with maximum speed.
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 0.99);[/em]: As expected, motor moves in a fixed speed.
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, 0.9, 20); [/em] : Code blocks at this line indefinitely and motor does not move[see attachment 1]. I would have expected the motor to slowly increase to 0.9 times its maximum speed in 20 milli seconds.
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, 0.5);[/em] As expected, motor moves in a slower speed.
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, 0, 20);[/em] Nothing happens [as expected]. But Ramp delay does not block the execution.
[em] motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor1, -0.2); [/em] throws exception [attachment 2] I would have expected the motor to move in the opposite direction at a slower speed.
[em]motorDriverL298.SetSpeed(MotorDriverL298.Motor.Motor2, -0.4, 10);[/em] Blocks the code at this line indefinitely and motor does not move.I would have expected the motor to move in the opposite direction reaching 0.4 times maximum speed in 10 milliseconds.
My question:
- Is this expected behavior? I do not seem to able to give negative value in speed for rotation in opposite direction. The range of speed does not speed to be +1.0 to -1.0. Also when I gave a speed of 1.0,nothing happened.
2 The SetSpeed seems to be non-blocking by default. So are the blocking methods taken away?
- For the ramp speed increase, even when the delay is 20 msec, the code blocks and motor stays still. Could that be a bug?
I am sorry to have to ask this basic question here. It may have been easier if I could just look at the code for MotorControllerL298.SetSpeed(), but I am still a beginner in Gadgeteering and do not want to do that.
Thanks for your time.