Beispiel #1
0
        public static void Main(string[] args)
        {
            Motor motor = new Motor (MotorPort.OutA);
            motor.ResetTacho();
            motor.MoveTo(25,1000,true);
            System.Threading.Thread.Sleep(3000);
            Console.WriteLine(motor.GetTachoCount().ToString());

            /*motor.MoveTo(75,0,false,true);
            LcdConsole.WriteLine(motor.GetTachoCount().ToString());
            System.Threading.Thread.Sleep(3000);
            LcdConsole.WriteLine ("Done executing motor test");*/
        }
Beispiel #2
0
		public static void Main (string[] args)
		{
			
			Motor motor = new Motor(MotorPort.OutA);
			motor.ResetTacho();
			PositionPID PID = new PositionPID(motor, 4000, true, 50, P, I, D, 5000);
			var waitHandle = PID.Run();
			Console.WriteLine("Moving motor A to position 4000");
			Console.WriteLine("Waiting for controller to finish");
			//Wait for controller to finish - you can do other stuff here
			waitHandle.WaitOne();
			Console.WriteLine("Done");
			Console.WriteLine("Motor position: " + motor.GetTachoCount());
		}
Beispiel #3
0
 public static void Main(string[] args)
 {
     Console.WriteLine ("Resetting the motors");
     TouchSensor ts = new TouchSensor(SensorPort.In2);
     Motor motorFwd = new Motor(MotorPort.OutB);
     Motor motorTurn = new Motor(MotorPort.OutC);
     Motor motorSwitch = new Motor(MotorPort.OutA);
     Motor motorArm = new Motor(MotorPort.OutD);
     motorArm.On (-60);
     ButtonEvents buts = new ButtonEvents();
     bool keepGoing = true;
     while (keepGoing) {
         buts.EscapePressed += () => {
             keepGoing = false;
         };
         if (ts.IsPressed ()) {
             keepGoing = false;
         }
     }
     motorArm.Off ();
     switchMode ();
     keepGoing = true;
     TouchSensor ts2 = new TouchSensor(SensorPort.In4);
     motorArm.On (-60);
     while (keepGoing) {
         buts.EscapePressed += () => {
             keepGoing = false;
         };
         if (ts2.IsPressed ()) {
             keepGoing = false;
         }
     }
     motorArm.Off ();
     switchMode ();
     motorArm.ResetTacho ();
     motorFwd.ResetTacho ();
     motorSwitch.ResetTacho ();
     motorTurn.ResetTacho ();
 }
Beispiel #4
0
        public virtual void Pee()
        {
            //Lift leg 
            
            Motor motor = new Motor(MotorPort.OutA);
            motor.ResetTacho();
            motor.SetSpeed(20);
            System.Threading.Thread.Sleep(2500);
            motor.Brake();
            //System.Threading.Thread.Sleep(2500);

            //Make peeing sound
            MakeSound(DogSound.Pee);
            LcdConsole.WriteLine("Peeing");
              
            //Reset bladder
            BladderLevel = 0;
        }
Beispiel #5
0
 public static RGBColor[] CountFacelets(Motor a, EV3ColorSensor sensor)
 {
     RGBColor[] colors = new RGBColor[8];
     a.ResetTacho();
     for (int count = 0; count < 8;)
         if (count == a.GetTachoCount () / 45 % 8)
             colors [count++] = sensor.ReadRGB ();
     return colors;
 }
        /// <summary>
        /// Resets the useless arm to its initial location (down)
        /// </summary>
        private static void ResetArmLocation(Motor motor)
        {
            LcdConsole.WriteLine ("Resetting the arm");

            motor.On (20);

            // there is a ramp up time for the motor. if the speed is checked
            // to fast then it will still be zero
            System.Threading.Thread.Sleep (200);

            // we'll be using the tachometer to track rotations so lets reset it
            motor.ResetTacho ();
            System.Threading.Thread.Sleep (100);

            while (motor.GetSpeed() > 0) {
                // just keeps us from moving on until the arm is fully reset
                // hacky I know
            }

            LcdConsole.WriteLine ("Arm reset");
            motor.Off();
        }
Beispiel #7
0
		public static void Main (string[] args)
		{
			
			Motor motorA = new Motor (MotorPort.OutA);
			Motor motorD = new Motor (MotorPort.OutD);
			WaitHandle motorWaitHandle;
			motorA.Off();
			motorD.Off();

			//Power control
			LcdConsole.WriteLine("Set power to 50");
			motorA.SetPower(50);
			Thread.Sleep(3000);
			LcdConsole.WriteLine("Break");
			motorA.Brake();

			//Speed control
			LcdConsole.WriteLine("Set speed to 50");
			motorA.SetSpeed(50);
			Thread.Sleep(1000);
			LcdConsole.WriteLine("Speed: " + motorA.GetSpeed());
			Thread.Sleep(2000);
			LcdConsole.WriteLine("Break");
			motorA.Brake();

			//Position control of single motor
			Thread.Sleep(3000);
			motorA.ResetTacho();
			LcdConsole.WriteLine("Moving motor A to 2000 ");
			motorWaitHandle =  motorA.SpeedProfile(50, 200, 1600, 200,true);
			//you could do something else here
			LcdConsole.WriteLine("Waiting for motor A to stop");
			motorWaitHandle.WaitOne();
			LcdConsole.WriteLine("Done moving motor");
			LcdConsole.WriteLine("Position A: " + motorA.GetTachoCount());

			//Individual position control of both motors
			Thread.Sleep(3000);
			motorA.ResetTacho();
			motorD.ResetTacho();
			LcdConsole.WriteLine("Moving motors A to 2000");
			LcdConsole.WriteLine("Moving motor B to 1000");
			WaitHandle[] handles = new WaitHandle[2];
			handles[0] =  motorA.SpeedProfile(50, 200, 1600, 200,true);
			handles[1] = motorD.SpeedProfile(50,200,600,200,true);
			//you could do something else here
			LcdConsole.WriteLine("Waiting for both motors to stop");
			WaitHandle.WaitAll(handles);
			LcdConsole.WriteLine("Done moving both motors");
			LcdConsole.WriteLine("Position A: " + motorA.GetTachoCount());
			LcdConsole.WriteLine("Position D: " + motorD.GetTachoCount());
			motorA.Off();
			motorD.Off();

			//Motor synchronisation position control 
			Thread.Sleep(3000);
			motorA.ResetTacho();
			motorD.ResetTacho();
			MotorSync sync = new MotorSync(MotorPort.OutA, MotorPort.OutD);
			LcdConsole.WriteLine("Sync motors to move 3000 steps forward");
			motorWaitHandle = sync.StepSync(40,0, 3000, true);
			//you could do something else here
			LcdConsole.WriteLine("Waiting for sync to stop");
			motorWaitHandle.WaitOne();
			LcdConsole.WriteLine("Done sync moving both motors");
			LcdConsole.WriteLine("Position A: " + motorA.GetTachoCount());
			LcdConsole.WriteLine("Position D: " + motorD.GetTachoCount());
			sync.Off();

			
		}