Skip to content

Commit

Permalink
ZCMP-E-Compensation
Browse files Browse the repository at this point in the history
test commit
  • Loading branch information
Nibbels committed Dec 30, 2017
1 parent ff51073 commit 9365e34
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Repetier/Constants.h
Expand Up @@ -20,7 +20,7 @@
#define CONSTANTS_H


#define REPETIER_VERSION "RF.01.38.01.Mod"
#define REPETIER_VERSION "RF.01.38.02.Mod"
#define UI_PRINTER_COMPANY "Conrad Community"
#define UI_VERSION_STRING "V " REPETIER_VERSION

Expand Down
4 changes: 4 additions & 0 deletions Repetier/Printer.cpp
Expand Up @@ -139,6 +139,10 @@ volatile long Printer::currentZSteps;
volatile long Printer::compensatedPositionTargetStepsZ;
volatile long Printer::compensatedPositionCurrentStepsZ;

volatile float Printer::compensatedPositionOverPercE = 0.0f;
volatile float Printer::compensatedPositionCollectTinyE = 0.0f;
volatile bool Printer::compensatedPositionPushE = false;

volatile char Printer::endZCompensationStep;
#endif // FEATURE_HEAT_BED_Z_COMPENSATION || FEATURE_WORK_PART_Z_COMPENSATION

Expand Down
3 changes: 3 additions & 0 deletions Repetier/Printer.h
Expand Up @@ -146,6 +146,9 @@ class Printer
#if FEATURE_HEAT_BED_Z_COMPENSATION || FEATURE_WORK_PART_Z_COMPENSATION
static volatile long compensatedPositionTargetStepsZ;
static volatile long compensatedPositionCurrentStepsZ;
static volatile float compensatedPositionOverPercE;
static volatile float compensatedPositionCollectTinyE;
static volatile bool compensatedPositionPushE;
static volatile char endZCompensationStep;
#endif // FEATURE_HEAT_BED_Z_COMPENSATION || FEATURE_WORK_PART_Z_COMPENSATION

Expand Down
16 changes: 11 additions & 5 deletions Repetier/RF.cpp
Expand Up @@ -3254,7 +3254,7 @@ void doHeatBedZCompensation( void )
(g_ZCompensationMatrix[nXRightIndex][nYBackIndex] - g_ZCompensationMatrix[nXLeftIndex][nYBackIndex]) * nDeltaX / nStepSizeX;

nNeededZCompensation = nTempXFront +
(nTempXBack - nTempXFront) * nDeltaY / nStepSizeY;
(nTempXBack - nTempXFront) * nDeltaY / nStepSizeY; //Das ist hier noch der Zeiger auf die Oberfläche.

#if DEBUG_HEAT_BED_Z_COMPENSATION
g_nDelta[X_AXIS] = nDeltaX;
Expand All @@ -3280,25 +3280,31 @@ void doHeatBedZCompensation( void )
if(nCurrentPositionSteps[Z_AXIS] == 0){
nNeededZCompensation += 13; //G1 Z0 shall not hit the bed: +5um -> this is better than not compensating at all because it makes tests weired.
}
Printer::compensatedPositionOverPercE = 0.0f;
}
else
{
// the printer is already a bit away from the surface - do the actual compensation
nNeededZCompensation = g_offsetZCompensationSteps +
((nNeededZCompensation - g_offsetZCompensationSteps) * (g_maxZCompensationSteps - nCurrentPositionSteps[Z_AXIS]))
/ (g_maxZCompensationSteps - g_minZCompensationSteps);
// Compensate Extrusion within ZCMP: Add and sum up this amount for every step extruded in move interrupt. Extrude the step if we have some full >=1.0 in interrupt.
Printer::compensatedPositionOverPercE = float(g_offsetZCompensationSteps - nNeededZCompensation) / float(g_maxZCompensationSteps - g_minZCompensationSteps);

// the printer is already a bit away from the surface - do the actual compensation -> Hier ist nNeededZCompensation dann nicht mehr der Zeiger auf die Oberfläche, sondern der Zeiger auf die kompensationshöhe:
nNeededZCompensation = ((nNeededZCompensation - g_offsetZCompensationSteps) * (g_maxZCompensationSteps - nCurrentPositionSteps[Z_AXIS]))
/ (g_maxZCompensationSteps - g_minZCompensationSteps);
nNeededZCompensation += g_offsetZCompensationSteps;
}
}
else
{
// after the first layers, only the static offset to the surface must be compensated
nNeededZCompensation = g_offsetZCompensationSteps;
Printer::compensatedPositionOverPercE = 0.0f;
}
}
else
{
//Gcode Z < 0 soll 5um überhalb des top matrix elements bleiben: diese anweisungen sind generell für uns sinnlos bzw. schädlich.
nNeededZCompensation = g_offsetZCompensationSteps + 13;
Printer::compensatedPositionOverPercE = 0.0f;
}

