private void RelativeJog(JogDirections direction) { Machine.SendCommand("G91"); switch (direction) { case JogDirections.XPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} X{XYStepSize.ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.YPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Y{(XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.ZPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.XMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} X{(-XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.YMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Y{(-XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.ZMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(-ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T0Minus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(-ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T0Plus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T1Minus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(-ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T1Plus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; } Machine.SendCommand("G90"); }
public void Jog(JogDirections direction) { if ((Machine.Settings.MachineType == FirmwareTypes.Repeteir_PnP || Machine.Settings.MachineType == FirmwareTypes.Marlin_Laser || Machine.Settings.MachineType == FirmwareTypes.Marlin || Machine.Settings.MachineType == FirmwareTypes.GRBL1_1) && (direction != JogDirections.CMinus && direction != JogDirections.CPlus) ) { RelativeJog(direction); } else { AbsoluteJog(direction); } }
private void AbsoluteJog(JogDirections direction) { var current = Machine.WorkspacePosition; switch (direction) { case JogDirections.XPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} X{(current.X + XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.YPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Y{(current.Y + XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.ZPlus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(current.Z + ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.XMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} X{(current.X - XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.YMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Y{(current.Y - XYStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.ZMinus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(current.Z - ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T0Minus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(Machine.Tool0 - ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T0Plus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(Machine.Tool0 + ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T1Minus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(Machine.Tool1 - ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.T1Plus: Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} Z{(Machine.Tool1 + ZStepSize).ToDim()} F{Machine.Settings.JogFeedRate}"); break; case JogDirections.CMinus: { var newAngle = Math.Round(Machine.Tool2 - 90); var normalizedAngle = newAngle % 360; if (normalizedAngle < 0) { normalizedAngle += 360; } var xOffset = -(Math.Sin(normalizedAngle.ToRadians()) * ShaftOffsetCorrection); var yOffset = -(Math.Cos(normalizedAngle.ToRadians()) * ShaftOffsetCorrection); Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} E{(newAngle).ToDim()} F5000"); Machine.SendCommand("G90"); Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} E{(newAngle).ToDim()} F5000"); Machine.SendCommand("G91"); Machine.SendCommand($"G0 X{xOffset.ToDim()} Y{yOffset.ToDim()}"); Machine.SendCommand("G90"); Debug.WriteLine($"New Angle {newAngle}°, Normalized {normalizedAngle}° Correction: ({xOffset.ToDim()} - {yOffset.ToDim()})"); } break; case JogDirections.CPlus: { var newAngle = Math.Round(Machine.Tool2 + 90); var normalizedAngle = newAngle % 360; if (normalizedAngle < 0) { normalizedAngle += 360; } var xOffset = -(Math.Sin(normalizedAngle.ToRadians()) * ShaftOffsetCorrection); var yOffset = -(Math.Cos(normalizedAngle.ToRadians()) * ShaftOffsetCorrection); Machine.SendCommand($"{Machine.Settings.JogGCodeCommand} E{(newAngle).ToDim()} F5000"); Machine.SendCommand("G91"); Machine.SendCommand($"G0 X{xOffset.ToDim()} Y{yOffset.ToDim()}"); Machine.SendCommand("G90"); Debug.WriteLine($"New Angle {newAngle}°, Normalized {normalizedAngle}° Correction: ({xOffset.ToDim()} - {yOffset.ToDim()})"); } break; } }