Switch module takes a lot of time to OFF

Now I’m working on a custom pick and place delta robot solution, based on smoothie.
I’m using a misc switch to control solenoid valve of vacuum ejector.
Config of switch:
switch.misc.enable true
switch.misc.input_on_command M42
switch.misc.input_off_command M43
switch.misc.output_pin 0.17
switch.misc.output_type digital

All is working perfectly, but it takes too much time to turning off this switch.
And I don’t have any idea why.

This is a log from my custom writed host, with using comands to turn ON and OFF misc switch:
object detected = 0.19020
start moving = 0.19194
turn on vacuum = 0.23800
near to object = 0.27578
go down to take object = 0.28497
go up with object = 0.29475
go to point of placement = 0.30717
sending М43 = 0.30728
vacuum is off = 1.16620
placing object in a box = 1.17320
On parking! Done! = 1.18360

Time from sending M43 to get an “ok” from smoothie - almost a one second! It’s really criticall for me, because my robot is fast. But now it just hangs in place, waiting turning off the vacuum.
And in this case why turn ON command (M42) worked instantly?

Here is a log, when I don’t use any of switch command, just movement:
object detected = 0.25767
start moving = 0.25882
near to object = 0.29923
go down to take object = 0.32037
go up with object = 0.33453
go to point of placement = 0.34480
placing object in a box = 0.51749
On parking! Done! = 0.67044

So I would be grateful for any advice,
Thank you!

1 Like

Smoothie doesn’t execute commands when it gets them, it places them in a queue and executes them once it’s their turn ( or it couldn’t do predictive acceleration )
Add M600 ( wait for execution ) before and after your M43 and this should get fixed.

Thank you for answer!
But according to http://smoothieware.org/supported-g-codes M600 - it’s a suspend print.
Maybe you mean M400?
But I tried put M600 like you say - there’s no effect, smoothie just said that print “already suspended”.

I’m sending this gcode like this via serial port on every cycle:
G1 X-24 Y-104 Z130 F80000
G1 Z92
G1 Z130
G1 X-110 Y130 Z90 E-75 F80000
G1 Z20
G1 Z105

New command sending only after ‘ok’ is received. New cycle starting only when M400 answers “ok”.
Time from start streaming to answer of M400 takes about 1.2 second with using switch M42 and M43, and about 0.6 secs without it.

I checked how much time my host is waiting for ‘ok’ when sending M43:
sending М43 = 0.28486
----start sending = 0.00000
----sended = 0.00090
----ok received = 0.87310

sending G1 X-24 Y-104 Z130 F80000 = 0.26233
----start sending = 0.00000
----sended = 0.00046
----ok received = 0.00505

0.8 secs instead 0.00505.

So, any thoughts about this?

Yes, M400 sorry.

Hi everyone!
After several experiments and a few conclusions, I guess that the execution of commands:

G1 X[] Y[] Z[] F[]

will be equivalent:
G1 X[] Y[] Z[] F[]

And now, there is a question - can smoothie execute M commands while executing G1 movement commands?
Like it described with difference of G0 and G1.

I don’t so familiar with C++ to find answer in source code,
So I would be grateful for any advice,
Thank you!

No, Smoothie will always wait for the queue to be empty to execure switch commands. The code of Smoothie would need to be massively rewritten to enable real-time M-codes.