logConsole() публичный статический Метод

public static logConsole ( string value ) : void
value string
Результат void
Пример #1
0
/// <summary>
/// /////////////////////////
/// </summary>
/// <param name="X"></param>
/// <param name="XOpp"></param>
/// <param name="Y"></param>
/// <param name="YOpp"></param>
/// <param name="Z"></param>
/// <param name="ZOpp"></param>
        private static void stepsPMM(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            /*
             * float diagChange = 1 / UserVariables.deltaOpp;
             * float towChange = 1 / UserVariables.deltaTower;
             */

            float diagChange = 1 / UserVariables.deltaOpp;
            float towChange  = 1 / UserVariables.deltaTower;

            float XYZ    = (X + Y + Z) / 3;
            float XYZOpp = (XOpp + YOpp + ZOpp) / 3;

            EEPROM.stepsPerMM -= (XYZ - XYZOpp) * ((diagChange + towChange) / 2);

            //XYZ is increased by the offset

            X    += (XYZ - XYZOpp) * diagChange * 1;
            Y    += (XYZ - XYZOpp) * diagChange * 1;
            Z    += (XYZ - XYZOpp) * diagChange * 1;
            XOpp += (XYZ - XYZOpp) * towChange * 0.75f;
            YOpp += (XYZ - XYZOpp) * towChange * 0.75f;
            ZOpp += (XYZ - XYZOpp) * towChange * 0.75f;


            UserInterface.logConsole("Steps per Millimeter: " + EEPROM.stepsPerMM.ToString());
        }
Пример #2
0
        private static void DRad(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            float DASA = ((X + XOpp) / 2);
            float DBSA = ((Y + YOpp) / 2);
            float DCSA = ((Z + ZOpp) / 2);

            float DRadRatio = UserVariables.DRadRatio;

            EEPROM.DA -= X / 0.5F;
            EEPROM.DB -= Y / 0.5F;
            EEPROM.DC -= Z / 0.5F;

            XOpp += X * (0.225F / 0.5F);
            YOpp += X * (0.1375F / 0.5F);
            ZOpp += X * (0.1375F / 0.5F);
            X    += X / 0.5F;

            XOpp += Y * (0.1375F / 0.5F);
            YOpp += Y * (0.225F / 0.5F);
            ZOpp += Y * (0.1375F / 0.5F);
            Y    += Y / 0.5F;

            XOpp += Z * (0.1375F / 0.5F);
            YOpp += Z * (0.1375F / 0.5F);
            ZOpp += Z * (0.225F / 0.5F);
            Z    += Z / 0.5F;

            UserInterface.logConsole("DRad: " + EEPROM.DA.ToString() + ", " + EEPROM.DB.ToString() + ", " + EEPROM.DC.ToString());
        }
