Example #1
0
        public static void Main()
        {
            // Start everything
            hal.OnInterrupt += hal_OnInterrupt;
            acc.setRange(enRange.range2g);
            acc.setUpInterrupt();
            acc.clearInterrupt();
            dataReady.OnInterrupt += dataReady_OnInterrupt;
            motorDrive.Start();
            byte[] outBuffer = System.Text.Encoding.UTF8.GetBytes("Motor active");
            acc.setUpAccelRate(200);
            Debug.Print(NI.IPAddress.ToString());

            //Int16 a = -1;
            //a = 0;
            //a = 1;

            //
            //  Ramp up the rotor speed
            //
            int speedNow = 0x3c;

            Thread.Sleep(6000);
            while (speedNow < maxSpeed)
            {
                speedNow++;
                motorDrive.Duration = (UInt32)((double)speedNow * 980d / 512d + 1000);
                if (speedNow > 70)
                {
                    Thread.Sleep(750);   // Was 2000
                }
                else
                {
                    Thread.Sleep(150);
                }
            }


            //  Snooze
            Thread.Sleep(Timeout.Infinite);
        }
Example #2
0
        public static void Main()
        {
            // Start everything
            blueComms.Open();
            blueComms.DataReceived += blueComms_DataReceived;
            hal.OnInterrupt        += hal_OnInterrupt;
            acc.setRange(enRange.range2g);
            acc.setUpInterrupt();
            acc.clearInterrupt();
            dataReady.OnInterrupt += dataReady_OnInterrupt;
            motorDrive.Start();
            byte[] outBuffer = System.Text.Encoding.UTF8.GetBytes("Motor active");
            blueComms.Write(outBuffer, 0, outBuffer.Length);
            acc.setUpAccelRate(200);

            //Int16 a = -1;
            //a = 0;
            //a = 1;

            //
            //  Ramp up the rotor speed
            //
            int speedNow = 0x3c;

            Thread.Sleep(6000);
            while (speedNow < maxSpeed)
            {
                speedNow++;
                motorDrive.Duration = (UInt32)((double)speedNow * 980d / 512d + 1000);
                Thread.Sleep(150);
            }


            //  Snooze
            Thread.Sleep(Timeout.Infinite);
        }
Example #3
0
        public static void Main()
        {
            int setTime  = 20000;
            int col0     = 100;
            int cyc0     = 137;
            int deltaCol = 10;
            int deltaCyc = 10;

            //
            //  Set the initial values
            //

            GlobalVariables.receivedMessage[1] = (byte)cyc0;
            GlobalVariables.receivedMessage[3] = (byte)col0;

            // Start everything
            hal.OnInterrupt += hal_OnInterrupt;
            acc.setUpAccelRate(200);
            acc.setRange(enRange.range4g);
            Thread.Sleep(100);
            acc.setUpInterrupt();
            Thread.Sleep(100);
            accelInt.OnInterrupt += accelInt_OnInterrupt;
            acc.clearInterrupt();
            Thread.Sleep(100);
            acc.clearInterrupt();
            Thread.Sleep(100);

            // Start the pwms.
            motorDrive.Start();
            servo1.Start();
            servo2.Start();
            servo3.Start();

            //
            //  Slowly ramp up the rotor
            //

            int curSpeed = 0;

            while (curSpeed <= maxSpeed)
            {
                curSpeed += 1;
                Thread.Sleep(500);
                GlobalVariables.throttleByte[0] = (byte)curSpeed;
                Debug.Print(curSpeed.ToString());
            }

            Thread.Sleep(setTime);
            //
            //  Go through a set sequence
            //

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 + 0);
            GlobalVariables.receivedMessage[3] = (byte)(col0 + deltaCol);
            Thread.Sleep(setTime);

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 + 0);
            GlobalVariables.receivedMessage[3] = (byte)(col0 - deltaCol);
            Thread.Sleep(setTime);


            GlobalVariables.receivedMessage[1] = (byte)(cyc0 + deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 + 0);
            Thread.Sleep(setTime);

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 + deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 + deltaCol);
            Thread.Sleep(setTime);

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 + deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 - deltaCol);
            Thread.Sleep(setTime);


            GlobalVariables.receivedMessage[1] = (byte)(cyc0 - deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 + 0);
            Thread.Sleep(setTime);

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 - deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 + deltaCol);
            Thread.Sleep(setTime);

            GlobalVariables.receivedMessage[1] = (byte)(cyc0 - deltaCyc);
            GlobalVariables.receivedMessage[3] = (byte)(col0 - deltaCol);
            Thread.Sleep(setTime);



            Thread.Sleep(Timeout.Infinite);
        }