Skip to content

Commit ac4b7d3

Browse files
committed
Hangprinter: Allow Hangprinter to be configured with 8 anchors
1 parent 6f235a0 commit ac4b7d3

File tree

2 files changed

+35
-10
lines changed

2 files changed

+35
-10
lines changed

src/Movement/Kinematics/HangprinterKinematics.cpp

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
constexpr size_t DefaultNumAnchors = 4;
2121
// Default anchor coordinates
2222
// These are only placeholders. Each machine must have these values calibrated in order to work correctly.
23-
constexpr float DefaultAnchors[7][3] = {{ 0.0, -2000.0, -100.0},
23+
constexpr float DefaultAnchors[8][3] = {{ 0.0, -2000.0, -100.0},
2424
{ 2000.0, 1000.0, -100.0},
2525
{-2000.0, 1000.0, -100.0},
2626
{ 0.0, 0.0, 3000.0},
2727
{ 0.0, 0.0, 0.0},
2828
{ 0.0, 0.0, 0.0},
29+
{ 0.0, 0.0, 0.0},
2930
{ 0.0, 0.0, 0.0}};
3031
constexpr float DefaultPrintRadius = 1500.0;
3132

@@ -85,13 +86,13 @@ void HangprinterKinematics::Init() noexcept
8586
* In practice you might want to compensate a bit more or a bit less */
8687
constexpr float DefaultSpoolBuildupFactor = 0.007;
8788
/* Measure and set spool radii with M669 to achieve better accuracy */
88-
constexpr float DefaultSpoolRadii[HANGPRINTER_MAX_AXES] = { 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0}; // HP4 default
89+
constexpr float DefaultSpoolRadii[HANGPRINTER_MAX_AXES] = { 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0}; // HP4 default
8990
/* If axis runs lines back through pulley system, set mechanical advantage accordingly with M669 */
90-
constexpr uint32_t DefaultMechanicalAdvantage[HANGPRINTER_MAX_AXES] = { 2, 2, 2, 2, 2, 2, 4}; // HP4 default
91-
constexpr uint32_t DefaultLinesPerSpool[HANGPRINTER_MAX_AXES] = { 1, 1, 1, 1, 1, 1, 1}; // HP4 default
92-
constexpr uint32_t DefaultMotorGearTeeth[HANGPRINTER_MAX_AXES] = { 20, 20, 20, 20, 20, 20, 20}; // HP4 default
93-
constexpr uint32_t DefaultSpoolGearTeeth[HANGPRINTER_MAX_AXES] = { 255, 255, 255, 255, 255, 255, 255}; // HP4 default
94-
constexpr uint32_t DefaultFullStepsPerMotorRev[HANGPRINTER_MAX_AXES] = { 25, 25, 25, 25, 25, 25, 25};
91+
constexpr uint32_t DefaultMechanicalAdvantage[HANGPRINTER_MAX_AXES] = { 2, 2, 2, 2, 2, 2, 2, 4}; // HP4 default
92+
constexpr uint32_t DefaultLinesPerSpool[HANGPRINTER_MAX_AXES] = { 1, 1, 1, 1, 1, 1, 1, 1}; // HP4 default
93+
constexpr uint32_t DefaultMotorGearTeeth[HANGPRINTER_MAX_AXES] = { 20, 20, 20, 20, 20, 20, 20, 20}; // HP4 default
94+
constexpr uint32_t DefaultSpoolGearTeeth[HANGPRINTER_MAX_AXES] = { 255, 255, 255, 255, 255, 255, 255, 255}; // HP4 default
95+
constexpr uint32_t DefaultFullStepsPerMotorRev[HANGPRINTER_MAX_AXES] = { 25, 25, 25, 25, 25, 25, 25, 25};
9596
ARRAY_INIT(anchors, DefaultAnchors);
9697
numAnchors = DefaultNumAnchors;
9798
printRadius = DefaultPrintRadius;
@@ -205,6 +206,14 @@ bool HangprinterKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, const
205206
return true;
206207
}
207208
}
209+
if (numAnchors > 7)
210+
{
211+
if (gb.TryGetFloatArray('H', 3, anchors[H_AXIS], reply, seen))
212+
{
213+
error = true;
214+
return true;
215+
}
216+
}
208217

209218
if (gb.Seen('P'))
210219
{
@@ -246,6 +255,11 @@ bool HangprinterKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, const
246255
reply.lcatf("G:%.2f, %.2f, %.2f\n",
247256
(double)anchors[G_AXIS][X_AXIS], (double)anchors[G_AXIS][Y_AXIS], (double)anchors[G_AXIS][Z_AXIS]);
248257
}
258+
if (numAnchors > 7)
259+
{
260+
reply.lcatf("H:%.2f, %.2f, %.2f\n",
261+
(double)anchors[H_AXIS][X_AXIS], (double)anchors[H_AXIS][Y_AXIS], (double)anchors[H_AXIS][Z_AXIS]);
262+
}
249263
}
250264
}
251265
else if (mCode == 666)
@@ -581,6 +595,16 @@ bool HangprinterKinematics::WriteCalibrationParameters(FileStore *f) const noexc
581595
}
582596
}
583597

598+
if (numAnchors > 7)
599+
{
600+
scratchString.printf(" H%.3f:%.3f:%.3f",
601+
(double)anchors[H_AXIS][X_AXIS], (double)anchors[H_AXIS][Y_AXIS], (double)anchors[H_AXIS][Z_AXIS]);
602+
if (!f->Write(scratchString.c_str()))
603+
{
604+
return false;
605+
}
606+
}
607+
584608
scratchString.printf(" P%.1f\n", (double)printRadius);
585609
if (!f->Write(scratchString.c_str()))
586610
{
@@ -797,8 +821,8 @@ void HangprinterKinematics::PrintParameters(const StringRef& reply) const noexce
797821
HangprinterKinematics::ODriveAnswer HangprinterKinematics::GetODrive3EncoderEstimate(DriverId const driver, bool const makeReference, const StringRef& reply, bool const subtractReference) THROWS(GCodeException)
798822
{
799823
const uint8_t cmd = CANSimple::MSG_GET_ENCODER_ESTIMATES;
800-
static CanAddress seenDrives[HANGPRINTER_MAX_AXES] = { 0, 0, 0, 0, 0, 0, 0 };
801-
static float referencePositions[HANGPRINTER_MAX_AXES] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
824+
static CanAddress seenDrives[HANGPRINTER_MAX_AXES] = { 0, 0, 0, 0, 0, 0, 0, 0 };
825+
static float referencePositions[HANGPRINTER_MAX_AXES] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
802826
static size_t numSeenDrives = 0;
803827
size_t thisDriveIdx = 0;
804828

src/Movement/Kinematics/HangprinterKinematics.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ class HangprinterKinematics : public RoundBedKinematics
5252

5353
private:
5454
// Basic facts about movement system
55-
static constexpr size_t HANGPRINTER_MAX_AXES = 7;
55+
static constexpr size_t HANGPRINTER_MAX_AXES = 8;
5656
static constexpr size_t A_AXIS = 0;
5757
static constexpr size_t B_AXIS = 1;
5858
static constexpr size_t C_AXIS = 2;
5959
static constexpr size_t D_AXIS = 3;
6060
static constexpr size_t E_AXIS = 4;
6161
static constexpr size_t F_AXIS = 5;
6262
static constexpr size_t G_AXIS = 6;
63+
static constexpr size_t H_AXIS = 7;
6364

6465
void Init() noexcept;
6566
void Recalc() noexcept;

0 commit comments

Comments
 (0)