nNeededZCompensation += g_staticZSteps;
Expand Down
24 changes: 21 additions & 3 deletions Repetier/motion.cpp
Expand Up @@ -1984,7 +1984,7 @@ long PrintLine::performMove(PrintLine* move, char forQueue)

if(move->isEMove())
{
if((move->error[E_AXIS] -= move->delta[E_AXIS]) < 0)
if((move->error[E_AXIS] -= move->delta[E_AXIS]) < 0 || Printer::compensatedPositionPushE) //we want to push some E step out if it is planned OR needed because of ZCMP-E-Compensation
{
#if USE_ADVANCE
if(Printer::isAdvanceActivated()) // Use interrupt for movement
Expand All @@ -1998,8 +1998,26 @@ long PrintLine::performMove(PrintLine* move, char forQueue)
#endif // USE_ADVANCE
Extruder::step();

if( forQueue ) move->error[E_AXIS] += queueError;
else move->error[E_AXIS] += directError;
if(!Printer::compensatedPositionPushE){
//add % parts of steps to extrusion because of higher layer heights caused by ZCMP
if(Printer::compensatedPositionOverPercE != 0.0f){
//if we have primaryAxis as E_AXIS we would not be able to smuggle in steps because they are in one row - and it wouldnt make sense anyways, because those moves are retracts typically.
if(move->primaryAxis != E_AXIS) Printer::compensatedPositionCollectTinyE += Printer::compensatedPositionOverPercE;
if(Printer::compensatedPositionCollectTinyE >= 1.0f) Printer::compensatedPositionPushE = true;
/*
}else{
Printer::compensatedPositionCollectTinyE = 0.0f; //clear rest if out of compensation?? --> really necessary or is some part of one step acceptable because we are never gonna come back to CMP if we moved out??
*/
}
//only count step if it is not caused by ZCMP-E-Compensation
if( forQueue ) move->error[E_AXIS] += queueError;
else move->error[E_AXIS] += directError;
}else{
//never count or update queue/direct steps if we are smuggling a step amongst others because of ZCMP-E-Compensation
Printer::compensatedPositionPushE = false;
Printer::compensatedPositionCollectTinyE--;
}

}
}
if(move->isXMove())
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
@@ -1,6 +1,9 @@
TODO: Z-Lift-Bug seems to be still present! Avoid Z-Lift: Todo @Conrad -> Has this possibly been fixed by removing halfstepping in 1.37u4?
TODO: Testing, testing ..

V RF.01.38.02.Mod (2017-12-30)
- added E-Compensation for Z-Compensation layer expansion.

V RF.01.38.01.Mod (2017-12-29)
- added renkforce feature FEATURE_ALIGN_EXTRUDERS
- fixed details in FEATURE_ALIGN_EXTRUDERS
Expand Down

0 comments on commit 9365e34

Please sign in to comment.