Plan B code is based on Gcode, it shares much of the structure of Gcode, but it has a few functions added specifically for Plan B. It is designed to be light to read (speed can be an issue) and versatile (it can control a nearly infinite amount of nozzles).
Printing with Plan B code is considerably faster than printing with a single nozzle but it does require a fully functional cartridge. As long as a cartridge works properly, Plan B code is the better choice.
Plan B code only uses two different kinds of commands.
G1 with D command
Example: G1 Y52.11 Z1.21 D0
G1 is a normal Gcode command and is used for controlled movement in a straight line. The D command is the part that is different from ordinary Gcode. D tells the printer that it needs to move to a position and start the printing sweep. D0 means start the sweep in the negative direction, D1 means start the sweep in the positive direction.
Y52.11 moves the printer to Y52.11mm absolute.
Z1.21 moves the printer to Z1.21mm, is this is bigger than the previous Z coordinate, a new layer will be deposited the size of the difference between 1.21mm and the previous layer.
For the X position the printer will actually look ahead and read the next line for a Nozzle command. This will determine the X position for the printer. If a Nozzle command is not seen within 5 lines of code, the printer might glitch and not print properly. A distance will either be added or subtracted (based on D1 or D0) from the X coordinate by the printer to account for acceleration.
Example: N0 N1 N4 N5 N6 X22.56 T1
Nozzle commands start with naming the nozzles to which the changes apply. In this case, N0, N1, N4, N5 and N6. All other nozzles will be ignored.
X is the coordinate at which this change needs to occur, this X is also the coordinate G1 with D command will look ahead for.
T is the toggle command, It will either turn on (T1) or off (T0) the nozzles stated in the line of code.
Because the code can only turn on OR turn off a set of nozzles, it is allowed to have 2 Nozzle commands with the same X coordinate one after another (order does not matter). This way it is possible to turn on nozzles and turn off different nozzles at the same coordinate.
Plan B code example:
G1 Y0.00 Z0.00 D1
N0 N1 N2 N3 N4 N5 N6 N7 X0.00 T1
N8 X0.10 T1
N9 X0.21 T1
N10 X0.35 T1
N11 X0.51 T1
N0 N1 N2 N3 N4 N5 N6 N7 N8 N9 X10.00 T0
N10 X19.01 T0
N11 X19.21 T0
G1 Y3.18 Z0.00 D0
N4 N5 N6 N7 N8 N9 N10 N11 X20.00 T1
N3 X19.9 T1
N2 X19.89 T1
N1 X19.65 T1
N0 X19.49 T1
N2 N3 N4 N5 N6 N7 N8 N9 N10 N11 X10.00 T0
N1 X0.99 T0
N0 X0.79 T0
Rules for Plan B code:
- N states the nozzle that needs to be turned on or off by the T command
- Multiple N’s can occur in a single command
- The order of the nozzles (N) do not matter, but increasing order is preferred.
- T states if it is either on or off (T1 is on, T0 is off)
- T0 and T1 cannot happen in the same line, separate lines at the same coordinate are needed to toggle nozzles both on and off.
- G1 with D command starts a line (D1 is positive direction, D0 is negative direction). The line will need no Y coordinates after a line has been started.
- Another G1 (either with or without D) command will stop the line and move the printhead to a new location.
- Z must move up to add a new layer.
- Z can’t decrease only increase (decreases are ignored)
- Too big Z increases will jam the printer.
- At the G1 with a increase in Z, the printer will also look at the X and Y coordinate to determine where the printhead needs to be after the new layer is deposited.