CompoundCarl
Posts: 2005
Joined: Wed Aug 05, 2015 6:23 am

Instructions for Basic Color Mixing in Simplify3D

Sat Dec 24, 2016 7:00 am

So I've been playing with the Repetier color mixing for a bit trying to find an easy way to control the colors from Simplify3D. I think I found a really easy approach that allows you to change the colors whenever you want. For example, you could have a part that changes to different color at a specific layer, or setup different processes so that each model prints with a different color. Here's how to set it up.

SETUP

First of all, I'm currently working with the Repetier color mixing, which is described in more detail here (http://www.reprap.org/wiki/Repetier_Color_Mixing). I am also going to assume that you are using something like the diamond hot end which has 3 different filament inputs that you mix to achieve the different colors. So using repetier, the actual mixing is accomplished using something called a "virtual" extruder. This basically means that you tell the firmware that anytime you switch to T0, you want the diamond hot end to use a mixing ratio that will produce the color cyan. Then you can setup other colors for other tools (T1 is ocean, T2 is blue, T3 is violet, and so on). There's 16 different colors in the documentation, so that's I'm using for now. To setup each of these virtual extruder color combinations, just copy/paste the following at the top of your starting script:

Code: Select all

; Cyan
M163 S0 P1
M163 S1 P0
M163 S2 P0
M164 S0

; Ocean
M163 S0 P5
M163 S1 P1
M163 S2 P0
M164 S1

; Blue
M163 S0 P1
M163 S1 P1
M163 S2 P0
M164 S2

; Violet
M163 S0 P1
M163 S1 P5
M163 S2 P0
M164 S3

; Magenta
M163 S0 P0
M163 S1 P1
M163 S2 P0
M164 S4

; Raspberry
M163 S0 P0
M163 S1 P5
M163 S2 P1
M164 S5

; Red
M163 S0 P0
M163 S1 P1
M163 S2 P1
M164 S6

; Orange
M163 S0 P0
M163 S1 P1
M163 S2 P5
M164 S7

; Yellow
M163 S0 P0
M163 S1 P0
M163 S2 P1
M164 S8

; Spring Green
M163 S0 P1
M163 S1 P0
M163 S2 P5
M164 S9

; Green
M163 S0 P1
M163 S1 P0
M163 S2 P1
M164 S10

; Turquoise
M163 S0 P5
M163 S1 P0
M163 S2 P1
M164 S11

; Cyan-Brown
M163 S0 P2
M163 S1 P1
M163 S2 P1
M164 S12

; Magenta-Brown
M163 S0 P1
M163 S1 P2
M163 S2 P1
M164 S13

; Yellow-Brown
M163 S0 P1
M163 S1 P1
M163 S2 P2
M164 S14

; Brown
M163 S0 P1
M163 S1 P1
M163 S2 P1
M164 S15

M104 S[extruder0_temperature] T0
The M163 commands set the mixing ratio for each of the 3 filament inputs, and then the M164 command saves that mixing ratio to a specific tool (so if you look at the orange color, M164 S7 means that you want to save the orange color combination to tool 7 - anytime you use T7, the extruder will print in orange). So after you do that, the firmware now knows the colors that you want to use, and which tool number corresponds to each color. So now we just have to handle switching to the different colors!

The most flexible way I have found to do this is by using a trick to change a few unused temperature commands into the color change commands that we need. Simplify3D already has some nice flexible temperature controls, so this allows us to leverage that for color mixing! Since the ambient temperature is usually around 25 degrees C, we know we should never have a "set extruder to 10 degrees C" command in our gcode file, so it's safe to use this command for our trick since we know it isn't being used elsewhere. So go ahead and add following code into your "additional commands for post-processing" section at the bottom of the Scripts tab. Just copy/paste everything below into that section.

Code: Select all

{STRIP "T"}
{REPLACE "M104 S1 T0" "T0"}
{REPLACE "M104 S2 T0" "T1"}
{REPLACE "M104 S3 T0" "T2"}
{REPLACE "M104 S4 T0" "T3"}
{REPLACE "M104 S5 T0" "T4"}
{REPLACE "M104 S6 T0" "T5"}
{REPLACE "M104 S7 T0" "T6"}
{REPLACE "M104 S8 T0" "T7"}
{REPLACE "M104 S9 T0" "T8"}
{REPLACE "M104 S10 T0" "T9"}
{REPLACE "M104 S11 T0" "T10"}
{REPLACE "M104 S12 T0" "T11"}
{REPLACE "M104 S13 T0" "T12"}
{REPLACE "M104 S14 T0" "T13"}
{REPLACE "M104 S15 T0" "T14"}
{REPLACE "M104 S16 T0" "T15"}
This removes any of the default tool change commands from the gcode file, and then adds our own tool change commands for each color combination that we need. So if you want to change to the green color (the 11th color in our list), you just need to tell Simplify3D to set the extruder color to 11 degrees, and then we automatically replace that command with "T10" which switches to the green virtual extruder.

So to summarize, we are putting some fake temperature commands in the file that automatically get replaced with the color changing commands that we need.

Ok, so how do we actually use this now that we have set it up? I'll go through a few quick examples below.


EXAMPLES