Пример #3
0
        public static void fastCalibration()
        {
            //check if eeprom object remains after this function is called for the second time

            if (iterationNum == 0)
            {
                if (UserVariables.diagonalRodLength.ToString() == "")
                {
                    UserVariables.diagonalRodLength = EEPROM.diagonalRod;
                    UserInterface.logConsole("Using default diagonal rod length from EEPROM");
                }
            }

            tempAccuracy = (Math.Abs(Heights.X) + Math.Abs(Heights.XOpp) + Math.Abs(Heights.Y) + Math.Abs(Heights.YOpp) + Math.Abs(Heights.Z) + Math.Abs(Heights.ZOpp)) / 6;
            Program.mainFormTest.setAccuracyPoint(iterationNum, tempAccuracy);
            checkAccuracy(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);

            if (calibrationState == true)
            {
                towerOffsets(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                alphaRotation(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                stepsPMM(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                HRad(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
            }
            else
            {
                //analyzeGeometry(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
            }
        }
Пример #4
0
        public mainForm()
        {
            FormBorderStyle = FormBorderStyle.FixedSingle;
            MaximizeBox     = false;

            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US");

            InitializeComponent();

            consoleMain.Text          = "";
            consoleMain.ScrollBars    = RichTextBoxScrollBars.Vertical;
            consolePrinter.Text       = "";
            consolePrinter.ScrollBars = RichTextBoxScrollBars.Vertical;


            // Basic set of standard baud rates.
            baudRateCombo.Items.Add("250000");
            baudRateCombo.Items.Add("115200");
            baudRateCombo.Items.Add("57600");
            baudRateCombo.Items.Add("38400");
            baudRateCombo.Items.Add("19200");
            baudRateCombo.Items.Add("9600");
            baudRateCombo.Text = "250000";  // This is the default for most RAMBo controllers.

            advancedPanel.Visible   = false;
            printerLogPanel.Visible = false;

            Connection.readThread  = new Thread(Threading.Read);
            Connection.calcThread  = new Thread(Threading.HandleRead);
            Connection._serialPort = new SerialPort();


            // Build the combobox of available ports.
            string[] ports = SerialPort.GetPortNames();

            if (ports.Length >= 1)
            {
                Dictionary <string, string> comboSource = new Dictionary <string, string>();

                int count = 0;

                foreach (string element in ports)
                {
                    comboSource.Add(ports[count], ports[count]);
                    count++;
                }

                portsCombo.DataSource    = new BindingSource(comboSource, null);
                portsCombo.DisplayMember = "Key";
                portsCombo.ValueMember   = "Value";
            }
            else
            {
                UserInterface.logConsole("No ports available");
            }

            //accuracyTime.Series["Accuracy"].Points.AddXY(0, 0);
            UserVariables.isInitiated = true;
        }
Пример #5
0
        public static void connect()
        {
            if (_serialPort.IsOpen)
            {
                UserInterface.logConsole("Already Connected");
            }
            else
            {
                try
                {
                    // Opens a new thread if there has been a previous thread that has closed.
                    if (readThread.IsAlive == false)
                    {
                        readThread  = new Thread(ConsoleRead.Read);
                        _serialPort = new SerialPort();
                    }

                    _serialPort.PortName = Program.mainFormTest.portsCombo.Text;
                    _serialPort.BaudRate = int.Parse(Program.mainFormTest.baudRateCombo.Text);

                    // Set the read/write timeouts.
                    _serialPort.ReadTimeout  = 500;
                    _serialPort.WriteTimeout = 500;

                    // Open the serial port and start reading on a reader thread.
                    // _continue is a flag used to terminate the app.

                    if (_serialPort.BaudRate != double.NaN && _serialPort.PortName != null)
                    {
                        _serialPort.Open();
                        ConsoleRead._continue = true;

                        readThread.Start();
                        UserInterface.logConsole("Connected");
                    }
                    else
                    {
                        UserInterface.logConsole("Please fill all text boxes above");
                    }
                }
                catch (Exception e1)
                {
                    UserInterface.logConsole(e1.Message);
                    ConsoleRead._continue = false;

                    //check if connection is open
                    if (readThread.IsAlive)
                    {
                        readThread.Join();
                    }

                    _serialPort.Close();
                }
            }
        }
Пример #6
0
 public static void sendToPosition(float X, float Y, float Z)
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine("G1 Z" + Z.ToString() + " X" + X.ToString() + " Y" + Y.ToString());
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #7
0
 public static void homeAxes()
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine("G28");
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #8
0
 private static void probe()
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine("G30");
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #9
0
 public static void emergencyReset()
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine("M112");
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #10
0
 public static void sendReadEEPROMCommand()
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine("M205");
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #11
0
 private void resetPrinter_Click(object sender, EventArgs e)
 {
     if (Connection._serialPort.IsOpen)
     {
         GCode.emergencyReset();
     }
     else
     {
         UserInterface.logConsole("Not connected");
     }
 }
Пример #12
0
 private void sendGCodeText()
 {
     if (Connection._serialPort.IsOpen)
     {
         Connection._serialPort.WriteLine(GCodeBox.Text.ToString().ToUpper());
         UserInterface.logConsole("Sent: " + GCodeBox.Text.ToString().ToUpper());
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #13
0
 private void readEEPROM_Click(object sender, EventArgs e)
 {
     if (Connection._serialPort.IsOpen)
     {
         EEPROMFunctions.tempEEPROMSet = false;
         EEPROMFunctions.readEEPROM();
         EEPROMFunctions.EEPROMReadOnly   = true;
         HeightFunctions.checkHeightsOnly = false;
         EEPROMFunctions.EEPROMReadCount  = 0;
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #14
0
        private static void HRad(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            float HRadSA    = ((X + XOpp + Y + YOpp + Z + ZOpp) / 6);
            float HRadRatio = UserVariables.HRadRatio;

            EEPROM.HRadius += (HRadSA / HRadRatio);

            X    -= HRadSA;
            Y    -= HRadSA;
            Z    -= HRadSA;
            XOpp -= HRadSA;
            YOpp -= HRadSA;
            ZOpp -= HRadSA;

            UserInterface.logConsole("HRad:" + EEPROM.HRadius.ToString());
        }
Пример #15
0
 private void calibrateButton_Click(object sender, EventArgs e)
 {
     if (Connection._serialPort.IsOpen)
     {
         GCode.checkHeights = true;
         EEPROMFunctions.readEEPROM();
         EEPROMFunctions.EEPROMReadOnly   = false;
         Calibration.calibrationState     = true;
         Calibration.calibrationSelection = 0;
         HeightFunctions.checkHeightsOnly = false;
     }
     else
     {
         UserInterface.logConsole("Not connected");
     }
 }
Пример #16
0
        private static void stepsPMM(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            float diagChange = 1 / UserVariables.deltaOpp;
            float towChange  = 1 / UserVariables.deltaTower;

            float XYZ    = (X + Y + Z) / 3;
            float XYZOpp = (XOpp + YOpp + ZOpp) / 3;

            EEPROM.stepsPerMM -= (XYZ - XYZOpp) * ((diagChange + towChange) / 2);

            X    += (XYZ - XYZOpp) * towChange;
            Y    += (XYZ - XYZOpp) * towChange;
            Z    += (XYZ - XYZOpp) * towChange;
            XOpp += (XYZ - XYZOpp) * diagChange;
            YOpp += (XYZ - XYZOpp) * diagChange;
            ZOpp += (XYZ - XYZOpp) * diagChange;

            UserInterface.logConsole("Steps per Millimeter: " + EEPROM.stepsPerMM.ToString());
        }
Пример #17
0
        private static void checkAccuracy(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            float accuracy = UserVariables.accuracy;

            if (X <= accuracy && X >= -accuracy && XOpp <= accuracy && XOpp >= -accuracy && Y <= accuracy && Y >= -accuracy && YOpp <= accuracy && YOpp >= -accuracy && Z <= accuracy && Z >= -accuracy && ZOpp <= accuracy && ZOpp >= -accuracy)
            {
                if (UserVariables.probeChoice == "FSR")
                {
                    EEPROM.zMaxLength -= UserVariables.FSROffset;
                    UserInterface.logConsole("Setting Z Max Length with adjustment for FSR");
                }

                calibrationState = false;
            }
            else
            {
                GCode.checkHeights = true;
                UserInterface.logConsole("Continuing Calibration");
            }
        }
Пример #18
0
 public static void disconnect()
 {
     if (_serialPort.IsOpen && readThread.IsAlive)
     {
         try
         {
             ConsoleRead._continue = false;
             readThread.Join();
             _serialPort.Close();
             UserInterface.logConsole("Disconnected");
         }
         catch (Exception e1)
         {
             UserInterface.logConsole(e1.Message);
         }
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #19
0
 public static void sendEEPROMVariable(int type, int position, float value)
 {
     if (Connection._serialPort.IsOpen)
     {
         if (type == 1)
         {
             Connection._serialPort.WriteLine("M206 T1 P" + position + " S" + value);
         }
         else if (type == 3)
         {
             Connection._serialPort.WriteLine("M206 T3 P" + position + " X" + value);
         }
         else
         {
             UserInterface.logConsole("Invalid EEPROM Variable.");
         }
     }
     else
     {
         UserInterface.logConsole("Not Connected");
     }
 }
Пример #20
0
 public static void sendEEPROM()
 {
     //manually set all eeprom values
     UserInterface.logConsole("Setting EEPROM.");
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 11, EEPROM.stepsPerMM);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 153, EEPROM.zMaxLength);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 808, EEPROM.zProbeHeight);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 812, EEPROM.zProbeSpeed);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 881, EEPROM.diagonalRod);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 885, EEPROM.HRadius);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(1, 893, EEPROM.offsetX);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(1, 895, EEPROM.offsetY);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(1, 897, EEPROM.offsetZ);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 901, EEPROM.A);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 905, EEPROM.B);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 909, EEPROM.C);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 913, EEPROM.DA);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 917, EEPROM.DB);
     Thread.Sleep(50);
     GCode.sendEEPROMVariable(3, 921, EEPROM.DC);
     Thread.Sleep(50);
 }
Пример #21
0
 public static void printHeights()
 {
     UserInterface.logConsole("Center:" + Heights.center + " X:" + Heights.X + " XOpp:" + Heights.XOpp + " Y:" + Heights.Y + " YOpp:" + Heights.YOpp + " Z:" + Heights.Z + " ZOpp:" + Heights.ZOpp);
 }
