# Specific 3D Printers, Scanners, & Hardware > RepRap Format Printer Forum > MakerFarm Forum >  Adding M600 to change filament to Gcode

## tsteever

I have been trying to modify some code for my prints by adding a M600 command to change filament. I got it to work once by just putting the filament in the actual code. I have been trying on another print but cannot get it to work! I just sits in one spot and extrudes a huge mess of filament. 

Here is a section of the code. I added the M600 right before the printer starts the fill section of the top layer. I want this to be a different color. 



```
G1 X189.521 Y94.348 E1544.45744G1 X190.463 Y94.995 E1544.47148
G1 X191.309 Y95.762 E1544.48552
G1 X192.053 Y96.643 E1544.49969
G1 X192.681 Y97.628 E1544.51404
G1 X193.172 Y98.676 E1544.52827
G1 X193.525 Y99.793 E1544.54266
G1 X193.732 Y100.944 E1544.55704
G1 X193.788 Y102.12 E1544.5715
G1 X193.788 Y197.87 E1545.74823
G1 X193.732 Y199.056 E1545.76282
G1 X193.525 Y200.206 E1545.77718
G1 X193.172 Y201.323 E1545.79158
G1 X192.681 Y202.372 E1545.80581
G1 X192.053 Y203.356 E1545.82016
G1 X191.309 Y204.237 E1545.83433
G1 X190.463 Y205.004 E1545.84836
G1 X189.521 Y205.651 E1545.86241
G1 X188.498 Y206.164 E1545.87647
G1 X187.431 Y206.527 E1545.89032
G1 X186.325 Y206.741 E1545.90417
G1 X185.181 Y206.8 E1545.91825
G1 X114.819 Y206.8 E1546.78296
G0 F10500 X114.745 Y205.82
M600
; TYPE:FILL
G1 F3600 X107.138 Y198.214 E1546.91517
G0 F10500 X107.221 Y197.731
G1 F3600 X106.762 Y197.272 E1546.92314
G0 F10500 X107.121 Y197.065
G1 F3600 X115.881 Y205.825 E1547.07539
G0 F10500 X115.739 Y206.248
G1 F3600 X115.215 Y205.725 E1547.08449
G0 F10500 X115.315 Y205.825
G1 F3600 X107.121 Y197.63 E1547.22691
G0 F10500 X107.121 Y196.499
G1 F3600 X116.447 Y205.825 E1547.389
G0 F10500 X117.012 Y205.825
G1 F3600 X107.121 Y195.933 E1547.56091
G0 F10500 X107.121 Y195.367
G1 F3600 X117.578 Y205.825 E1547.74267
G0 F10500 X118.144 Y205.825
G1 F3600 X107.121 Y194.802 E1547.93425
G0 F10500 X107.121 Y194.236
G1 F3600 X118.709 Y205.825 E1548.13566
G0 F10500 X119.275 Y205.825
G1 F3600 X107.121 Y193.67 E1548.3469
G0 F10500 X107.121 Y193.105
G1 F3600 X119.841 Y205.825 E1548.56798
G0 F10500 X120.406 Y205.825
```

----------


## JSeeley

Should "TYPE:FILL" be in parentheses? I've never seen a text command in G-code programs, only action descriptons or tool geometry within parentheses.

----------


## tsteever

That is what my slicer puts in. I kinda like it. It makes inserting these M600 commands a lot easier...in theory.

----------


## JSeeley

So TYPE:FILL can replace the several lines of code required to execute this procedure. It's my understanding that M600 pauses machine, but what about the other M600 codes? Extruder on, extruder off, or change filament? The program has your tool paused and all other commands are on, I think the reason you are getting a pool of plastic. Extruder is still on M604

----------


## tsteever

The Type:FILL is just something my slicer puts in. There are no actual commands issued in that line. The ";" tells the printer to ignore what come after in that line. At least that is how I learned it. I could be wrong.

The M600 command causes the machine to move to the home position and retract the filament, then pause while you load new filament and push the button. I had thought it was supposed to lock the x and y axis motors but I can still move them. It is tricky and I wish there was a way to have it work better. What is a M604 command?

----------


