Hi,
in my Gadgeteer 4.2 Project i have a strange issue with the Motor Controller298.
I want to control 2 Motors, when i use MoveMotorRampNonBlocking() the second Motor only rotate in Debugging mode, when i run the code without degug only 1 Motor rotate.
Other methods e.g. MoveMotorRamp works fine.
For example ramp it up to 50% instead of 100 and over smaller timespans. 1000ms or 500ms for example. Is it the first motor or the second that is not turning on?
The move non blocking functions use threads behind the scenes, but the driver does not appear to be thread safe so there is a race between the two calls.
public void MoveMotorRampNonBlocking(Motor _motorSide, int _newSpeed, int _rampingDelayMilli)
{
var m = new tMovement();
m.m_motorSide = _motorSide;
m.m_newSpeed = _newSpeed;
m.m_rampingDelayMilli = _rampingDelayMilli;
Thread moveThread = new Thread(() => this.MoveMotorRampThreadStart(m));
moveThread.Start();
}
private tMovement movement;// = new tMovement();
/// <summary>
/// Represents the function that is used to start a thread to asynchronously move a motor.
/// </summary>
private void MoveMotorRampThreadStart(tMovement vars)
{
MoveMotorRamp(vars.m_motorSide, vars.m_newSpeed, vars.m_rampingDelayMilli);
}
@ dutzend - Can you post entire code for your modified motor driver, please. Also make sure you are not referencing the driver dll that comes with the sdk (remove the module in the designer completely and instantiate it manually in your “program started”).