Пример #22
0
        /*
         * public void analyzeGeometry(float X, float XOpp, float Y, float YOpp, float Z, float ZOpp)
         * {
         *  int analyzeCount = 0;
         *
         *
         *  UserInterface.logConsole("Expect a slight inaccuracy in the geometry analysis; basic calibration.");
         * }
         */

        private static void towerOffsets(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            int   j          = 0;
            float accuracy   = UserVariables.calculationAccuracy;
            float tempX2     = X;
            float tempXOpp2  = XOpp;
            float tempY2     = Y;
            float tempYOpp2  = YOpp;
            float tempZ2     = Z;
            float tempZOpp2  = ZOpp;
            float offsetX    = EEPROM.offsetX;
            float offsetY    = EEPROM.offsetY;
            float offsetZ    = EEPROM.offsetZ;
            float stepsPerMM = EEPROM.stepsPerMM;

            float towMain = UserVariables.offsetCorrection; //0.6
            float oppMain = UserVariables.mainOppPerc;      //0.5
            float towSub  = UserVariables.towPerc;          //0.3
            float oppSub  = UserVariables.oppPerc;          //-0.25

            while (j < 100)
            {
                if (Math.Abs(tempX2) > UserVariables.accuracy || Math.Abs(tempY2) > UserVariables.accuracy || Math.Abs(tempZ2) > UserVariables.accuracy)
                {
                    offsetX -= tempX2 * stepsPerMM * (1 / towMain);

                    tempXOpp2 -= tempX2 * (oppMain / towMain);
                    tempY2    -= tempX2 * (towSub / towMain);
                    tempYOpp2 -= tempX2 * (-oppSub / towMain);
                    tempZ2    -= tempX2 * (towSub / towMain);
                    tempZOpp2 -= tempX2 * (-oppSub / towMain);
                    tempX2    -= tempX2 / 1;

                    offsetY -= tempY2 * stepsPerMM * (1 / towMain);

                    tempYOpp2 -= tempY2 * (oppMain / towMain);
                    tempX2    -= tempY2 * (towSub / towMain);
                    tempXOpp2 -= tempY2 * (-oppSub / towMain);
                    tempZ2    -= tempY2 * (towSub / towMain);
                    tempZOpp2 -= tempY2 * (-oppSub / towMain);
                    tempY2    -= tempY2 / 1;

                    offsetZ -= tempZ2 * stepsPerMM * (1 / towMain);

                    tempZOpp2 -= tempZ2 * (oppMain / towMain);
                    tempX2    -= tempZ2 * (towSub / towMain);
                    tempXOpp2 += tempZ2 * (-oppSub / towMain);
                    tempY2    -= tempZ2 * (towSub / towMain);
                    tempYOpp2 -= tempZ2 * (-oppSub / towMain);
                    tempZ2    -= tempZ2 / 1;

                    tempX2    = Validation.checkZero(tempX2);
                    tempY2    = Validation.checkZero(tempY2);
                    tempZ2    = Validation.checkZero(tempZ2);
                    tempXOpp2 = Validation.checkZero(tempXOpp2);
                    tempYOpp2 = Validation.checkZero(tempYOpp2);
                    tempZOpp2 = Validation.checkZero(tempZOpp2);

                    if (Math.Abs(tempX2) <= UserVariables.accuracy && Math.Abs(tempY2) <= UserVariables.accuracy && Math.Abs(tempZ2) <= UserVariables.accuracy)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        UserInterface.logConsole("No Hrad correction");

                        float smallest = Math.Min(offsetX, Math.Min(offsetY, offsetZ));

                        offsetX -= smallest;
                        offsetY -= smallest;
                        offsetZ -= smallest;

                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);

                        X    = tempX2;
                        XOpp = tempXOpp2;
                        Y    = tempY2;
                        YOpp = tempYOpp2;
                        Z    = tempZ2;
                        ZOpp = tempZOpp2;

                        //round to the nearest whole number
                        EEPROM.offsetX = Convert.ToInt32(offsetX);
                        EEPROM.offsetY = Convert.ToInt32(offsetY);
                        EEPROM.offsetZ = Convert.ToInt32(offsetZ);

                        j = 100;
                    }
                    else if (j == 99)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        float dradCorr  = tempX2 * -1.25F;
                        float HRadRatio = UserVariables.HRadRatio;

                        EEPROM.HRadius += dradCorr;

                        EEPROM.offsetX = 0;
                        EEPROM.offsetY = 0;
                        EEPROM.offsetZ = 0;

                        //hradsa = dradcorr
                        //solve inversely from previous method
                        float HRadOffset = HRadRatio * dradCorr;

                        tempX2    -= HRadOffset;
                        tempY2    -= HRadOffset;
                        tempZ2    -= HRadOffset;
                        tempXOpp2 -= HRadOffset;
                        tempYOpp2 -= HRadOffset;
                        tempZOpp2 -= HRadOffset;

                        UserInterface.logConsole("Hrad correction: " + dradCorr);
                        UserInterface.logConsole("HRad: " + EEPROM.HRadius.ToString());

                        j = 0;
                    }
                    else
                    {
                        j++;
                    }

                    //UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                    //UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                }
                else
                {
                    j = 100;

                    UserInterface.logConsole("Tower Offsets and Delta Radii Calibrated");
                }
            }

            if (EEPROM.offsetX > 1000 || EEPROM.offsetY > 1000 || EEPROM.offsetZ > 1000)
            {
                UserInterface.logConsole("Tower offset calibration error, setting default values.");
                UserInterface.logConsole("Tower offsets before damage prevention: X" + offsetX + " Y" + offsetY + " Z" + offsetZ);
                offsetX = 0;
                offsetY = 0;
                offsetZ = 0;
            }
        }
