Skip to content

Commit

Permalink
Work towards Duet board support. Temp commit to move to another machine
Browse files Browse the repository at this point in the history
  • Loading branch information
jkuusama committed Nov 15, 2022
1 parent 1d826ad commit 50f9c06
Show file tree
Hide file tree
Showing 14 changed files with 1,175 additions and 473 deletions.
12 changes: 9 additions & 3 deletions LitePlacer/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ public partial class MySettings
}
block. Visual Studio bug doesn't allow that, so they are here. :-(
*/
public double Duet3_Xspeed { get; set; } = 1000; // mm/s
public double Duet3_Xspeed { get; set; } = 5000; // mm/s
public double Duet3_XHomingSpeed { get; set; } = 500; // mm/s
public double Duet3_Yspeed { get; set; } = 200; // mm/s
public double Duet3_XHomingBackoff { get; set; } = 5; // mm

public double Duet3_Yspeed { get; set; } = 5000; // mm/s
public double Duet3_YHomingSpeed { get; set; } = 500; // mm/s
public double Duet3_YHomingBackoff { get; set; } = 5; // mm

public double Duet3_Zspeed { get; set; } = 50; // mm/s
public double Duet3_ZHomingSpeed { get; set; } = 500; // mm/s
public double Duet3_ZHomingBackoff { get; set; } = 5; // mm

public double Duet3_Aspeed { get; set; } = 200; // mm/s

public double Duet3_Xacc { get; set; } = 1000; // mm/s^2
Expand Down Expand Up @@ -76,7 +82,7 @@ public partial class MySettings
public int Duet3_XCurrent { get; set; } = 1100; //mA
public int Duet3_YCurrent { get; set; } = 1200; //mA
public int Duet3_ZCurrent { get; set; } = 1300; //mA
public int Duet3_ACurrent { get; set; } = 400; //mA
public int Duet3_ACurrent { get; set; } = 100; //mA
// =================================================================================


Expand Down
45 changes: 37 additions & 8 deletions LitePlacer/CNC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class CNC

public enum ControlBoardType { TinyG, Duet3, other, unknown };
// see AppSettings.cs, CNC_boardtype
public ControlBoardType Controlboard { get; set; } = ControlBoardType.unknown;
public static ControlBoardType Controlboard { get; set; } = ControlBoardType.unknown;

public bool SlackCompensation { get; set; }
public double SlackCompensationDistance { get; set; }
Expand Down Expand Up @@ -163,12 +163,17 @@ public double RegularMoveTimeout // in seconds
// Therefore, for each movement when the user wants to go to (X, Y),
// we really go to (X - 0.002*Y, Y)

// CurrentX, CurrentXY are the corrected values that user and MainForm sees and uses.
// CurrentX, CurrentY are the corrected values that user and MainForm sees and uses.
// These reflect a square machine.
// TrueX/Y is what the control board actually uses.

// CurrentZ, CurrentA are the values that user and MainForm sees and uses; no correction at the moment

// TinyG sends position reports as status info, and updates UI based on those.
// Duet 3 doesn't, so we need to keeo UI updated ourselves. On some commands, we
// can call UI update routines directly. On some, we set temporary position and a flag,
// so that Duet3 knows to update UI on "ok" message

public static double SquareCorrection { get; set; }

private static double CurrX;
Expand Down Expand Up @@ -198,11 +203,14 @@ public double CurrentX
}
}

public static void setCurrX(double x)
public void SetCurrentX(double x)
{
_trueX = x;
CurrX = x - CurrY * SquareCorrection;
//MainForm.DisplayText("CNC.setCurrX: x= " + x.ToString() + ", CurrX= " + CurrX.ToString() + ", CurrY= " + CurrY.ToString());
if (Controlboard == ControlBoardType.Duet3)
{
MainForm.Update_Xposition(CurrX.ToString("0.000", CultureInfo.InvariantCulture));
}
}


Expand All @@ -220,11 +228,15 @@ public double CurrentY
}
}

public static void setCurrY(double y)
public void SetCurrentY(double y)
{
CurrY = y;
CurrX = _trueX - CurrY * SquareCorrection;
//MainForm.DisplayText("CNC.setCurrY: "+ y.ToString()+ " CurrX= " + CurrX.ToString());
if (Controlboard == ControlBoardType.Duet3)
{
MainForm.Update_Yposition(y.ToString("0.000", CultureInfo.InvariantCulture));
MainForm.Update_Xposition(CurrX.ToString("0.000", CultureInfo.InvariantCulture));
}
}


Expand All @@ -240,9 +252,13 @@ public double CurrentZ
CurrZ = value;
}
}
public static void setCurrZ(double z)
public void SetCurrentZ(double z)
{
CurrZ = z;
if (Controlboard == ControlBoardType.Duet3)
{
MainForm.Update_Zposition(z.ToString("0.000", CultureInfo.InvariantCulture));
}
}


Expand All @@ -258,9 +274,13 @@ public double CurrentA
CurrA = value;
}
}
public static void setCurrA(double a)
public void SetCurrentA(double a)
{
CurrA = a;
if (Controlboard == ControlBoardType.Duet3)
{
MainForm.Update_Aposition(a.ToString("0.000", CultureInfo.InvariantCulture));
}
}


Expand All @@ -275,6 +295,10 @@ public void SetPosition(string X, string Y, string Z, string A)
if (Controlboard == ControlBoardType.Duet3)
{
Duet3.SetPosition(X, Y, Z, A);
MainForm.Update_Xposition(X);
MainForm.Update_Yposition(Y);
MainForm.Update_Zposition(Z);
MainForm.Update_Aposition(A);
}
else if (Controlboard == ControlBoardType.TinyG)
{
Expand Down Expand Up @@ -1063,6 +1087,7 @@ public decimal SmallMovementSpeed

public bool Home_m(string axis)
{
Homing = true;
if (ErrorState)
{
MainForm.DisplayText("*** Cnc.Home_m(), board in error state.", KnownColor.DarkRed, true);
Expand All @@ -1072,11 +1097,13 @@ public bool Home_m(string axis)
{
if (Duet3.Home_m(axis))
{
Homing = false;
return true;
}
else
{
RaiseError();
Homing = false;
return false;
}
};
Expand All @@ -1085,11 +1112,13 @@ public bool Home_m(string axis)
{
if (TinyG.Home_m(axis))
{
Homing = false;
return true;
}
else
{
RaiseError();
Homing = false;
return false;
}
};
Expand Down
Loading

0 comments on commit 50f9c06

Please sign in to comment.