1) Change to a different color every 20 layers - assuming you have already made the changes above, go to the Temperature tab and just enter the colors you want at each layer. So if you want to use red for layers 1-19, green for layers 20-39, and blue for layers 40 and beyond, you would just enter the following temperature setpoints for the extruder temperature controller:

layer 1 - temperature 7
layer 20 - temperature 11
layer 40 - temperature 3

Simplify3D will put an "M104 S7 T0" at layer 1, "M104 S11 T0" at layer 20, and "M104 S3 T0" at layer 40. Our post processing script then replaces that with T6 at layer 1 (our red virtual extruder), T10 at layer 20 (the green virtual extruder), and T2 at layer 40 (blue virtual extruder). So you can see how easy this is to modify.


2) Use a different color for each process - thankfully Simplify3D already knows how to switch temperatures when going between different processes. So if you were printing one model at 200C and using another process to print a second model at 190C, then the software already put in the appropriate temperature change commands anytime you were switching between processes. So that same idea works for our special color mixing commands. Let's say you wanted to setup one process to print a part in orange, and another process that printed a different part in violet. Just create the first process, use the "Select Models" button so that is only applies to the model you want, then use the following temperature setpoint:

layer 1 - temperature 8

So now anytime the software prints using that process, it will make sure to put the "M104 S8 T0" temperature command in the file, which gets replaced with our T7 virtual extruder (orange). Then setup a second process, use "Select Models" button so that this process only applies to the second model, then enter the following setpoint:

layer 1 - temperature 4

That tells the second process to always use "M104 S4 T0", which gets replaced with T3 (the violet virtual extruder). So now when you prepare to print, you can select both processes and it will automatically switch colors so that the first part is always printed in orange and the second part is always printed in violet.


IMPORTANT NOTES

Now, there are a few other important things to keep in mind when using this trick
  • Since we are using the temperature setpoints to control the color mixing, you need to make sure to handle the extruder temperature on your own. You can do this by either putting a static temperature command in your starting script like "M109 S200 T0" or just preheat the extruder manually beforehand.
  • Remember that the temperature values were always 1 higher than the tool numbers. I did this because it seems that S3D doesn't like when you use a temperature of 0 degrees, so just make sure to reference the lists above when you want to find what temperature to use for each color.
  • We need to make sure that we define the virtual extruders before we try to switch to them, so I had to add "M104 S[extruder0_temperature] T0" to the bottom of the starting script I posted above. That is needed, because otherwise Simplify3D puts the temperature command for the first layer at the very beginning of the file before the rest of the starting script.
  • If you do choose to setup multiple processes, don't forget to add the code at the beginning of this post to every single process. If you forget to add it to some of the processes, you may run into trouble.
  • Keep in mind that the post-processing commands aren't actually run until you export the gcode file, so don't be surprised if you set the preview coloring to "active toolhead" and you don't see the changes. If you click "Save toolpaths to disk", save the file, then open the file in a text editor, you will see that all the changes have been made.

Finally, I should mention that this method requires some extra complexity because I wanted to use all 16 colors (and I could even add another 20 or so colors if I wanted). But you can make this MUCH easier if you only want to use 6 colors or less. In that case, because Simplify3D already supports up to 6 different extruders, then all you need to do is paste the M163 and M164 commands that you want into your starting script. So maybe you setup red at T0, green at T1, and 4 other colors at T2-T5. Then you can add 5 more extruders on the Extruder tab in Simplify3D, making sure that each one has its own toolhead number (T0, T1, T2, T3, T4, and T5). You could even name them something like "Red Extruder", "Green Extruder", etc to make it really easy. Then you would just use the normal extruder selections to choose what colors are used for which things. You can setup multiple processes like before, and just change all the extruder selections to "Green Extruder" or something like that. Hopefully this makes sense.

Anyways, I've been using this for a few days now and it's working really well, so I would be interested to hear what others think!

YvesAtLorax
Posts: 3
Joined: Thu Jun 25, 2015 10:10 pm

Re: Instructions for Basic Color Mixing in Simplify3D

Sat Feb 11, 2017 8:51 pm

Very nice work around!!! Thank you for posting it.

cece
Posts: 1
Joined: Sun Feb 25, 2018 7:07 am

Re: Instructions for Basic Color Mixing in Simplify3D

Sun Feb 25, 2018 10:20 am

Hello and thank you for this tutorial that enlighten me on another track :D . I left on the M165 Command, because I flashed in Marlin 1.1.8. And also wanted to use the script to call this command, to assign it to one of the twelve models of a group. I will still persevere in this direction to see if there is a possibility. Or if it's a failure go in your direction using the Repetier firmware, like cous. A big thank-you

bipsen
Posts: 2
Joined: Mon Feb 26, 2018 6:07 am

Re: Instructions for Basic Color Mixing in Simplify3D

Mon Oct 15, 2018 6:42 am

Hi

Thanks for the input - I was looking for something to get a bit better knowledge about printing with mixing extruders...

If printing with multiple colors in the same layer (that will require multiple STL's to be imported an arranged right), how can tool change then be handled ? A priming tower (or multiple, if possible) is probably needed - but how would the process then look ?

Regards
/B

Return to “General Discussion and Tips”