Home→Forums→MonoBrick EV3 Firmware→Engine control – move 45°, wait, move 45°, wait→Reply To: Engine control – move 45°, wait, move 45°, wait
November 24, 2014 at 22:50
#5010
Anders Søborg
Keymaster
Hi there
I just tried you program, and it turns out that what you have observed
…If I turn the engine with my hand a little bit the program continues…
is in fact a error in the firmware that happens when you move a very small amount and the program has not been AOT compiled. I already fixed it and will create a new release tomorrow. A temporary workaround is to make the motor move a big step the first time you create a profile. I modified your program so it looks like this.
using System;
using System.Threading;
using MonoBrickFirmware;
using MonoBrickFirmware.Movement;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.UserInput;
namespace MoveMotorA90
{
class Program
{
static void Main(string[] args)
{
Motor motorA = new Motor(MotorPort.OutA);
ManualResetEvent stop = new ManualResetEvent(false);
bool run = true;
WaitHandle motorWaitHandle;
ButtonEvents press = new ButtonEvents();
press.EnterPressed += delegate
{
stop.Set();
run = false;
};
motorA.SpeedProfile(30, 300, 300, 300, true).WaitOne();
motorA.ResetTacho();
while(run)
{
LcdConsole.WriteLine("Position A: " + motorA.GetTachoCount());
motorWaitHandle = motorA.SpeedProfile(30, 15, 15, 15, true);
WaitHandle.WaitAny(new WaitHandle[]{motorWaitHandle, stop});
}
motorA.Off();
LcdConsole.WriteLine("Position A: " + motorA.GetTachoCount());
}
}
}
Let me know how it goes…
/Anders
Follow