## JSeeley

Sorry, I'm new to 3d programming. I can track your cartesian coordinates, but then you call for a filament pause. I don't know what's included in that command but it looks as if something is missing.   



M600 - Park head to allow filament change or pause of printM601 - Unpark head to resume printingM602 - Turn on/off current extruder motor (e.g., for cleaning)M603 - Display LCD alert, sound beeper and wait for button press.

I'd think a M601 would be necessary to resume after pause. But you've said that your process has worked in the past???

----------


## Roxy

M600 has a number of parameters.   When ever I use it, I do something like M600 Z50 to raise the nozzle up above the part.   That is important for two reasons.  First, it gets the hot end away from the print.  But the other reason that is important is you need room to work.   Once I get the filament changed, I need to manually turn the gears to fill the nozzle with the new color.   So I put a piece of paper on top of the print and let the nozzle extrude hot filament until the color changes.   The paper keeps the new filament from sticking.

----------


## tsteever

The first M600 works great. All I add is the m600. The printer retracts, raises up off the bed and then moves over to the edge of the printer and retracts some more to move the filament out of the nozzle. I then manually add new filament and hit the button. It moves back to where it left off and resumes. I don't add any more to it then that. 

On on the second m600 it just spits out filament. The first works, just not the second!

----------


## JSeeley

Thanks for the tips! 
I'm not at that level yet, but this knowledge will come in handy. I'm just trying to get a feel for the variable needs each program/shape demands. I created some standard size blocks and circles/rings files for calibration and trial and error test runs. It's amazing how differently a 12.70cm cube prints when you start changing the variables from print to print. I'm using Simplify for slicing, and am intrigued by the options you are given to dial in a print/build.

----------


## Roxy

> On on the second m600 it just spits out filament. The first works, just not the second!


Oh?  That is very strange.   Most of the time when I use M600 I have several of them in the GCode file because I usually return to the original color I started the print with.

----------


## tsteever

Roxy, do you just add them in? Just a M600? Do you need to be mindful where to put them? I am thinking I am just not getting the sequence correct. I want to add a M600 right before the fill is printed on my top layer and then add another m600 to switch back before the next layer begins. Here is the order I'd like to print...

Print begins and prints beginning layers.
Print begins layer 8 and prints the permineters
M600
Print resumes layer 8 and prints fill 
M600
Print resumes and moves to layer 9
Prints perimeters
M600
Prints fill
M600
Prints next layer and finished print

----------


## Roxy

> Roxy, do you just add them in? Just a M600? Do you need to be mindful where to put them? I am thinking I am just not getting the sequence correct. I want to add a M600 right before the fill is printed on my top layer and then add another m600 to switch back before the next layer begins. Here is the order I'd like to print...


Yes, I just edit them into the GCode file.   I usually use http://gcode.ws/# to find the exact layers I want to be different color.   Once I know the layer height, I search for a G1 Z????  in the GCode file that matches where I want the color change.  And then I almost always add a M600 Z50 after that line that raises the Z-Axis for the next layer.

----------


## tsteever

What happens if you just enter the M600, nothing else?

Can you describe your printers movements with the M600 Z50 command?

----------


## Roxy

It does a very small initial retraction.   It raises the nozzle about 50mm.    I moves the nozzle to about (100,100).   And then it does a much longer retraction to get the filament fully cleared.

----------


## tsteever

So, it was my understanding that the axis would lock (motors hold position) while changing filament. I was able to move my axis. I added a M600 Z20 to my code and it appears to be working. I think there was some other issues causing the weird extrusion. 

So, am I mistaken or do I need to add an additional command to get the acid to lock?


Edit: So it looks like it locks the axis, but for a limited time. Anyway to lengthen this time? Like until I push the button?

I think my earlier problems we from me combining different gcodes together. I wanted a solid layer interjected where my slicer puts a bunch of weird fill. I sliced two versions, one with 100% fill and one normal. I cut the code from the normal print and pasted the code from the 100% print (For the identical layer). I suspect there is something with the extruder messing things up. Perhaps I need to insert a G92 E0 in or something.

----------


## Roxy

