Esempio n. 1
0
        private void btnCheckGRBL_Click(object sender, EventArgs e)
        {
            float  stepX = 0, stepY = 0, stepZ = 0;
            float  speedX = 0, speedY = 0, speedZ = 0;
            float  maxfX = 0, maxfY = 0, maxfZ = 0;
            string rx, ry, rz;
            int    id;

            if ((GRBLSettings.Count > 0))
            {
                foreach (string setting in GRBLSettings)
                {
                    string[] splt = setting.Split('=');
                    if (splt.Length > 1)
                    {
                        if (int.TryParse(splt[0].Substring(1), out id))
                        {
                            if (id == 100)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out stepX);
                            }
                            else if (id == 101)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out stepY);
                            }
                            else if (id == 102)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out stepZ);
                            }
                            else if (id == 110)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out speedX);
                            }
                            else if (id == 111)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out speedY);
                            }
                            else if (id == 112)
                            {
                                float.TryParse(splt[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out speedZ);
                            }
                        }
                    }
                }
                maxfX = stepX * speedX / 60000; rx = (maxfX < 30) ? "ok" : "problem!";
                maxfY = stepY * speedY / 60000; ry = (maxfY < 30) ? "ok" : "problem!";
                maxfZ = stepZ * speedZ / 60000; rz = (maxfZ < 30) ? "ok" : "problem!";
                if ((maxfX < 30) && (maxfY < 30) && (maxfZ < 30))
                {
                    btnCheckGRBLResult.BackColor = Color.Lime;
                }
                else
                {
                    btnCheckGRBLResult.BackColor = Color.Fuchsia;
                }
                btnCheckGRBLResult.Enabled = true;
                float minF = 1800 / Math.Max(stepX, Math.Max(stepY, stepZ));
                strCheckResult  = "Maximum frequency at a 'STEP' pin (at Arduino UNO, Nano) must not exceed 30kHz.\r\nCalculation: steps/mm ($100) * speed-mm/min ($110) / 60 / 1000\r\n";
                strCheckResult += string.Format("Max frequency X = {0:.##}kHz - {1}\r\nMax frequency Y = {2:.##}kHz - {3}\r\nMax frequency Z = {4:.##}kHz - {5}\r\n\r\n", maxfX, rx, maxfY, ry, maxfZ, rz);
                strCheckResult += "Minimum feedrate (F) must not go below 30 steps/sec.\r\nCalculation: (lowest mm/min) = (30 steps/sec) * (60 sec/min) / (axis steps/mm setting)\r\n";
                strCheckResult += string.Format("Min Feedrate for X = {0:.#}mm/min\r\nMin Feedrate for Y = {1:.#}mm/min\r\nMin Feedrate for Z = {2:.#}mm/min\r\n\r\n", (1800 / stepX), (1800 / stepY), (1800 / stepZ));
                strCheckResult += string.Format("Avoid feedrates (F) below {0:.#}mm/min\r\n", minF);
                strCheckResult += "\r\nSettings are copied to clipboard for further use (e.g. save as text file)";
                System.Windows.Forms.Clipboard.SetText(string.Join("\r\n", GRBLSettings.ToArray()));
                GRBLSettings.Clear();
            }
            else
            {
                if (grblStateNow == grblState.idle)
                {
                    requestSend("$$");      //GRBLSettings.Clear();
                    countCallCheckGRBL = 4; // timer1 will recall this function after 2 seconds
                }
                else
                {
                    addToLog("Wait for IDLE, then try again!");
                }
            }
        }
Esempio n. 2
0
 private void btnGRBLCommand1_Click(object sender, EventArgs e)
 {
     requestSend("$$"); GRBLSettings.Clear();
 }
Esempio n. 3
0
 private void btnGRBLCommand1_Click(object sender, EventArgs e)      // $$and $x=val - View and write Grbl settings
 {
     requestSend("$$"); GRBLSettings.Clear();
 }