M221 with percentage value behaves strangely
-
Currently my printer is running firmware 3.2.2 (I do not remember noticing any difference with 3.3 though but I did not explicitly check this), and I have a problem with recalculating the extruder moves on a hand-optimised piece of code.
The existing code is called with M98 from another file after defining and activating a second coordinate system in order to be able to print several of these parts. Here is the relevant section:
[skirt and layer 0 code removed] M221 S42 ; just 42% - what the heck?? ;LAYER_CHANGE ;Z:0.35 ;HEIGHT:0.15 ;LAYER:1 G1 Z0.350 F6000.000 G1 X77.216 Y77.222 F6000.000 G1 F120.000 G1 X79.780 Y77.228 E0.05871 G1 X79.780 Y79.780 E0.05844 G1 X76.220 Y79.780 E0.08151 G1 X76.220 Y77.220 E0.05862 G1 X77.156 Y77.222 E0.02142 G1 X76.619 Y77.702 F6000.000 G1 F120.000 G1 X76.619 Y79.464 E0.05462 G1 X76.619 Y77.537 E0.05974 G1 X77.171 Y77.538 E0.01713 G1 X77.171 Y79.464 E0.05970 G1 X77.724 Y79.464 E0.01713 G1 X77.724 Y77.540 E0.05966 G1 X78.276 Y77.541 E0.01713 G1 X78.276 Y79.464 E0.05963 G1 X78.829 Y79.464 E0.01713 G1 X78.829 Y77.542 E0.05959 G1 X79.381 Y77.543 E0.01713 G1 X79.381 Y79.464 E0.05955 [several more similar layers follow]
where I want to remove the M221 code to make later maintenance easier.
From what I get from the gcode reference, I ought to be able to recalculate the E values in this case with "new E value = old E value * 0.42" since a value of 1...100 after M221 ought be a percentage value. This does however result in massive underextrusion.After a lot of attempts, I can say now I only get a comparable result if I calculate as follows: "new E value = old E value * (1-0,042)" - which again does not seem to fit to the explanation of M221 as I understand it.
The printer runs perfectly fine otherwise - but my usual prints (some of them being of similar size) do not not include M221 at all - I used it here to find the "sweet spot" since the part has rather tight tolerances in this area. My extruder is defined with 256 microsteps (6640 microsteps per mm of material) and no interpolation.
Can anyone check/confirm this - or correct my misunderstanding of the gcode reference entry if there is one? If needed, I can upload the gcode file as well, but I guess this would not be of much use on another printer...
-
Hi,
I'm not sure what you are asking.
M221 S42 is going to set the extruder multiplier to 0.42 which will result in significant under extrusion.
The values I have used, to date, are 95 to 105.
Frederick
-
@neodue said in M221 with percentage value behaves strangely:
From what I get from the gcode reference, I ought to be able to recalculate the E values in this case with "new E value = old E value * 0.42" since a value of 1...100 after M221 ought be a percentage value.
Extrusion is calculated as:
motor_steps_commanded = requested_extrusion * (M221_percentage/100) * extruder_steps_per_mm
The previous M221 setting before you changed it does not affect this. So M221 S42 will cause the commanded extrusion to be 42% of the extrusion requested in the G1 command. Whether that length of filament is actually extruded depends on whether your M92 extruder steps/mm is set correctly.
-
@dc42 Thanks a lot! Then this is really weird, because this does not fit for some reason.
My explanation above does not seem clear enough, so let me try to rephrase what happened:
- at first I had the part printed without the M221 command. That one suffered from a certain overextrusion.
- thus, I inserted the M221 command into the gcode and played around with it until the extrusion fit. This is the code you see above. (I was quite surprised I had to go down to M221 S42 since the initial version let me expect some 5...10% overextrusion at max).
With the code above, the part then was printed well. - Now that I got the part right, I wanted to recalculate the extrusion values and remove the M221 command again. I did this by using the formula "new extrusion value = current extrusion value * M221_percentage/100", e.g. for the line 12 of the code above: new extrusion value = 0.05871 * 42/100" = 0.02466
- I did this for the whole part, [edit] set the M221 command to 100 (removing it does not seem to have an effect either) [/edit], tried to print it... and only now I got the part with the massive underextrusion you would expect from such an M221 value.
- Lastly, I fiddled around with the extrusion values until I got the part right again, this time NOT using M221 but changing the extrusion values directly. This last step then yielded a similar part as in step 2 with the extrusion values reduced by about 4..5%.
All in all, using M221 does behave differently on my Duet Wifi than changing the extruder values directly in the gcode - the latter seems to have about a 10 times higher effect than the former if I use the same percentage value in both cases.
@fcwilt Is this explanation clearer?
-
@neodue said in M221 with percentage value behaves strangely:
thus, I inserted the M221 command into the gcode and played around with it until the extrusion fit.
Two questions:
- What do you mean by "until the extrusion fit"?
- Have you verified the steps-per-mm setting for the extruder?
Thanks.
Frederick
-
Just to verify, are you printing these files as jobs, or executing them as macros?
-
@fcwilt said in M221 with percentage value behaves strangely:
- What do you mean by "until the extrusion fit"?
I changed the M221 setting, printed that part (you might have noticed it is rather small - just 3x4mm, so printing is pretty fast), optically checked and measured it, changed it again etc. until the part turned out as it should.
- Have you verified the steps-per-mm setting for the extruder?
Yes, the extruder setting is fine. Maybe I should add I have had this printer in regular use for years and it prints perfectly well. This only happens if I use M221. Apart from that, the steps-per-mm setting of the extruder should not be affected whether I use M221 in my code or not
-
@phaedrux I guess the correct answer would be "both"... I have one file (code added below) that I start as a job from the SD card that initialises the printer (set temps, call my standard homing macro etc.). This file then sets the second coordinate system and calls the second file ("multipart.gcode" which then contains the gcode part of which I posted above) with M98.
M107 ; turn off fan in case it was manually turned on before M190 S60 ; set bed temperature and wait for it to be reached ;TYPE:Custom ; prepare printer G28 ; zero axes M98 P"/sys/homezfein.g" ; heat hotend to 160°C and fine home z with piezo bed sensors G10 P0 S215 ; final temp for first layer M116 ; wait M98 P"/sys/naseputzen.g" ; wipe nozzle and start printing G21 ; set units to millimeters G90 ; use absolute coordinates M83 ; use relative distances for extrusion G92 E0 ; Filament gcode ; 1st part G1 X68.5 Y43 F6000 ; go to new print centre G10 L20 P2 X78.5 Y78 ; ... define 2nd coordinate system G55 ; activate 2nd coordinate system M98 P"0:/gcodes/multipart.gcode" ; call part gcode as subprogram G54 ; reactivate main coordinate system ; 2nd part G1 X68.5 Y78 F6000 ; go to new print centre G10 L20 P2 X78.5 Y78 ; ... define 2nd coordinate systemn G55 ; activate 2nd coordinate system M98 P"0:/gcodes/multipart.gcode" ; call part gcode as subprogram G54 ; reactivate main coordinate system ; 3rd part G1 X68.5 Y113 F6000 ; go to new print centre G10 L20 P2 X78.5 Y78 ; ... define 2nd coordinate system G55 ; activate 2nd coordinate system M98 P"0:/gcodes/multipart.gcode" ; call part gcode as subprogram G54 ; reactivate main coordinate system M107 ;TYPE:Custom ; Filament-specific end gcode ;END gcode for filament M98 P"/sys/cancel.g" ; call cancel macro to end printing
-
-
@neodue M221 is not applied to moves executed within a file macro. This is so that you can have e.g. commands to wipe the nozzle inside tool change files and resume.g that are not affected by M221 commands that you use during printing to improve print quality. Does this explain what you observe?
-
@dc42 This means for any files called with M98, M221 is not executed? Yes, that - mostly - explains it.
The only thing I wonder about then is that M221 still seems to have a minor effect from within my subprogram - as noted, adding M221 S42 seemed to reduce my extruder flow slightly - at least from what I could tell.