> So, am I mistaken or do I need to add an additional command to get the acid to lock?
> 
> Edit: So it looks like it locks the axis, but for a limited time. Anyway to lengthen this time? Like until I push the button?


In Configuration_adv.h there is a line that says:

#define DEFAULT_STEPPER_DEACTIVE_TIME (60*5)

I have mine set to 5 minutes.

----------


## tsteever

I figured out my troubles were bot related to the M600 but the fact that I have attempted to splice two different gcodes together. I have a name badge that I want to put two solid layers in on layers 3 and 4. Layers 1 and 2 have writing in laid in them and I want layer 3 to be a solid layer instead of the sloppy bridging my slicer does (That is the only thing I do not like about Matter Control). So, I sliced up two models, one with the writing and one without set to 100% fill. I then cut the Gcode from the 100% fill models layers 3 and 4 and pasted them into the model with the letter.

When I run it in gcode viewer it looks fine as does my gcode emulator. When i print however, it makes a huge mess when it gets to the sliced section. My suspicion is there is something wrong with how the extruder count is off from one print to the other. Here is one section of sliced code. Is this even possible to do (combine slices that is)?

Layer two is the beginning of the sliced code.


```
; TYPE:WALL-INNERG1 F1800 E690.89384
G1 F3600 X166.706 Y171.423 E690.89959
G1 X166.331 Y172.572 E690.91453
G1 X166.241 Y171.423 E690.92878
G0 F10500 X165.808 Y171.023
; TYPE:WALL-OUTER
G1 F2520 X167.257 Y171.023 E690.9467
G1 X166.089 Y174.601 E690.99325
G1 X165.808 Y171.023 E691.03763
; LAYER:2
G0 F10500 X144.17 Y201.842 Z0.7
G0 X144.17 Y201.842
; TYPE:WALL-INNER
G1 F3600 X144.709 Y202.256 E781.43384
G1 X145.337 Y202.517 E781.44225
G1 X145.973 Y202.6 E781.45018
G1 X154.051 Y202.6 E781.55007
G1 X154.687 Y202.517 E781.558
G1 X155.315 Y202.256 E781.56641
G1 X155.854 Y201.842 E781.57482
G1 X156.268 Y201.303 E781.58322
G1 X156.529 Y200.675 E781.59163
G1 X156.617 Y200 E781.60005
G1 X156.529 Y199.325 E781.60847
G1 X156.268 Y198.697 E781.61688
G1 X155.854 Y198.158 E781.62528
G1 X155.315 Y197.744 E781.63369
```

----------


## Roxy

I wouldn't try to splice two GCode files together...   You are just asking for trouble.   You might be able to merge the two .STL files together in Slic3r the way you want them.

----------


## tsteever

I don't use slic3r. Inconsistent results and odd artifacts/movements with it. I use Matter control. One print I make a lot has a large overhang. Slic3r cannot seem to get it. I worried it was my printer. I switched to Mattercontrol and it went away. I get over hangs with perfect results approaching 60 degrees now, I think it could even do better but I haven't tried.

I figured out my splicing problem. It was indeed the extruder distance. What I did to solve it was to insert a G92 EXXXXXXX to what ever the previous layer extruder distance was. Print came out perfect and exactly as I wanted it.

----------


## Roxy

> I figured out my splicing problem. It was indeed the extruder distance. What I did to solve it was to insert a G92 EXXXXXXX to what ever the previous layer extruder distance was. Print came out perfect and exactly as I wanted it.


I think Slic3r resets the extruder distance to 0.00 everytime it switches layers.   You might not have had this problem if you were using Slic3r !     :Smile:

----------


## best49erfan

I have an Alunar M508. can I use the same gcode commands to do a color change?

----------


## Roxy

> I have an Alunar M508. can I use the same gcode commands to do a color change?


Unknown!   But multiple filament extruders are getting some traction now.   We need to add a pallet command so you can define how much filament from each of the sources is going to be feed into your extruder.   For starters, that will let you mix colors.   If you load primary colors as filaments, in theory you can get what ever you want as an output color.   (Of course it won't be that good.  But it will be a lot better than doing an M600 and changing filament to get a different color)

----------

