Version 1.00e

Fixed G32 so that it really does run macro file bed.g if it exists
Added H parameter to M558 command
Added bed.g file for Mini Kossel with mechanical Z probe
This commit is contained in:
David Crocker 2015-01-31 19:36:29 +00:00
parent 4f2e0423a2
commit 1e70add19c
10 changed files with 37221 additions and 64 deletions

View file

@ -24,8 +24,8 @@ Licence: GPL
#define CONFIGURATION_H
#define NAME "RepRapFirmware"
#define VERSION "1.00d-dc42"
#define DATE "2015-01-30"
#define VERSION "1.00e-dc42"
#define DATE "2015-01-31"
#define AUTHORS "reprappro, dc42, zpl"
#define FLASH_SAVE_ENABLED (1)

View file

@ -74,6 +74,7 @@ void GCodes::Init()
limitAxes = true;
SetAllAxesNotHomed();
toolChangeSequence = 0;
setBedState = 0;
coolingInverted = false;
}
@ -875,7 +876,7 @@ bool GCodes::DoSingleZProbeAtPoint(int probePointIndex)
switch (cannedCycleMoveCount)
{
case 0: // Raise Z to 5mm. This only does anything on the first move; on all the others Z is already there
moveToDo[Z_AXIS] = Z_DIVE;
moveToDo[Z_AXIS] = platform->GetZProbeDiveHeight();
activeDrive[Z_AXIS] = true;
moveToDo[DRIVES] = platform->MaxFeedrate(Z_AXIS);
activeDrive[DRIVES] = true;
@ -924,7 +925,7 @@ bool GCodes::DoSingleZProbeAtPoint(int probePointIndex)
return false;
case 3: // Raise the head 5mm
moveToDo[Z_AXIS] = Z_DIVE;
moveToDo[Z_AXIS] = platform->GetZProbeDiveHeight();
activeDrive[Z_AXIS] = true;
moveToDo[DRIVES] = platform->MaxFeedrate(Z_AXIS);
activeDrive[DRIVES] = true;
@ -1026,38 +1027,62 @@ bool GCodes::SetBedEquationWithProbe(StringRef& reply)
{
// zpl-2014-10-09: In order to stay compatible with old firmware versions, only execute bed.g
// if it is actually present in the sys directory
if (platform->GetMassStorage()->PathExists(SYS_DIR SET_BED_EQUATION))
switch (setBedState)
{
return DoFileMacro(SET_BED_EQUATION);
}
case 0:
{
FileStore *f = platform->GetFileStore(SYS_DIR, SET_BED_EQUATION, false);
if (f != NULL)
{
f->Close();
setBedState = 1;
}
else
{
setBedState = 2;
}
}
return false;
if (reprap.GetMove()->NumberOfXYProbePoints() < 3)
{
reply.copy("Bed probing: there needs to be 3 or more points set.\n");
return true;
}
case 1:
{
bool finished = DoFileMacro(SET_BED_EQUATION);
if (finished)
{
setBedState = 0;
}
return finished;
}
// zpl 2014-11-02: When calling G32, ensure bed compensation parameters are initially reset
if (!settingBedEquationWithProbe)
{
case 2:
if (reprap.GetMove()->NumberOfXYProbePoints() < 3)
{
reply.copy("Bed probing: there needs to be 3 or more points set.\n");
setBedState = 0;
return true;
}
// zpl 2014-11-02: When calling G32, ensure bed compensation parameters are initially reset
reprap.GetMove()->SetIdentityTransform();
settingBedEquationWithProbe = true;
}
++setBedState;
return false;
if (DoSingleZProbeAtPoint(probeCount))
{
probeCount++;
}
case 3:
if (DoSingleZProbeAtPoint(probeCount))
{
probeCount++;
}
if (probeCount >= reprap.GetMove()->NumberOfXYProbePoints())
{
probeCount = 0;
zProbesSet = true;
reprap.GetMove()->SetProbedBedEquation(reply);
settingBedEquationWithProbe = false;
return true;
if (probeCount >= reprap.GetMove()->NumberOfXYProbePoints())
{
probeCount = 0;
zProbesSet = true;
reprap.GetMove()->SetProbedBedEquation(reply);
setBedState = 0;
return true;
}
return false;
}
return false;
}
// This returns the (X, Y) points to probe the bed at probe point count. When probing,
@ -1286,7 +1311,7 @@ void GCodes::QueueFileToPrint(const char* fileName)
void GCodes::DeleteFile(const char* fileName)
{
if(!platform->GetMassStorage()->Delete(platform->GetGCodeDir(), fileName))
if (!platform->GetMassStorage()->Delete(platform->GetGCodeDir(), fileName))
{
platform->Message(BOTH_ERROR_MESSAGE, "Could not delete file \"%s\"\n", fileName);
}
@ -3173,13 +3198,7 @@ bool GCodes::HandleMcode(GCodeBuffer* gb)
case 558: // Set or report Z probe type and for which axes it is used
{
bool seenP = false, seenR = false;
if (gb->Seen('P'))
{
platform->SetZProbeType(gb->GetIValue());
seenP = true;
}
bool seen = false;
bool zProbeAxes[AXES];
platform->GetZProbeAxes(zProbeAxes);
for (size_t axis=0; axis<AXES; axis++)
@ -3187,24 +3206,38 @@ bool GCodes::HandleMcode(GCodeBuffer* gb)
if (gb->Seen(axisLetters[axis]))
{
zProbeAxes[axis] = (gb->GetIValue() > 0);
seenP = true;
seen = true;
}
}
if (seen)
{
platform->SetZProbeAxes(zProbeAxes);
}
// We must get and set the Z probe type first before setting the dive height, because different probe types may have different dive heights
if (gb->Seen('P'))
{
platform->SetZProbeType(gb->GetIValue());
seen = true;
}
if (gb->Seen('H'))
{
platform->SetZProbeDiveHeight(gb->GetIValue());
seen = true;
}
if (gb->Seen('R'))
{
platform->SetZProbeChannel(gb->GetIValue());
seenR = true;
seen = true;
}
if (seenP)
if (!seen)
{
platform->SetZProbeAxes(zProbeAxes);
}
else if (!seenR)
{
reply.printf("Z Probe type is %d on channel %d and it is used for these axes:", platform->GetZProbeType(), platform->GetZProbeChannel());
for(size_t axis=0; axis<AXES; axis++)
reply.printf("Z Probe type is %d on channel %d with dive height %.1f and it is used for these axes:",
platform->GetZProbeType(), platform->GetZProbeChannel(), platform->GetZProbeDiveHeight());
for (size_t axis=0; axis<AXES; axis++)
{
if (zProbeAxes[axis])
{

View file

@ -206,7 +206,6 @@ class GCodes
int8_t cannedCycleMoveCount; // Counts through internal (i.e. not macro) canned cycle moves
bool cannedCycleMoveQueued; // True if a canned cycle move has been set
bool zProbesSet; // True if all Z probing is done and we can set the bed equation
bool settingBedEquationWithProbe; // True if we're executing G32 without a macro
float longWait; // Timer for things that happen occasionally (seconds)
bool limitAxes; // Don't think outside the box.
bool axisIsHomed[AXES]; // These record which of the axes have been homed
@ -216,7 +215,8 @@ class GCodes
float speedFactorChange; // factor by which we changed the speed factor since the last move
float extrusionFactors[DRIVES - AXES]; // extrusion factors (normally 1.0)
float lastProbedZ; // the last height at which the Z probe stopped
int8_t toolChangeSequence; // Steps through the tool change procedure
uint8_t toolChangeSequence; // Steps through the tool change procedure
uint8_t setBedState; // Steps through the setbed procedure
bool simulating;
float simulationTime;

View file

@ -322,10 +322,25 @@ void Platform::InitZProbe()
zProbeOnFilter.Init(0);
zProbeOffFilter.Init(0);
if (nvData.zProbeType >= 1 && nvData.zProbeType < 4)
switch (nvData.zProbeType)
{
case 1:
case 2:
pinModeNonDue(nvData.zProbeModulationPin, OUTPUT);
digitalWriteNonDue(nvData.zProbeModulationPin, (nvData.zProbeType < 3) ? HIGH : LOW); // enable the IR LED or alternate sensor
digitalWriteNonDue(nvData.zProbeModulationPin, HIGH); // enable the IR LED
break;
case 3:
pinModeNonDue(nvData.zProbeModulationPin, OUTPUT);
digitalWriteNonDue(nvData.zProbeModulationPin, LOW); // enable the alternate sensor
break;
case 4:
pinModeNonDue(endStopPins[E0_AXIS], INPUT_PULLUP);
break;
default:
break;
}
}
@ -430,6 +445,41 @@ float Platform::ZProbeStopHeight() const
}
}
float Platform::GetZProbeDiveHeight() const
{
switch (nvData.zProbeType)
{
case 1:
case 2:
return nvData.irZProbeParameters.diveHeight;
case 3:
return nvData.alternateZProbeParameters.diveHeight;
case 4:
return nvData.switchZProbeParameters.diveHeight;
default:
return Z_DIVE;
}
}
void Platform::SetZProbeDiveHeight(float h)
{
switch (nvData.zProbeType)
{
case 1:
case 2:
nvData.irZProbeParameters.diveHeight = h;
break;
case 3:
nvData.alternateZProbeParameters.diveHeight = h;
break;
case 4:
nvData.switchZProbeParameters.diveHeight = h;
break;
default:
break;
}
}
void Platform::SetZProbeType(int pt)
{
int newZProbeType = (pt >= 0 && pt <= 4) ? pt : 0;
@ -866,7 +916,7 @@ void Platform::Tick()
case 2: // last conversion started was the Z probe, with IR LED on
{
uint16_t reading = (nvData.zProbeType != 4) ? GetAdcReading(zProbeAdcChannel) : (digitalRead(endStopPins[AXES])) ? 1023 : 0;
uint16_t reading = (nvData.zProbeType != 4) ? GetAdcReading(zProbeAdcChannel) : (digitalRead(endStopPins[E0_AXIS])) ? 4000 : 0;
const_cast<ZProbeAveragingFilter&>(zProbeOnFilter).ProcessReading(reading);
}
StartAdcConversion(heaterAdcChannels[currentHeater]); // read a thermistor
@ -879,7 +929,7 @@ void Platform::Tick()
case 4: // last conversion started was the Z probe, with IR LED off if modulation is enabled
{
uint16_t reading = (nvData.zProbeType != 4) ? GetAdcReading(zProbeAdcChannel) : (digitalRead(endStopPins[AXES])) ? 1023 : 0;
uint16_t reading = (nvData.zProbeType != 4) ? GetAdcReading(zProbeAdcChannel) : (digitalRead(endStopPins[E0_AXIS])) ? 4000 : 0;
const_cast<ZProbeAveragingFilter&>(zProbeOffFilter).ProcessReading(reading);
}
// no break

View file

@ -117,7 +117,7 @@ const float defaultDeltaHomedHeight = 200; // mm
#define HOME_FEEDRATES {50.0, 50.0, 100.0/60.0} // mm/sec (dc42 increased Z because we slow down z-homing when approaching the target height)
const size_t X_AXIS = 0, Y_AXIS = 1, Z_AXIS = 2; // The indices of the Cartesian axes in drive arrays
const size_t X_AXIS = 0, Y_AXIS = 1, Z_AXIS = 2, E0_AXIS = 3; // The indices of the Cartesian axes in drive arrays
const size_t A_AXIS = 0, B_AXIS = 1, C_AXIS = 2; // The indices of the 3 tower motors of a delta printer in drive arrays
// HEATERS - The bed is assumed to be the at index 0
@ -418,6 +418,7 @@ struct ZProbeParameters
float height; // the nozzle height at which the target ADC value is returned
float calibTemperature; // the temperature at which we did the calibration
float temperatureCoefficient; // the variation of height with bed temperature
float diveHeight; // the dive height we use when probing
void Init(float h)
{
@ -426,6 +427,7 @@ struct ZProbeParameters
height = h;
calibTemperature = 20.0;
temperatureCoefficient = 0.0; // no default temperature correction
diveHeight = Z_DIVE;
}
float GetStopHeight(float temperature) const
@ -650,8 +652,8 @@ public:
// Z probe
float ZProbeStopHeight() const;
float ZProbeXoffset() const;
float ZProbeYoffset() const;
float GetZProbeDiveHeight() const;
void SetZProbeDiveHeight(float h);
int ZProbe() const;
EndStopHit GetZProbeResult() const;
int GetZProbeSecondaryValues(int& v1, int& v2);

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
; Bed probing routine for Mini Kossel
M561 ; clear bed transform, otherwise homing may be at the wrong height
; Macro files don't nest, so we can't do a G28 here. Include the code from homedelta.g instead.
G91 ; use relative positioning
G1 S1 X320 Y320 Z320 F5000 ; move all carriages up 320mm, stopping at the endstops
G1 S2 X-4 Y-4 Z-4 F1000 ; move all towers down 5mm
G1 S1 X8 Y8 Z8 F500 ; move towers up 8mm, stopping at the endstops
G90 ; back to absolute positioning
M564 S0 ; don't apply limits
; Deploy probe
G1 X25 Y93 Z50 F10000 ; put probe arm next to belt
G1 X-7 F500
G1 X12 F2000
G1 X0 Y0 Z10 F5000
;*** Adjust the XY coordinates in the following M557 commands if necessary to suit your build and the position of the zprobe
G30 P0 X-50 Y-50 Z-99999
G30 P1 X-50 Y50 Z-99999
G30 P2 X50 Y50 Z-99999
G30 P3 X50 Y-50 Z-99999
G30 P4 X0 Y0 Z-99999 S
; Retract probe
G1 Z40 F10000 ; raise head
G1 X-59 Y66 Z35 ; move over the post
G1 Z7 F500 ; push probe down on post
G1 Z35 F10000 ; raise head again
G1 X0 Y0 ; move to somewhere sensible
M564 S1 ; apply limits again

View file

@ -45,15 +45,10 @@ M92 E663:663 ; Set extruder steps per mm
;G10 P2 S0 R0 ; Set tool 2 operating and standby temperatures
// Z probe and compensation definition
;*** If you have an IR zprobe, change P0 to P1 in the following M558 command
M558 P0 X0 Y0 Z0 ; Z probe is a switch and is not used for homing any axes
;G31 Z1.20 P500 ; Set the IR zprobe height and threshold (put your own values here)
;*** Adjust the XY coordinates in the following M557 commands if necessary to suit your build and the position of the zprobe
M557 P0 X-50 Y-50 ; Four...
M557 P1 X-50 Y50 ; ...probe points...
M557 P2 X50 Y50 ; ...for bed...
M557 P3 X50 Y-50 ; ...levelling
M557 P4 X0 Y0 ; 5th probe point for levelling
;*** If you have an IR zprobe instead of a switch, change P4 to P1 in the following M558 command
M558 P4 X0 Y0 Z0 H8 ; Z probe is a switch and is not used for homing any axes
G31 X1.2 Y17.6 Z4.80 P500 ; Set the zprobe height and threshold (put your own values here)
;*** If you are using axis compensation, put the figures in the following command
M556 S78 X0 Y0 Z0 ; Axis compensation here