Switch delay

I have a simple GCode that appears to have different behavior depending on the use of a switch.

The Gcode is as follows:


M106 G1 A360.0 Y0.200 E3 F21599.999999968964  
M106 G1 A360.0 Y0.200 E3 F21518.336483901028  
M106 G1 A360.0 Y0.200 E3 F21437.288135562419  
M106 G1 A360.0 Y0.200 E3 F21356.848029988076 
M106 G1 A360.0 Y0.200 E3 F21277.009345763821

This should siply rotate the A axis 360, move the Y axis 0.2mm, and extrude 3mm of filament at a feedrate around 21000 mm/min.

Everything is as it should be except, when I have M106 on the line it creates a short delay between each line.

When M106 is not on the line, there is no delay in between excuting each line of code.

Does Smoothie implement a delay for activating switches?

Can this be modified?

The pins I’m using are P1.30 and P1.31.

I am trying to use the switch as a digital switch (on/off) and wanting to trigger something each layer of material that is laid down, that is why we have the M106 on each line.

what does your firmware expect for the gcode for M106?
Have you tried M106 S255 G1 …
Or M106 P0 S255 G1 …

Maybe parsing delays but you’ll want to figure out what your firmware is expecting and try to optimize for it.

Thank you for the suggestions, we’ve tried the suggested g-code and it still gives us a pause after each line.

What we have tried to do the following:

  • running without the M codes for the switch (this gives us the expect movements without the pause, but of course we do not get the switch)

  • we tried putting the g-command for the switch in different locations in the g-code. For example, we put it in the beginning of each line, at the end of each line, and on its own individual lines. We get identical behavior with both.

  • we tried with both the RGS and GCoder modules. Same behavior with both.

  • we then tried a different pin and it still gave us a pause.

  • we tried assigned a different MCode, for example M106 we used M42, and it still gives a pause.

  • We looked at the firmware source for the switches and did not see any reference to a sleep time.

  • We also looked at the debug information and noticed that the commands have a “*XX” values attached to it (See below). Is this a processing time from smoothie? e.g. *19 = 19ms? If so, it doesnt appear that processing the M-codes in the same line does anything more than add additional processing (e.g. 3 x 20ms = 60ms) (S

Appreciate your help here.

with no switch command:


- Extruder 0: 1.00mm
- Extruder 1: 26.00mm
The print goes:
- from 0.00 mm to 0.00 mm in X and is 0.00 mm wide
- from 0.10 mm to 0.50 mm in Y and is 0.40 mm deep
- from 0.00 mm to 0.00 mm in Z and is 0.00 mm high
Estimated duration: 1 layers, 0:02:05
SENT: N-1 M110 *15
RECV: ok
Print started at: 05:25:35
SENT: N0 G91 *17
RECV: ok
SENT: N1 T1 *58
RECV: ok
SENT: N2 G1 A360.0 Y0.100 E3 F5.988647114475 *19
RECV: ok
SENT: N3 G1 A360.0 Y0.100 E3 F5.977337110482 *28
RECV: ok
SENT: N4 G1 A360.0 Y0.100 E3 F5.966069745523 *31
RECV: ok
SENT: N5 G1 A360.0 Y0.100 E3 F5.954844778928 *17
RECV: ok
SENT: N6 G1 A360.0 Y0.100 E3 F5.943661971831 *19
RECV: ok
SENT: N7 G1 E-15 F240**51
RECV: ok
SENT: N-1 M110**15
Print ended at: 05:25:35 and took 0:00:00
RECV: ok
SENT: M117 Finished Print
RECV: ok
SENT: M105
RECV: ok T0:inf /0.0 @0 B:inf /0.0 @0
SENT: M105
RECV: ok T0:inf /0.0 @0 B:inf /0.0 @0

With switches:


oading file: C:\printfoam\python\code\smoothie_and_projector\test_1\test_1.gcode
Loaded C:\printfoam\python\code\smoothie_and_projector\test_1\test_1.gcode, 28 lines
0.00mm of filament used in this print
- Extruder 0: 1.00mm
- Extruder 1: 26.00mm
The print goes:
- from 0.00 mm to 0.00 mm in X and is 0.00 mm wide
- from 0.00 mm to 0.00 mm in Y and is 0.00 mm deep
- from 0.00 mm to 0.00 mm in Z and is 0.00 mm high
Estimated duration: 1 layers, 0:00:03
SENT: N-1 M110 *15
RECV: ok
Print started at: 05:26:53
SENT: N0 G91 *17
RECV: ok
SENT: N1 T1 *58
RECV: ok
SENT: N2 M106M107 G1 A360.0 Y0.100 E3 F5.988647114475 *50
RECV: ok
SENT: N3 M106M107 G1 A360.0 Y0.100 E3 F5.977337110482 *61
RECV: ok
SENT: M117 85.71% Est 0.00.00
RECV: ok
SENT: N4 M106M107 G1 A360.0 Y0.100 E3 F5.966069745523 *62
RECV: ok
SENT: N5 M106M107 G1 A360.0 Y0.100 E3 F5.954844778928 *48
RECV: ok
SENT: N6 M106M107 G1 A360.0 Y0.100 E3 F5.943661971831 *50
RECV: ok
SENT: M105
RECV: ok T0:inf /0.0 @0 B:inf /0.0 @0
SENT: N7 G1 E-15 F240*51
RECV: ok
SENT: N-1 M110*15
Print ended at: 05:26:58 and took 0:00:04
RECV: ok
SENT: M117 Finished Print
RECV: ok

Hello, welcome to the community!

Why do you have M106 on the same link as the G1? That’s just not valid Gcode.
Put the M106 on it’s own separate line, before or after the G1 depending on your needs.

Also, as the documentation asks, when asking for help like this, please post a link to your configuration file on Pastebin, so we can check it. And give us your firmware version, information about the machine, etc. Anything that could help/inform us.

Thanks!