Пример #23
0
        public static void basicCalibration()
        {
            //check if eeprom object remains after this function is called for the second time
            if (iterationNum == 0)
            {
                if (UserVariables.diagonalRodLength.ToString() == "")
                {
                    UserVariables.diagonalRodLength = EEPROM.diagonalRod;
                    UserInterface.logConsole("Using default diagonal rod length from EEPROM");
                }
            }

            tempAccuracy = (Math.Abs(Heights.X) + Math.Abs(Heights.XOpp) + Math.Abs(Heights.Y) + Math.Abs(Heights.YOpp) + Math.Abs(Heights.Z) + Math.Abs(Heights.ZOpp)) / 6;
            Program.mainFormTest.setAccuracyPoint(iterationNum, tempAccuracy);
            checkAccuracy(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);

            if (calibrationState == true)
            {
                bool spm = (Heights.X + Heights.Y + Heights.Z) / 3 > (Heights.XOpp + Heights.YOpp + Heights.ZOpp) / 3 + UserVariables.accuracy || (Heights.X + Heights.Y + Heights.Z) / 3 < (Heights.XOpp + Heights.YOpp + Heights.ZOpp) / 3 - UserVariables.accuracy;//returns false if drad does not need corrected

                bool tower = Math.Abs(Math.Max(Heights.X, Math.Max(Heights.Y, Heights.Z)) - Math.Min(Heights.X, Math.Min(Heights.Y, Heights.Z))) > UserVariables.accuracy;

                bool alpha = Heights.XOpp > Heights.YOpp + UserVariables.accuracy || Heights.XOpp <Heights.YOpp - UserVariables.accuracy || Heights.XOpp> Heights.ZOpp + UserVariables.accuracy || Heights.XOpp <Heights.ZOpp - UserVariables.accuracy ||
                                                                                                                                                                                                                 Heights.YOpp> Heights.XOpp + UserVariables.accuracy || Heights.YOpp <Heights.XOpp - UserVariables.accuracy || Heights.YOpp> Heights.ZOpp + UserVariables.accuracy || Heights.YOpp <Heights.ZOpp - UserVariables.accuracy ||
                                                                                                                                                                                                                                                                                                                                                                                                    Heights.ZOpp> Heights.YOpp + UserVariables.accuracy || Heights.ZOpp <Heights.YOpp - UserVariables.accuracy || Heights.ZOpp> Heights.XOpp + UserVariables.accuracy || Heights.ZOpp < Heights.XOpp - UserVariables.accuracy;//returns false if tower offsets do not need corrected

                bool hrad = Heights.X <Heights.Y + UserVariables.accuracy && Heights.X> Heights.Y - UserVariables.accuracy &&
                            Heights.X <Heights.Z + UserVariables.accuracy && Heights.X> Heights.Z - UserVariables.accuracy &&
                            Heights.X <Heights.YOpp + UserVariables.accuracy && Heights.X> Heights.YOpp - UserVariables.accuracy &&
                            Heights.X <Heights.ZOpp + UserVariables.accuracy && Heights.X> Heights.ZOpp - UserVariables.accuracy &&
                            Heights.X <Heights.XOpp + UserVariables.accuracy && Heights.X> Heights.XOpp - UserVariables.accuracy &&
                            Heights.XOpp <Heights.X + UserVariables.accuracy && Heights.XOpp> Heights.X - UserVariables.accuracy &&
                            Heights.XOpp <Heights.Y + UserVariables.accuracy && Heights.XOpp> Heights.Y - UserVariables.accuracy &&
                            Heights.XOpp <Heights.Z + UserVariables.accuracy && Heights.XOpp> Heights.Z - UserVariables.accuracy &&
                            Heights.XOpp <Heights.YOpp + UserVariables.accuracy && Heights.XOpp> Heights.YOpp - UserVariables.accuracy &&
                            Heights.XOpp <Heights.ZOpp + UserVariables.accuracy && Heights.XOpp> Heights.ZOpp - UserVariables.accuracy &&
                            Heights.Y <Heights.X + UserVariables.accuracy && Heights.Y> Heights.X - UserVariables.accuracy &&
                            Heights.Y <Heights.Z + UserVariables.accuracy && Heights.Y> Heights.Z - UserVariables.accuracy &&
                            Heights.Y <Heights.XOpp + UserVariables.accuracy && Heights.Y> Heights.XOpp - UserVariables.accuracy &&
                            Heights.Y <Heights.YOpp + UserVariables.accuracy && Heights.Y> Heights.YOpp - UserVariables.accuracy &&
                            Heights.Y <Heights.ZOpp + UserVariables.accuracy && Heights.Y> Heights.ZOpp - UserVariables.accuracy &&
                            Heights.YOpp <Heights.X + UserVariables.accuracy && Heights.YOpp> Heights.X - UserVariables.accuracy &&
                            Heights.YOpp <Heights.Y + UserVariables.accuracy && Heights.YOpp> Heights.Y - UserVariables.accuracy &&
                            Heights.YOpp <Heights.Z + UserVariables.accuracy && Heights.YOpp> Heights.Z - UserVariables.accuracy &&
                            Heights.YOpp <Heights.XOpp + UserVariables.accuracy && Heights.YOpp> Heights.XOpp - UserVariables.accuracy &&
                            Heights.YOpp <Heights.ZOpp + UserVariables.accuracy && Heights.YOpp> Heights.ZOpp - UserVariables.accuracy &&
                            Heights.Z <Heights.X + UserVariables.accuracy && Heights.Z> Heights.X - UserVariables.accuracy &&
                            Heights.Z <Heights.Y + UserVariables.accuracy && Heights.Z> Heights.Y - UserVariables.accuracy &&
                            Heights.Z <Heights.XOpp + UserVariables.accuracy && Heights.Z> Heights.XOpp - UserVariables.accuracy &&
                            Heights.Z <Heights.YOpp + UserVariables.accuracy && Heights.Z> Heights.YOpp - UserVariables.accuracy &&
                            Heights.Z <Heights.ZOpp + UserVariables.accuracy && Heights.Z> Heights.ZOpp - UserVariables.accuracy &&
                            Heights.ZOpp <Heights.X + UserVariables.accuracy && Heights.ZOpp> Heights.X - UserVariables.accuracy &&
                            Heights.ZOpp <Heights.Y + UserVariables.accuracy && Heights.ZOpp> Heights.Y - UserVariables.accuracy &&
                            Heights.ZOpp <Heights.Z + UserVariables.accuracy && Heights.ZOpp> Heights.Z - UserVariables.accuracy &&
                            Heights.ZOpp <Heights.XOpp + UserVariables.accuracy && Heights.ZOpp> Heights.XOpp - UserVariables.accuracy &&
                            Heights.ZOpp <Heights.YOpp + UserVariables.accuracy && Heights.ZOpp> Heights.YOpp - UserVariables.accuracy;

                UserInterface.logConsole("Tower:" + tower + " SPM:" + spm + " Alpha:" + alpha + " HRad:" + hrad);

                if (tower)
                {
                    towerOffsets(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                }
                else if (alpha)
                {
                    alphaRotation(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                }
                else if (spm)
                {
                    stepsPMM(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                }
                else if (hrad)
                {
                    HRad(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
                }
            }
            else
            {
                //analyzeGeometry(ref Heights.X, ref Heights.XOpp, ref Heights.Y, ref Heights.YOpp, ref Heights.Z, ref Heights.ZOpp);
            }
        }
Пример #24
0
        /*
         * public void analyzeGeometry(float X, float XOpp, float Y, float YOpp, float Z, float ZOpp)
         * {
         *  int analyzeCount = 0;
         *
         *
         *  UserInterface.logConsole("Expect a slight inaccuracy in the geometry analysis; basic calibration.");
         * }
         */

        private static void towerOffsets(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            int   j          = 0;
            float accuracy   = UserVariables.calculationAccuracy;
            float tempX2     = X;
            float tempXOpp2  = XOpp;
            float tempY2     = Y;
            float tempYOpp2  = YOpp;
            float tempZ2     = Z;
            float tempZOpp2  = ZOpp;
            float offsetX    = EEPROM.offsetX;
            float offsetY    = EEPROM.offsetY;
            float offsetZ    = EEPROM.offsetZ;
            float stepsPerMM = EEPROM.stepsPerMM;

            while (j < 100)
            {
                if (Math.Abs(tempX2) > UserVariables.accuracy / 2 || Math.Abs(tempY2) > UserVariables.accuracy / 2 || Math.Abs(tempZ2) > UserVariables.accuracy / 2)
                {
                    offsetX += tempX2 * stepsPerMM * (1 / 0.60F);

                    tempXOpp2 += tempX2 * (0.5F / 0.60F);
                    tempY2    += tempX2 * (0.3F / 0.60F);
                    tempYOpp2 += tempX2 * (-0.25F / 0.60F);
                    tempZ2    += tempX2 * (0.3F / 0.60F);
                    tempZOpp2 += tempX2 * (-0.25F / 0.60F);
                    tempX2    += tempX2 / -1;

                    offsetY += tempY2 * stepsPerMM * (1 / 0.60F);

                    tempYOpp2 += tempY2 * (0.5F / 0.60F);
                    tempX2    += tempY2 * (0.3F / 0.60F);
                    tempXOpp2 += tempY2 * (-0.25F / 0.60F);
                    tempZ2    += tempY2 * (0.3F / 0.60F);
                    tempZOpp2 += tempY2 * (-0.25F / 0.60F);
                    tempY2    += tempY2 / -1;

                    offsetZ += tempZ2 * stepsPerMM * (1 / 0.60F);

                    tempZOpp2 += tempZ2 * (0.5F / 0.60F);
                    tempX2    += tempZ2 * (0.3F / 0.60F);
                    tempXOpp2 += tempZ2 * (-0.25F / 0.60F);
                    tempY2    += tempZ2 * (0.3F / 0.60F);
                    tempYOpp2 += tempZ2 * (-0.25F / 0.60F);
                    tempZ2    += tempZ2 / -1;

                    tempX2    = Validation.checkZero(tempX2);
                    tempY2    = Validation.checkZero(tempY2);
                    tempZ2    = Validation.checkZero(tempZ2);
                    tempXOpp2 = Validation.checkZero(tempXOpp2);
                    tempYOpp2 = Validation.checkZero(tempYOpp2);
                    tempZOpp2 = Validation.checkZero(tempZOpp2);

                    float tempComb    = tempX2 + tempY2 + tempZ2;
                    float tempCombAbs = Math.Abs(tempX2) + Math.Abs(tempY2) + Math.Abs(tempZ2);

                    if (Math.Abs(tempX2) <= UserVariables.accuracy && Math.Abs(tempY2) <= UserVariables.accuracy && Math.Abs(tempZ2) <= UserVariables.accuracy)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        UserInterface.logConsole("No Drad correction");

                        float smallest = Math.Min(offsetX, Math.Min(offsetY, offsetZ));

                        offsetX -= smallest;
                        offsetY -= smallest;
                        offsetZ -= smallest;

                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);

                        X    = tempX2;
                        XOpp = tempXOpp2;
                        Y    = tempY2;
                        YOpp = tempYOpp2;
                        Z    = tempZ2;
                        ZOpp = tempZOpp2;

                        //round to the nearest whole number
                        EEPROM.offsetX = Convert.ToInt32(offsetX);
                        EEPROM.offsetY = Convert.ToInt32(offsetY);
                        EEPROM.offsetZ = Convert.ToInt32(offsetZ);

                        j = 100;
                    }
                    else if (j == 99)
                    {
                        UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                        UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                        float dradCorr = tempComb * -0.85F;

                        EEPROM.DA += dradCorr;
                        EEPROM.DB += dradCorr;
                        EEPROM.DC += dradCorr;

                        EEPROM.offsetX = 200;
                        EEPROM.offsetY = 200;
                        EEPROM.offsetZ = 200;

                        UserInterface.logConsole("Drad correction: " + dradCorr);
                        UserInterface.logConsole("DRad: " + EEPROM.DA.ToString() + ", " + EEPROM.DB.ToString() + ", " + EEPROM.DC.ToString());

                        j = 100;
                    }
                    else
                    {
                        j++;
                    }

                    //UserInterface.logConsole("Offs :" + offsetX + " " + offsetY + " " + offsetZ);
                    //UserInterface.logConsole("VHeights :" + tempX2 + " " + tempXOpp2 + " " + tempY2 + " " + tempYOpp2 + " " + tempZ2 + " " + tempZOpp2);
                }
                else
                {
                    xyzOffset = false;
                    j         = 100;
                }
            }

            if (EEPROM.offsetX > 1000 || EEPROM.offsetY > 1000 || EEPROM.offsetZ > 1000)
            {
                UserInterface.logConsole("XYZ offset calibration error, setting default values.");
                UserInterface.logConsole("XYZ offsets before damage prevention: X" + offsetX + " Y" + offsetY + " Z" + offsetZ);
                offsetX = 0;
                offsetY = 0;
                offsetZ = 0;
            }
        }
Пример #25
0
        public static void heuristicLearning()
        {
            //find base heights
            //find heights with each value increased by 1 - HRad, tower offset 1-3, diagonal rod

            if (UserVariables.advancedCalCount == 0)
            {//start
                if (Connection._serialPort.IsOpen)
                {
                    EEPROM.stepsPerMM += 1;
                    UserInterface.logConsole("Setting steps per millimeter to: " + (EEPROM.stepsPerMM).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 1)
            {//get diagonal rod percentages
                UserVariables.deltaTower = ((Heights.teX - Heights.X) + (Heights.teY - Heights.Y) + (Heights.teZ - Heights.Z)) / 3;
                UserVariables.deltaOpp   = ((Heights.teXOpp - Heights.XOpp) + (Heights.teYOpp - Heights.YOpp) + (Heights.teZOpp - Heights.ZOpp)) / 3;

                if (Connection._serialPort.IsOpen)
                {
                    EEPROM.stepsPerMM -= 1;
                    UserInterface.logConsole("Setting steps per millimeter to: " + (EEPROM.stepsPerMM).ToString());

                    //set Hrad +1
                    EEPROM.HRadius += 1;
                    UserInterface.logConsole("Setting horizontal radius to: " + (EEPROM.HRadius).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 2)
            {//get HRad percentages
                UserVariables.HRadRatio = -(Math.Abs((Heights.X - Heights.teX) + (Heights.Y - Heights.teY) + (Heights.Z - Heights.teZ) + (Heights.XOpp - Heights.teXOpp) + (Heights.YOpp - Heights.teYOpp) + (Heights.ZOpp - Heights.teZOpp))) / 6;

                if (Connection._serialPort.IsOpen)
                {
                    //reset horizontal radius
                    EEPROM.HRadius -= 1;
                    UserInterface.logConsole("Setting horizontal radius to: " + (EEPROM.HRadius).ToString());

                    //set X offset
                    EEPROM.offsetX += 80;
                    UserInterface.logConsole("Setting offset X to: " + (EEPROM.offsetX).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 3)
            {//get X offset percentages
                UserVariables.offsetCorrection += Math.Abs(1 / (Heights.X - Heights.teX));
                UserVariables.mainOppPerc      += Math.Abs((Heights.XOpp - Heights.teXOpp) / (Heights.X - Heights.teX));
                UserVariables.towPerc          += (Math.Abs((Heights.Y - Heights.teY) / (Heights.X - Heights.teX)) + Math.Abs((Heights.Z - Heights.teZ) / (Heights.X - Heights.teX))) / 2;
                UserVariables.oppPerc          += (Math.Abs((Heights.YOpp - Heights.teYOpp) / (Heights.X - Heights.teX)) + Math.Abs((Heights.ZOpp - Heights.teZOpp) / (Heights.X - Heights.teX))) / 2;

                if (Connection._serialPort.IsOpen)
                {
                    //reset X offset
                    EEPROM.offsetX -= 80;
                    UserInterface.logConsole("Setting offset X to: " + (EEPROM.offsetX).ToString());

                    //set Y offset
                    EEPROM.offsetY += 80;
                    UserInterface.logConsole("Setting offset Y to: " + (EEPROM.offsetY).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 4)
            {//get Y offset percentages
                UserVariables.offsetCorrection += Math.Abs(1 / (Heights.Y - Heights.teY));
                UserVariables.mainOppPerc      += Math.Abs((Heights.YOpp - Heights.teYOpp) / (Heights.Y - Heights.teY));
                UserVariables.towPerc          += (Math.Abs((Heights.X - Heights.teX) / (Heights.Y - Heights.teY)) + Math.Abs((Heights.Z - Heights.teZ) / (Heights.Y - Heights.teY))) / 2;
                UserVariables.oppPerc          += (Math.Abs((Heights.XOpp - Heights.teXOpp) / (Heights.Y - Heights.teY)) + Math.Abs((Heights.ZOpp - Heights.teZOpp) / (Heights.Y - Heights.teY))) / 2;

                if (Connection._serialPort.IsOpen)
                {
                    //reset Y offset
                    EEPROM.offsetY -= 80;
                    UserInterface.logConsole("Setting offset Y to: " + (EEPROM.offsetY).ToString());

                    //set Z offset
                    EEPROM.offsetZ += 80;
                    UserInterface.logConsole("Setting offset Z to: " + (EEPROM.offsetZ).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 5)
            {//get Z offset percentages
                UserVariables.offsetCorrection += Math.Abs(1 / (Heights.Z - Heights.teZ));
                UserVariables.mainOppPerc      += Math.Abs((Heights.ZOpp - Heights.teZOpp) / (Heights.Z - Heights.teZ));
                UserVariables.towPerc          += (Math.Abs((Heights.X - Heights.teX) / (Heights.Z - Heights.teZ)) + Math.Abs((Heights.Y - Heights.teY) / (Heights.Z - Heights.teZ))) / 2;
                UserVariables.oppPerc          += (Math.Abs((Heights.XOpp - Heights.teXOpp) / (Heights.Z - Heights.teZ)) + Math.Abs((Heights.YOpp - Heights.teYOpp) / (Heights.Z - Heights.teZ))) / 2;

                if (Connection._serialPort.IsOpen)
                {
                    //set Z offset
                    EEPROM.offsetZ -= 80;
                    UserInterface.logConsole("Setting offset Z to: " + (EEPROM.offsetZ).ToString());

                    //set alpha rotation offset perc X
                    EEPROM.A += 1;
                    UserInterface.logConsole("Setting Alpha A to: " + (EEPROM.A).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 6)//6
            {
                //get A alpha rotation

                UserVariables.alphaRotationPercentage += (2 / Math.Abs((Heights.YOpp - Heights.ZOpp) - (Heights.teYOpp - Heights.teZOpp)));

                if (Connection._serialPort.IsOpen)
                {
                    //set alpha rotation offset perc X
                    EEPROM.A -= 1;
                    UserInterface.logConsole("Setting Alpha A to: " + (EEPROM.A).ToString());

                    //set alpha rotation offset perc Y
                    EEPROM.B += 1;
                    UserInterface.logConsole("Setting Alpha B to: " + (EEPROM.B).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 7) //7
            {                                             //get B alpha rotation
                UserVariables.alphaRotationPercentage += (2 / Math.Abs((Heights.ZOpp - Heights.XOpp) - (Heights.teXOpp - Heights.teXOpp)));

                if (Connection._serialPort.IsOpen)
                {
                    //set alpha rotation offset perc Y
                    EEPROM.B -= 1;
                    UserInterface.logConsole("Setting Alpha B to: " + (EEPROM.B).ToString());

                    //set alpha rotation offset perc Z
                    EEPROM.C += 1;
                    UserInterface.logConsole("Setting Alpha C to: " + (EEPROM.C).ToString());
                }

                //check heights

                UserVariables.advancedCalCount++;
            }
            else if (UserVariables.advancedCalCount == 8) //8
            {                                             //get C alpha rotation
                UserVariables.alphaRotationPercentage += (2 / Math.Abs((Heights.XOpp - Heights.YOpp) - (Heights.teXOpp - Heights.teYOpp)));
                UserVariables.alphaRotationPercentage /= 3;

                if (Connection._serialPort.IsOpen)
                {
                    //set alpha rotation offset perc Z
                    EEPROM.C -= 1;
                    UserInterface.logConsole("Setting Alpha C to: " + (EEPROM.C).ToString());
                }

                UserInterface.logConsole("Alpha offset percentage: " + UserVariables.alphaRotationPercentage);

                UserVariables.advancedCalibration = false;
                Program.mainFormTest.setButtonValues();
                UserVariables.advancedCalCount = 0;

                //check heights

                UserInterface.setAdvancedCalVars();
            }

            GCode.checkHeights = true;
        }
Пример #26
0
        private static void alphaRotation(ref float X, ref float XOpp, ref float Y, ref float YOpp, ref float Z, ref float ZOpp)
        {
            float offsetX  = EEPROM.offsetX;
            float offsetY  = EEPROM.offsetY;
            float offsetZ  = EEPROM.offsetZ;
            float accuracy = UserVariables.accuracy;

            //change to object
            float alphaRotationPercentage = UserVariables.alphaRotationPercentage;

            int k = 0;

            while (k < 100)
            {
                //X Alpha Rotation
                if (YOpp > ZOpp)
                {
                    float ZYOppAvg = (YOpp - ZOpp) / 2;
                    EEPROM.A = EEPROM.A + (ZYOppAvg * alphaRotationPercentage); // (0.5/((diff y0 and z0 at X + 0.5)-(diff y0 and z0 at X = 0))) * 2 = 1.75
                    YOpp     = YOpp - ZYOppAvg;
                    ZOpp     = ZOpp + ZYOppAvg;
                }
                else if (YOpp < ZOpp)
                {
                    float ZYOppAvg = (ZOpp - YOpp) / 2;

                    EEPROM.A = EEPROM.A - (ZYOppAvg * alphaRotationPercentage);
                    YOpp     = YOpp + ZYOppAvg;
                    ZOpp     = ZOpp - ZYOppAvg;
                }

                //Y Alpha Rotation
                if (ZOpp > XOpp)
                {
                    float XZOppAvg = (ZOpp - XOpp) / 2;
                    EEPROM.B = EEPROM.B + (XZOppAvg * alphaRotationPercentage);
                    ZOpp     = ZOpp - XZOppAvg;
                    XOpp     = XOpp + XZOppAvg;
                }
                else if (ZOpp < XOpp)
                {
                    float XZOppAvg = (XOpp - ZOpp) / 2;

                    EEPROM.B = EEPROM.B - (XZOppAvg * alphaRotationPercentage);
                    ZOpp     = ZOpp + XZOppAvg;
                    XOpp     = XOpp - XZOppAvg;
                }
                //Z Alpha Rotation
                if (XOpp > YOpp)
                {
                    float YXOppAvg = (XOpp - YOpp) / 2;
                    EEPROM.C = EEPROM.C + (YXOppAvg * alphaRotationPercentage);
                    XOpp     = XOpp - YXOppAvg;
                    YOpp     = YOpp + YXOppAvg;
                }
                else if (XOpp < YOpp)
                {
                    float YXOppAvg = (YOpp - XOpp) / 2;

                    EEPROM.C = EEPROM.C - (YXOppAvg * alphaRotationPercentage);
                    XOpp     = XOpp + YXOppAvg;
                    YOpp     = YOpp - YXOppAvg;
                }

                //determine if value is close enough
                float hTow    = Math.Max(Math.Max(XOpp, YOpp), ZOpp);
                float lTow    = Math.Min(Math.Min(XOpp, YOpp), ZOpp);
                float towDiff = hTow - lTow;

                if (towDiff < UserVariables.calculationAccuracy && towDiff > -UserVariables.calculationAccuracy)
                {
                    k = 100;

                    //log
                    UserInterface.logConsole("ABC:" + EEPROM.A + " " + EEPROM.B + " " + EEPROM.C);
                }
                else
                {
                    k++;
                }
            }
        }
Пример #27
0
        private void manualCalibrateBut_Click(object sender, EventArgs e)
        {
            try
            {
                Calibration.calibrationState = true;

                Program.mainFormTest.setUserVariables();

                Heights.X    = Convert.ToSingle(xManual.Text);
                Heights.XOpp = Convert.ToSingle(xOppManual.Text);
                Heights.Y    = Convert.ToSingle(yManual.Text);
                Heights.YOpp = Convert.ToSingle(yOppManual.Text);
                Heights.Z    = Convert.ToSingle(zManual.Text);
                Heights.ZOpp = Convert.ToSingle(zOppManual.Text);

                EEPROM.stepsPerMM   = Convert.ToSingle(spmMan.Text);
                EEPROM.tempSPM      = Convert.ToSingle(spmMan.Text);
                EEPROM.zMaxLength   = Convert.ToSingle(zMaxMan.Text);
                EEPROM.zProbeHeight = Convert.ToSingle(zProHeiMan.Text);
                EEPROM.zProbeSpeed  = Convert.ToSingle(zProSpeMan.Text);
                EEPROM.HRadius      = Convert.ToSingle(horRadMan.Text);
                EEPROM.diagonalRod  = Convert.ToSingle(diaRodMan.Text);
                EEPROM.offsetX      = Convert.ToSingle(towOffXMan.Text);
                EEPROM.offsetY      = Convert.ToSingle(towOffYMan.Text);
                EEPROM.offsetZ      = Convert.ToSingle(towOffZMan.Text);
                EEPROM.A            = Convert.ToSingle(alpRotAMan.Text);
                EEPROM.B            = Convert.ToSingle(alpRotBMan.Text);
                EEPROM.C            = Convert.ToSingle(alpRotCMan.Text);
                EEPROM.DA           = Convert.ToSingle(delRadAMan.Text);
                EEPROM.DB           = Convert.ToSingle(delRadBMan.Text);
                EEPROM.DC           = Convert.ToSingle(delRadCMan.Text);

                Calibration.basicCalibration();

                //set eeprom vals in manual calibration
                this.spmMan.Text     = EEPROM.stepsPerMM.ToString();
                this.zMaxMan.Text    = EEPROM.zMaxLength.ToString();
                this.zProHeiMan.Text = EEPROM.zProbeHeight.ToString();
                this.zProSpeMan.Text = EEPROM.zProbeSpeed.ToString();
                this.diaRodMan.Text  = EEPROM.diagonalRod.ToString();
                this.horRadMan.Text  = EEPROM.HRadius.ToString();
                this.towOffXMan.Text = EEPROM.offsetX.ToString();
                this.towOffYMan.Text = EEPROM.offsetY.ToString();
                this.towOffZMan.Text = EEPROM.offsetZ.ToString();
                this.alpRotAMan.Text = EEPROM.A.ToString();
                this.alpRotBMan.Text = EEPROM.B.ToString();
                this.alpRotCMan.Text = EEPROM.C.ToString();
                this.delRadAMan.Text = EEPROM.DA.ToString();
                this.delRadBMan.Text = EEPROM.DB.ToString();
                this.delRadCMan.Text = EEPROM.DC.ToString();

                //set expected height map
                this.xExp.Text    = Heights.X.ToString();
                this.xOppExp.Text = Heights.XOpp.ToString();
                this.yExp.Text    = Heights.Y.ToString();
                this.yOppExp.Text = Heights.YOpp.ToString();
                this.zExp.Text    = Heights.Z.ToString();
                this.zOppExp.Text = Heights.ZOpp.ToString();


                Calibration.calibrationState = false;
            }
            catch (Exception ex)
            {
                UserInterface.logConsole(ex.ToString());
            }
        }
Пример #28
0
        public static void setEEPROM(int intParse, float floatParse2)
        {
            switch (intParse)
            {
            case 11:
                UserInterface.logConsole("EEPROM capture initiated");

                EEPROM.stepsPerMM = floatParse2;
                EEPROM.tempSPM    = floatParse2;
                break;

            case 153:
                EEPROM.zMaxLength = floatParse2;
                break;

            case 808:
                EEPROM.zProbeHeight = floatParse2;
                break;

            case 812:
                EEPROM.zProbeSpeed = floatParse2;
                tempEEPROMSet      = true;
                GCode.checkHeights = true;
                EEPROMReadCount++;
                Program.mainFormTest.setEEPROMGUIList();

                break;

            case 881:
                EEPROM.diagonalRod = floatParse2;
                break;

            case 885:
                EEPROM.HRadius = floatParse2;
                break;

            case 893:
                EEPROM.offsetX = floatParse2;
                break;

            case 895:
                EEPROM.offsetY = floatParse2;
                break;

            case 897:
                EEPROM.offsetZ = floatParse2;
                break;

            case 901:
                EEPROM.A = floatParse2;
                break;

            case 905:
                EEPROM.B = floatParse2;
                break;

            case 909:
                EEPROM.C = floatParse2;
                break;

            case 913:
                EEPROM.DA = floatParse2;
                break;

            case 917:
                EEPROM.DB = floatParse2;
                break;

            case 921:
                EEPROM.DC = floatParse2;
                break;
            }
        }
Пример #29
0
        public static void handleInput(string message, bool canMove)
        {
            Program.mainFormTest.setUserVariables();

            if (EEPROMFunctions.tempEEPROMSet == false)
            {
                int   intParse;
                float floatParse2;

                EEPROMFunctions.parseEEPROM(message, out intParse, out floatParse2);
                EEPROMFunctions.setEEPROM(intParse, floatParse2);
            }
            else if (EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == true && EEPROMFunctions.EEPROMReadCount < 1)
            {
                //rm
            }
            else if (GCode.checkHeights == true && EEPROMFunctions.tempEEPROMSet == true && Calibration.calibrateInProgress == false && EEPROMFunctions.EEPROMReadOnly == false)
            {
                if (UserVariables.probeChoice == "Z-Probe" && GCode.wasZProbeHeightSet == false && GCode.wasSet == true)
                {
                    if (HeightFunctions.parseZProbe(message) != 1000)
                    {
                        EEPROM.zProbeHeight = Convert.ToSingle(Math.Round(EEPROM.zMaxLength / 6) - HeightFunctions.parseZProbe(message));

                        GCode.wasZProbeHeightSet = true;
                        Program.mainFormTest.setEEPROMGUIList();
                        EEPROMFunctions.sendEEPROM();
                    }
                }
                else if (canMove == true)
                {
                    //UserInterface.logConsole("position flow");
                    GCode.positionFlow();
                }
                else if (HeightFunctions.parseZProbe(message) != 1000 && HeightFunctions.heightsSet == false)
                {
                    HeightFunctions.setHeights(HeightFunctions.parseZProbe(message));
                }
            }
            else if (Calibration.calibrationState == true && Calibration.calibrateInProgress == false && GCode.checkHeights == false && EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == false && HeightFunctions.heightsSet == true)
            {
                Program.mainFormTest.setHeightsInvoke();

                if (Calibration.calibrationState == true && HeightFunctions.checkHeightsOnly == false)
                {
                    Calibration.calibrateInProgress = true;

                    /*
                     * if (EEPROMFunctions.EEPROMRequestSent == false)
                     * {
                     *  EEPROMFunctions.readEEPROM();
                     *  EEPROMFunctions.EEPROMRequestSent = true;
                     * }
                     */

                    if (UserVariables.advancedCalibration == false || GCode.isHeuristicComplete == true)
                    {
                        UserInterface.logConsole("Calibration Iteration Number: " + Calibration.iterationNum);
                        Calibration.calibrate();

                        Program.mainFormTest.setEEPROMGUIList();
                        EEPROMFunctions.sendEEPROM();

                        if (Calibration.calibrationState == false)
                        {
                            GCode.homeAxes();
                            Calibration.calibrationComplete = true;
                            UserInterface.logConsole("Calibration Complete");
                            //end calibration
                        }
                    }
                    else
                    {
                        UserInterface.logConsole("Heuristic Step: " + UserVariables.advancedCalCount);
                        GCode.heuristicLearning();

                        Program.mainFormTest.setEEPROMGUIList();
                        EEPROMFunctions.sendEEPROM();
                    }


                    Calibration.calibrateInProgress = false;
                }
                else
                {
                    if (UserVariables.probeChoice == "FSR")
                    {
                        EEPROM.zMaxLength -= UserVariables.FSROffset;
                        UserInterface.logConsole("Setting Z Max Length with adjustment for FSR");
                    }

                    GCode.homeAxes();

                    UserInterface.logConsole("Heights checked");
                }

                HeightFunctions.heightsSet = false;
            }

            /*
             * else
             * {
             *  UserInterface.logConsole("0: " + Calibration.calibrateInProgress + GCode.checkHeights + EEPROMFunctions.tempEEPROMSet + EEPROMFunctions.EEPROMReadOnly);
             * }
             */
        }
Пример #30
0
        public static void handleInput(string message)
        {
            Program.mainFormTest.setUserVariables();

            if (EEPROMFunctions.tempEEPROMSet == false)
            {
                int   intParse;
                float floatParse2;

                EEPROMFunctions.parseEEPROM(message, out intParse, out floatParse2);
                EEPROMFunctions.setEEPROM(intParse, floatParse2);
            }
            else if (EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == true && EEPROMFunctions.EEPROMReadCount < 1)
            {
                //rm
            }
            else if (GCode.checkHeights == true && EEPROMFunctions.tempEEPROMSet == true && Calibration.calibrateInProgress == false && EEPROMFunctions.EEPROMReadOnly == false)
            {
                GCode.positionFlow();
            }
            else if (Calibration.calibrationState == true && Calibration.calibrateInProgress == false && GCode.checkHeights == false && EEPROMFunctions.tempEEPROMSet == true && EEPROMFunctions.EEPROMReadOnly == false)
            {
                if (HeightFunctions.parseZProbe(message) != 1000 && HeightFunctions.heightsSet == false)
                {
                    HeightFunctions.setHeights(HeightFunctions.parseZProbe(message));
                }
                else if (HeightFunctions.heightsSet == true)
                {
                    Program.mainFormTest.setHeightsInvoke();

                    if (Calibration.calibrationState == true && HeightFunctions.checkHeightsOnly == false)
                    {
                        Calibration.calibrateInProgress = true;

                        /*
                         * if (EEPROMFunctions.EEPROMRequestSent == false)
                         * {
                         *  EEPROMFunctions.readEEPROM();
                         *  EEPROMFunctions.EEPROMRequestSent = true;
                         * }
                         */

                        if (UserVariables.advancedCalibration == false)
                        {
                            UserInterface.logConsole("Calibration Iteration Number: " + Calibration.iterationNum);
                            Calibration.calibrate();

                            Program.mainFormTest.setEEPROMGUIList();
                            EEPROMFunctions.sendEEPROM();

                            if (Calibration.calibrationState == false)
                            {
                                GCode.homeAxes();
                                UserInterface.logConsole("Calibration Complete");
                                //end calibration
                            }
                        }
                        else
                        {
                            UserInterface.logConsole("Heuristic Step: " + UserVariables.advancedCalCount);
                            GCode.heuristicLearning();

                            Program.mainFormTest.setEEPROMGUIList();
                            EEPROMFunctions.sendEEPROM();
                        }


                        Calibration.calibrateInProgress = false;
                    }

                    HeightFunctions.heightsSet = false;
                }
            }

            /*
             * else
             * {
             *  UserInterface.logConsole("0: " + Calibration.calibrateInProgress + GCode.checkHeights + EEPROMFunctions.tempEEPROMSet + EEPROMFunctions.EEPROMReadOnly);
             * }
             */
        }