Reply To: Engine control – move 45°, wait, move 45°, wait

HomeForumsMonoBrick EV3 FirmwareEngine control – move 45°, wait, move 45°, waitReply To: Engine control – move 45°, wait, move 45°, wait

#5010
Author Image
Anders Søborg
Key Master

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

Posted in

Make a donation