Ability to specify bed Z probe points added. See M505.

This commit is contained in:
Adrian Bowyer 2013-11-15 22:04:52 +00:00
parent 4c293f767f
commit c7286905b2
9 changed files with 30289 additions and 30023 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
SENT: M105
ok T:108.4 /-273.1 B:38.5 /-273.1 @:0
SENT: G31
RECV: ok
SENDING:M20
SENT: M20
Begin file list
RECV: Begin file list
PS-COV~3.GCO
RECV: PS-COV~3.GCO
BIGCIRC.G
RECV: BIGCIRC.G
CIRCLE.G
RECV: CIRCLE.G
CROCCLIP.G
RECV: CROCCLIP.G
KNIGHT7.G
RECV: KNIGHT7.G
KTST.G
RECV: KTST.G
SQUARE.G
RECV: SQUARE.G
End file list
RECV: End file list
RECV: ok
SENT: M23 circle.g
File opened:circle.g Size:1030
RECV: File opened:circle.g Size:1030
File selected
RECV: File selected
RECV: ok
SENT: M24
Print Started at: 17:03:28
RECV: ok
SENDING:M114
SENT: M114
X:0.000Y:0.000Z:0.000E:0.000 Count X:0.000Y:0.000Z:0.000
RECV: X:0.000Y:0.000Z:0.000E:0.000 Count X:0.000Y:0.000Z:0.000
RECV: ok
SENT: M140 S55.0
Setting bed temperature to 55.000000 degrees Celsius.
RECV: ok
SENT: M104 S205
Setting hotend temperature to 205.000000 degrees Celsius.
RECV: ok

View file

@ -393,7 +393,7 @@ bool GCodes::DoSingleZProbe()
switch(cannedCycleMoveCount)
{
case 0:
case 0: // This only does anything on the first move; on all the others Z is already there
moveToDo[Z_AXIS] = Z_DIVE;
action[Z_AXIS] = true;
moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS);
@ -422,10 +422,17 @@ bool GCodes::DoSingleZProbe()
action[DRIVES] = true;
reprap.GetMove()->SetZProbing(true);
if(DoCannedCycleMove(moveToDo, action, true))
{
// platform->GetLine()->Write(platform->ZProbe());
cannedCycleMoveCount++;
}
return false;
case 3:
moveToDo[Z_AXIS] = Z_DIVE;
action[Z_AXIS] = true;
moveToDo[DRIVES] = platform->HomeFeedRate(Z_AXIS);
action[DRIVES] = true;
reprap.GetMove()->SetZProbing(false);
if(DoCannedCycleMove(moveToDo, action, false))
cannedCycleMoveCount++;
return false;
default:
@ -460,24 +467,8 @@ bool GCodes::DoMultipleZProbe()
bool GCodes::GetProbeCoordinates(int count, float& x, float& y, float& z)
{
switch(count)
{
case 0:
x = 0.2*platform->AxisLength(X_AXIS);
y = 0.2*platform->AxisLength(Y_AXIS);
break;
case 1:
x = 0.8*platform->AxisLength(X_AXIS);
y = 0.2*platform->AxisLength(Y_AXIS);
break;
case 2:
x = 0.5*platform->AxisLength(X_AXIS);
y = 0.8*platform->AxisLength(Y_AXIS);
break;
default:
platform->Message(HOST_MESSAGE, "probeCount beyond maximum requested.\n");
break;
}
x = reprap.GetMove()->xBedProbePoint(count);
y = reprap.GetMove()->yBedProbePoint(count);
z = bedZs[count];
return zProbesSet;
}
@ -652,7 +643,7 @@ bool GCodes::StandbyHeaters()
{
if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
return false;
for(int8_t heater = 0; heater < DRIVES; heater++)
for(int8_t heater = 0; heater < HEATERS; heater++)
reprap.GetHeat()->Standby(heater);
return true;
}
@ -731,6 +722,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
{
int code;
float value;
int iValue;
char* str;
bool result = true;
bool error = false;
@ -814,7 +806,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
error = true;
snprintf(reply, STRING_LENGTH, "invalid G Code: %s", gb->Buffer());
}
if(result == true)
if(result)
HandleReply(error, gb == serialGCode, reply, 'G', code);
return result;
}
@ -1077,6 +1069,17 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
}
break;
case 505: // Set Z probe point coordinates
if(gb->Seen('P'))
{
iValue = gb->GetIValue();
if(gb->Seen(gCodeLetters[X_AXIS]))
reprap.GetMove()->SetXBedProbePoint(iValue, gb->GetFValue());
if(gb->Seen(gCodeLetters[Y_AXIS]))
reprap.GetMove()->SetYBedProbePoint(iValue, gb->GetFValue());
}
break;
case 906: // Set Motor currents
for(uint8_t i = 0; i < DRIVES; i++)
{
@ -1092,7 +1095,7 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
error = true;
snprintf(reply, STRING_LENGTH, "invalid M Code: %s", gb->Buffer());
}
if(result == true)
if(result)
HandleReply(error, gb == serialGCode, reply, 'M', code);
return result;
}
@ -1122,14 +1125,14 @@ bool GCodes::ActOnGcode(GCodeBuffer *gb)
if(error)
snprintf(reply, STRING_LENGTH, "invalid T Code: %s", gb->Buffer());
if(result == true)
if(result)
HandleReply(error, gb == serialGCode, reply, 'T', code);
return result;
}
// An empty buffer jumps to here and gets discarded
if(result == true)
if(result)
HandleReply(error, gb == serialGCode, reply, 'X', code);
return result;

