Linear advance and M900
I've been trying to experiment with using linear advance. The new Prusa firmware and Marlin apparently make good use of it and people are reporting higher speeds with similar quality.
It's been difficult to find much documentation on how linear advance has been implemented in Repetier. Does it support the M900 command to adjust the K factor value on the fly? Or do you have to recompile the firmware each time you want to make an adjustment or switch filament types?
How do advance and quadratic advance interact? What are sane values for each?
Given that linear advance appears to be gaining traction elsewhere, perhaps it's time to flesh out the implementation for repetier?
http://reprap.org/wiki/G-code#M900_Set_Linear_Advance_Scaling_Factors
https://www.prusaprinters.org/fw-3-1-0-linear-advance-drivers-1-9-1/
http://marlinfw.org/docs/features/lin_advance.html
https://forum.repetier.com/discussion/3411/is-advance-algorithm-now-stable
It's been difficult to find much documentation on how linear advance has been implemented in Repetier. Does it support the M900 command to adjust the K factor value on the fly? Or do you have to recompile the firmware each time you want to make an adjustment or switch filament types?
How do advance and quadratic advance interact? What are sane values for each?
Given that linear advance appears to be gaining traction elsewhere, perhaps it's time to flesh out the implementation for repetier?
http://reprap.org/wiki/G-code#M900_Set_Linear_Advance_Scaling_Factors
https://www.prusaprinters.org/fw-3-1-0-linear-advance-drivers-1-9-1/
http://marlinfw.org/docs/features/lin_advance.html
https://forum.repetier.com/discussion/3411/is-advance-algorithm-now-stable
Comments
No matter what value I use, the extruder begins to reverse itself shortly after the start of the print.
Try only using linear advance. That seems to match much better. Make sure to modify L parameter (whcih pruse names K, but K is quadratic term here). K is very sensitive and already smaller values of 0.x have big impact while L can be 30-50 without problems. K=50 will make a retract as that is the compensation. Bigger compensation can lead to retracts on higher speeds.
I modified a M900 gcode file to test the various values but it always retracts and then when it does start to go forward there is nothing in the nozzle to extrude.
I only have advance enabled in the firmware. Quadratic is disabled. M233 only echoes back the Y value for L.
Here is the gcode file I am testing with. Even if I remove the M233 commands and manually set it to a value before a print any value above 0 will reverse the extruder.
Acceleration is 800, which I thought was pretty reasonable.
My entire configuration.h file can be seen here: https://www.dropbox.com/s/7o7qa56wfor2cj0/Configuration.h?dl=0
It was only ever able to deposit filament on the first two segments before reversing and the part of the segments at high speed were only small dribbles.
Is 120mm/s simply way too fast for my printer setup perhaps? Next chance I get I will try with speeds closer to what I actually print with. Usually 60mm/s. Mind you, if I left M233 Y0 the file would at least successfully print, though the blobbing and over-extruding at the rapid parts was pretty bad as you'd imagine.
M232 returned
meaning at maximum it advanced 17 steps at resolution 147 steps per mm = 0.12mm. That is ok as it is a direct extruder. For bowden you would need much bigger L values and get the risk of reversal.
Do you have automatic retract enabled? I have none enabled.
I wasn't aware of the M232 command before. I should add it to the test file.
While looking up the M232 command I found this: https://github.com/repetier/Repetier-Firmware/wiki/Hardware-settings-and-print-quality I'll just leave that there for posterity.
It will be about a week before I get to test anything again, but I will report back once I have.
Thanks for your time.
I'm going to test a print now with M233 Y30 which looked to have the best line quality.
Test print failed. The lines were very thin and eventually the extruder reversed. I canceled the print after the first layer and ran M232 and M233 in the terminal.
Another thing I have noticed is that with any L factor set the extrusion rate from a manual extrusion, say through Octoprint to prime the nozzle, occurs very slowly.
#if USE_ADVANCE
if(!isXYZMove() || !isEPositiveMove()) {
#if ENABLE_QUADRATIC_ADVANCE
advanceRate = 0; // No head move or E move only or sucking filament back
advanceFull = 0;
#endif
advanceL = 0;
} else {
float advlin = fabs(speedE) * Extruder::current->advanceL * 0.001 * Printer::axisStepsPerMM[E_AXIS];
advanceL = (uint16_t)((65536L * advlin) / vMax); //advanceLscaled = (65536*vE*k2)/vMax
#if ENABLE_QUADRATIC_ADVANCE
advanceFull = 65536 * Extruder::current->advanceK * speedE * speedE; // Steps*65536 at full speed
long steps = (HAL::U16SquaredToU32(vMax)) / (accelerationPrim << 1); // v^2/(2*a) = steps needed to accelerate from 0-vMax
advanceRate = advanceFull / steps;
if((advanceFull >> 16) > maxadv) {
maxadv = (advanceFull >> 16);
maxadvspeed = fabs(speedE);
}
#endif
if(advlin > maxadv2) {
maxadv2 = advlin;
maxadvspeed = fabs(speedE);
}
}
#endif
You see that retracts and other pure e moves have advanceL computed as 0 so advance has no effect here.In updateAdvanceSteps you see
int tred = HAL::mulu6xu16shift16(v, advanceL);
HAL::forbidInterrupts();
Printer::extruderStepsNeeded += tred - Printer::advanceStepsSet;
if(tred > 0 && Printer::advanceStepsSet <= 0)
Printer::extruderStepsNeeded += (Extruder::current->advanceBacklash << 1);
else if(tred < 0 && Printer::advanceStepsSet >= 0)
Printer::extruderStepsNeeded -= (Extruder::current->advanceBacklash << 1);
Printer::advanceStepsSet = tred;
HAL::allowInterrupts();
for linear solution. So the added advance is always positive. Only way to get a reverse is if you decelerate so fast that advance reduces faster then E would extrude to gcode logic causing a reverse. But that would then happen on every move not sometimes.
When advance is enabled, E is not handled in the stepper interrupt but in a extra interrupt for E and that has a limited frequency. What is your extruder resolution and what speed is slow for you? What board are you using. Maybe this gives some explanations. I mean if normal extrusion is too slow it could mean it can not follow advance as well causing unhandled extruderStepsNeeded from delay that could result in reversals.
In V2 I will add advance in normal stepper interrupt handling, so I think there it will improve a bit, but the atmega is of course no help with it's low max. stepper frequency. 1800 steps/mm is simply total overkill. I have 147steps per mm, I think 300-500 would be ideal resolution. So if you can reduce microstepping by factor 4 you have 450 and Emax is up to 33mm/s.
Would upgrading to an Adruino Due solve the frequency limit automatically? It may be time to leave 8 bit behind.
Thanks for all your help figuring this out. I get great prints right now as it is but was interested in advance. Repetier dev 1.0 had been great.