G32 and G92 improvements

1. G92 with a Z value now sets exactly that Z value even if bed
compensation is in effect.
2. If G32 is run before the Z axis is homed, the first bed probe in the
G32 sequence homes the Z axiws.
This commit is contained in:
David Crocker 2014-02-07 23:06:20 +00:00
parent 25ad6c9f85
commit 2d61bba024
5 changed files with 34 additions and 18 deletions

View file

@ -24,8 +24,8 @@ Licence: GPL
#define CONFIGURATION_H #define CONFIGURATION_H
#define NAME "RepRapFirmware" #define NAME "RepRapFirmware"
#define VERSION "0.57k-dc42" #define VERSION "0.57l-dc42"
#define DATE "2014-02-06" #define DATE "2014-02-07"
#define LAST_AUTHOR "reprappro.com" #define LAST_AUTHOR "reprappro.com"
// Other firmware that we might switch to be compatible with. // Other firmware that we might switch to be compatible with.

View file

@ -84,7 +84,7 @@ void GCodes::Init()
active = true; active = true;
longWait = platform->Time(); longWait = platform->Time();
dwellTime = longWait; dwellTime = longWait;
axisIsHomed[0] = axisIsHomed[1] = axisIsHomed[2] = false; axisIsHomed[X_AXIS] = axisIsHomed[Y_AXIS] = axisIsHomed[Z_AXIS] = false;
} }
void GCodes::doFilePrint(GCodeBuffer* gb) void GCodes::doFilePrint(GCodeBuffer* gb)
@ -518,6 +518,9 @@ bool GCodes::SetPositions(GCodeBuffer *gb)
return false; return false;
LoadMoveBufferFromGCode(gb, true, false); LoadMoveBufferFromGCode(gb, true, false);
// Transform the position so that e.g. if the user does G92 Z0,
// the position we report (which gets inverse-transformed) really is Z=0 afterwards
reprap.GetMove()->Transform(moveBuffer);
reprap.GetMove()->SetLiveCoordinates(moveBuffer); reprap.GetMove()->SetLiveCoordinates(moveBuffer);
reprap.GetMove()->SetPositions(moveBuffer); reprap.GetMove()->SetPositions(moveBuffer);
@ -597,7 +600,7 @@ bool GCodes::DoHome(char* reply, bool& error)
homeX = false; homeX = false;
homeY = false; homeY = false;
homeZ = false; homeZ = false;
axisIsHomed[0] = axisIsHomed[1] = axisIsHomed[2] = true; axisIsHomed[X_AXIS] = axisIsHomed[Y_AXIS] = axisIsHomed[Z_AXIS] = true;
return true; return true;
} }
return false; return false;
@ -609,7 +612,7 @@ bool GCodes::DoHome(char* reply, bool& error)
{ {
homeAxisMoveCount = 0; homeAxisMoveCount = 0;
homeX = false; homeX = false;
axisIsHomed[0] = true; axisIsHomed[X_AXIS] = true;
return NoHome(); return NoHome();
} }
return false; return false;
@ -622,7 +625,7 @@ bool GCodes::DoHome(char* reply, bool& error)
{ {
homeAxisMoveCount = 0; homeAxisMoveCount = 0;
homeY = false; homeY = false;
axisIsHomed[1] = true; axisIsHomed[Y_AXIS] = true;
return NoHome(); return NoHome();
} }
return false; return false;
@ -631,7 +634,7 @@ bool GCodes::DoHome(char* reply, bool& error)
if(homeZ) if(homeZ)
{ {
if (!(axisIsHomed[0] && axisIsHomed[1])) if (!(axisIsHomed[X_AXIS] && axisIsHomed[Y_AXIS]))
{ {
// We can only home Z if X and Y have already been homed. Possibly this should only be if we are using an IR probe. // We can only home Z if X and Y have already been homed. Possibly this should only be if we are using an IR probe.
strncpy(reply, "Must home X and Y before homing Z", STRING_LENGTH); strncpy(reply, "Must home X and Y before homing Z", STRING_LENGTH);
@ -643,7 +646,7 @@ bool GCodes::DoHome(char* reply, bool& error)
{ {
homeAxisMoveCount = 0; homeAxisMoveCount = 0;
homeZ = false; homeZ = false;
axisIsHomed[2] = true; axisIsHomed[Z_AXIS] = true;
return NoHome(); return NoHome();
} }
return false; return false;
@ -702,7 +705,10 @@ bool GCodes::DoSingleZProbeAtPoint()
activeDrive[DRIVES] = true; activeDrive[DRIVES] = true;
reprap.GetMove()->SetZProbing(true); reprap.GetMove()->SetZProbing(true);
if(DoCannedCycleMove(true)) if(DoCannedCycleMove(true))
{
cannedCycleMoveCount++; cannedCycleMoveCount++;
axisIsHomed[Z_AXIS] = true; // we now home the Z-axis in Move.cpp it is wasn't already
}
return false; return false;
case 3: case 3:
@ -741,7 +747,7 @@ bool GCodes::DoSingleZProbe()
{ {
cannedCycleMoveCount = 0; cannedCycleMoveCount = 0;
probeCount = 0; probeCount = 0;
axisIsHomed[2] = true; // we have homed the Z axis axisIsHomed[Z_AXIS] = true; // we have homed the Z axis
return true; return true;
} }
return false; return false;
@ -1315,7 +1321,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
break; break;
case 32: // Probe Z at multiple positions and generate the bed transform case 32: // Probe Z at multiple positions and generate the bed transform
if (!(axisIsHomed[0] && axisIsHomed[1])) if (!(axisIsHomed[X_AXIS] && axisIsHomed[Y_AXIS]))
{ {
// We can only do a Z probe if X and Y have already been homed // We can only do a Z probe if X and Y have already been homed
strncpy(reply, "Must home X and Y before bed probing", STRING_LENGTH); strncpy(reply, "Must home X and Y before bed probing", STRING_LENGTH);

View file

@ -98,8 +98,6 @@ void Move::Init()
lastMove->Release(); lastMove->Release();
liveCoordinates[DRIVES] = platform->HomeFeedRate(Z_AXIS); liveCoordinates[DRIVES] = platform->HomeFeedRate(Z_AXIS);
checkEndStopsOnNextMove = false;
SetStepHypotenuse(); SetStepHypotenuse();
currentFeedrate = -1.0; currentFeedrate = -1.0;
@ -169,6 +167,7 @@ void Move::Spin()
// If there's a G Code move available, add it to the look-ahead // If there's a G Code move available, add it to the look-ahead
// ring for processing. // ring for processing.
bool checkEndStopsOnNextMove;
if(gCodes->ReadMove(nextMove, checkEndStopsOnNextMove)) if(gCodes->ReadMove(nextMove, checkEndStopsOnNextMove))
{ {
Transform(nextMove); Transform(nextMove);

15
Move.h
View file

@ -227,7 +227,6 @@ class Move
float lastTime; float lastTime;
bool addNoMoreMoves; bool addNoMoreMoves;
bool active; bool active;
bool checkEndStopsOnNextMove;
float currentFeedrate; float currentFeedrate;
float nextMove[DRIVES + 1]; // Extra is for feedrate float nextMove[DRIVES + 1]; // Extra is for feedrate
float stepDistances[(1<<AXES)]; // Index bits: lsb -> dx, dy, dz <- msb float stepDistances[(1<<AXES)]; // Index bits: lsb -> dx, dy, dz <- msb
@ -547,13 +546,25 @@ inline void Move::HitLowStop(int8_t drive, LookAhead* la, DDA* hitDDA)
{ {
if(zProbing) if(zProbing)
{ {
// Executing G32, so record the Z position at which we hit the end stop
if (gCodes->GetAxisIsHomed(drive))
{
// Z-axis has already been homed, so just record the height of the bed at this point
lastZHit = ComputeCurrentCoordinate(drive, la, hitDDA); lastZHit = ComputeCurrentCoordinate(drive, la, hitDDA);
la->SetDriveCoordinateAndZeroEndSpeed(lastZHit, drive); la->SetDriveCoordinateAndZeroEndSpeed(lastZHit, drive);
lastZHit = lastZHit - platform->ZProbeStopHeight(); lastZHit = lastZHit - platform->ZProbeStopHeight();
}
else
{
// Z axis has not yet been homed, so treat this probe as a homing command
la->SetDriveCoordinateAndZeroEndSpeed(platform->ZProbeStopHeight(), drive);
lastZHit = 0.0;
}
return; return;
} else } else
{ {
lastZHit = platform->ZProbeStopHeight(); // Should never be used. // Executing G30, so set the current Z height to the value at which the end stop is triggered
lastZHit = platform->ZProbeStopHeight();
hitPoint = lastZHit; hitPoint = lastZHit;
} }
} }

Binary file not shown.