Tried to run the attached macro as a job today. (Nonlinear_extrusion.gcode)
Indeed, gcode command M221 does not work when used inside a macro. The figure and code below summarizes my findings and how I obtained them:
Matlab commands to obtain parameters:
x = [1 2 3 4 5 6] %different velocities in mm/s
y_des = 50; %desired distance
measured = [48.84 46.81 46.12 45.65 45.26 44.66]; %measured distance
y1 = y_des./measured; %calculate the ratio
p1 = polyfit(x,y1,2); %obtain second order polynomial approximation
figure(1) %plot your results
plot(x,y1)
gcode to perform compensation
M221 D0 S103.97 ;fill in p1(3), see Matlab code
M592 D0 A0.005 B0.0015 L0.45 ;for A, fill in p1(2), for B, fill in p1(1)
@Phaedrux, thanks for your help!