View file

@ -152,6 +152,15 @@ void Move::Init()
lastZHit = 0.0;
zProbing = false;
xBedProbePoints[0] = 0.2*platform->AxisLength(X_AXIS);
yBedProbePoints[0] = 0.2*platform->AxisLength(Y_AXIS);
xBedProbePoints[1] = 0.8*platform->AxisLength(X_AXIS);
yBedProbePoints[1] = 0.2*platform->AxisLength(Y_AXIS);
xBedProbePoints[2] = 0.5*platform->AxisLength(X_AXIS);
yBedProbePoints[2] = 0.8*platform->AxisLength(Y_AXIS);
lastTime = platform->Time();
longWait = lastTime;
active = true;

39
Move.h
View file

@ -159,6 +159,10 @@ class Move
void HitLowStop(int8_t drive, LookAhead* la, DDA* hitDDA);
void HitHighStop(int8_t drive, LookAhead* la, DDA* hitDDA);
void SetPositions(float move[]);
void SetXBedProbePoint(int index, float x);
void SetYBedProbePoint(int index, float y);
float xBedProbePoint(int index);
float yBedProbePoint(int index);
void SetZProbing(bool probing);
void SetProbedBedPlane();
float GetLastProbedZ();
@ -213,6 +217,8 @@ class Move
float stepDistances[(1<<AXES)]; // Index bits: lsb -> dx, dy, dz <- msb
float extruderStepDistances[(1<<(DRIVES-AXES))]; // NB - limits us to 5 extruders
long nextMachineEndPoints[DRIVES+1];
float xBedProbePoints[NUMBER_OF_PROBE_POINTS];
float yBedProbePoints[NUMBER_OF_PROBE_POINTS];
float aX, aY, aC; // Bed plane explicit equation z' = z + aX*x + aY*y + aC
bool zPlaneSet;
float tanXY, tanYZ, tanXZ; // 90 degrees + angle gives angle between axes
@ -393,10 +399,35 @@ inline void Move::ResumeMoving()
addNoMoreMoves = false;
}
//inline bool Move::ZProbing()
//{
// return zProbing;
//}
inline void Move::SetXBedProbePoint(int index, float x)
{
if(index < 0 || index >= NUMBER_OF_PROBE_POINTS)
{
platform->Message(HOST_MESSAGE, "Z probe point X index out of range.\n");
return;
}
xBedProbePoints[index] = x;
}
inline void Move::SetYBedProbePoint(int index, float y)
{
if(index < 0 || index >= NUMBER_OF_PROBE_POINTS)
{
platform->Message(HOST_MESSAGE, "Z probe point Y index out of range.\n");
return;
}
yBedProbePoints[index] = y;
}
inline float Move::xBedProbePoint(int index)
{
return xBedProbePoints[index];
}
inline float Move::yBedProbePoint(int index)
{
return yBedProbePoints[index];
}
inline void Move::SetZProbing(bool probing)
{

View file

@ -355,6 +355,8 @@ inline void Platform::PollZHeight()
EndStopHit Platform::Stopped(int8_t drive)
{
if(zProbePin >= 0)
{
if(drive == Z_AXIS)
{
if(ZProbe() > zProbeADValue)
@ -362,6 +364,7 @@ EndStopHit Platform::Stopped(int8_t drive)
else
return noStop;
}
}
if(lowStopPins[drive] >= 0)
{

View file

@ -89,7 +89,7 @@ Licence: GPL
#define MAX_STEPPER_DIGIPOT_VOLTAGE ( 3.3*2.5/(2.7+2.5) ) // Stepper motor current reference voltage
#define Z_PROBE_AD_VALUE 400
#define Z_PROBE_STOP_HEIGHT 0.7 // mm
#define Z_PROBE_PIN 0 // Analogue pin number
#define Z_PROBE_PIN -1 // Analogue pin number
#define MAX_FEEDRATES {50.0, 50.0, 3.0, 16.0} // mm/sec
#define ACCELERATIONS {800.0, 800.0, 10.0, 250.0} // mm/sec^2
#define DRIVE_STEPS_PER_UNIT {91.4286, 91.4286, 4000.0, 910.0}

30152
SD-image/gcodes/ormaxis.g Normal file

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ M500 Preprap
G21 ; mm
G90 ; Absolute positioning
M83 ; Extrusion relative
G31 Z0.7 P550 ; Set Z probe height and threshold
G31 Z0.0 P500 ; Set Z probe height and threshold
M906 X800 Y800 Z800 E800 ; Motor currents (mA)
T0 ; Extruder 0