Reply To: controlling the engine

HomeForumsMonoBrick EV3 Firmwarecontrolling the engineReply To: controlling the engine

#4845
Author Image
Anders Søborg
Keymaster

Hi

I think that you are doing something wrong. The code below works fine…


using System;
using MonoBrickFirmware;
using MonoBrickFirmware.Display.Dialogs;
using MonoBrickFirmware.Display;
using MonoBrickFirmware.Movement;
using System.Threading;

namespace MonoBrickHelloWorld
{
	class MainClass
	{
		private const float P = 0.8f;
		private const float I = 1800.1f;
		private const float D = 0.5f;

		public static void Main (string[] args)
		{
			Motor a = new Motor(MotorPort.OutA);
			PositionPID PID = new PositionPID(a,1000, true, 50, P,I,D, 500);
			PID.Run().WaitOne();
			LcdConsole.WriteLine(a.GetTachoCount().ToString());
			PID = new PositionPID(a,-1000, true, 50, P,I,D, 500);
			PID.Run().WaitOne();
			LcdConsole.WriteLine(a.GetTachoCount().ToString());

		}
	}
}

/Anders

Posted in

Make a donation