Skip to content

Commit

Permalink
Support extrusion heater feedforward even if IOBITS not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dc42 committed Nov 13, 2024
1 parent 1894b35 commit 2908f2b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
13 changes: 8 additions & 5 deletions src/Movement/DDARing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ uint32_t DDARing::ManageLaserPower() noexcept

#endif

#if SUPPORT_IOBITS

// Manage the IOBITS (G1 P parameter) and extruder heater feedforward. Called by the Laser task.
uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
{
#if SUPPORT_IOBITS
PortControl& pc = reprap.GetPortControl();
bool doneIoBits = !pc.IsConfigured();
#endif
bool doneFeedForward = false;
bool setFeedForward = false;
uint32_t nextWakeupDelay = StepClockRate;
Expand All @@ -741,6 +741,7 @@ uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
{
const int32_t timeToMoveStart = (int32_t)(cdda->GetMoveStartTime() - now); // get the time to the start of the move, negative if the move has started
const int32_t timeToMoveEnd = timeToMoveStart + (int32_t)cdda->GetClocksNeeded(); // get the time to the move ended, negative if the move has ended
#if SUPPORT_IOBITS
if (!doneIoBits && timeToMoveStart < (int32_t)pc.GetAdvanceClocks() && timeToMoveEnd > (int32_t)pc.GetAdvanceClocks())
{
// This move is current from the perspective of IOBits
Expand All @@ -756,8 +757,8 @@ uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
break;
}
}

if (!doneFeedForward)
#endif
{
feedForwardTool = cdda->GetTool();
if (feedForwardTool != nullptr && timeToMoveStart < (int32_t)feedForwardTool->GetFeedForwardAdvanceClocks() && timeToMoveEnd > (int32_t)feedForwardTool->GetFeedForwardAdvanceClocks())
Expand All @@ -772,7 +773,9 @@ uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
}
nextWakeupDelay = min<uint32_t>(nextWakeupDelay, (uint32_t)timeToMoveEnd > feedForwardTool->GetFeedForwardAdvanceClocks());
doneFeedForward = true;
#if SUPPORT_IOBITS
if (doneIoBits)
#endif
{
break;
}
Expand All @@ -781,10 +784,12 @@ uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
cdda = cdda->GetNext();
}

#if SUPPORT_IOBITS
if (!doneIoBits)
{
pc.UpdatePorts(0); // no move active so turn off all IOBITS ports
}
#endif

SetBasePriority(0);

Expand All @@ -807,8 +812,6 @@ uint32_t DDARing::ManageIOBitsAndFeedForward() noexcept
return (nextWakeupDelay + StepClockRate/1000 - 1)/(StepClockRate/1000); // convert step clocks to milliseconds, rounding up
}

#endif

#if SUPPORT_REMOTE_COMMANDS

// Add a move from the ATE to the movement queue
Expand Down
2 changes: 0 additions & 2 deletions src/Movement/DDARing.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class DDARing INHERIT_OBJECT_MODEL
#if SUPPORT_LASER
uint32_t ManageLaserPower() noexcept; // Manage the laser power
#endif
#if SUPPORT_IOBITS
uint32_t ManageIOBitsAndFeedForward() noexcept; // Manage the IOBITS (G1 P parameter) and extruder heater feedforward
#endif

void RecordLookaheadError() noexcept { ++numLookaheadErrors; } // Record a lookahead error
void Diagnostics(MessageType mtype, unsigned int ringNumber) noexcept;
Expand Down
8 changes: 3 additions & 5 deletions src/Movement/Move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ void Move::LaserTaskRun() noexcept
else
#endif

# if SUPPORT_LASER
#if SUPPORT_LASER
if (gcodes.GetMachineType() == MachineType::laser)
{
// Manage the laser power
Expand All @@ -1560,16 +1560,14 @@ void Move::LaserTaskRun() noexcept
}
}
else
# endif
#endif
{
# if SUPPORT_IOBITS
// Manage the IOBits
// Manage the feedforward and IOBits
uint32_t ticks;
while ((ticks = rings[0].ManageIOBitsAndFeedForward()) != 0)
{
(void)TaskBase::TakeIndexed(NotifyIndices::Laser, ticks);
}
# endif
}
}
}
Expand Down

0 comments on commit 2908f2b

Please sign in to comment.