M581 in RRF3 not triggering trigger2.g
-
@bearer
Snippet from M581 Gcode documentation...…..
Any trigger number # greater then 1 causes the macro file sys/trigger#.g to be executed.
…….That is what I have done.
In my sys folder where config.g etc resides I have placed the trigger2.g file as per documentation.
-
@bearer
Sorry, there was a typo error in the first post. It should have said:The file trigger2.g in the sys/ folder has the following code...…..
-
If I put M581 ^P"!io2.in"T2 C0 in config.g as you suggested I get the following error:
Error: M581: Missing port name string when config.g reloads.
-
^
goes inside the""
is it safe to try and execute the trigger macro to see if there are any issues with the code?
M98 P"/sys/trigger2.g"
should to the trick to see if its okay... or just post the config.g and trigger2.g contents so people can see whats going on.
-
@bearer
Running M98 P"trigger2.g"in the console works.
adding ^ inside "" does not.Here is my config.g:
; Configuration file for Duet 3 (firmware version 3)
; executed by the firmware on start-up
;
; generated by RepRapFirmware Configuration Tool v2.1.1 on Mon Nov 04 2019 16:21:57 GMT+0000 (Greenwich Mean Time); General preferences
M555 P2 ; Set Marlin-style output
G21 ; Set dimensions to millimetres
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"Duet3" ; set printer name
M586 P0 S1 ; Enable HTTP
M586 P1 S1 ; Enable FTP
M586 P2 S1 ; Enable TelnetM669 K1 ; select CoreXY mode
; Drives
M569 P0 S1 ; X physical drive 0.0 goes forwards
M569 P1 S1 ; Y physical drive 0.1 goes forwards
M569 P2 S0 ; Z0 physical drive 0.2 goes forwards
M569 P3 S0 ; Z1 physical drive 0.3 goes forwards
M569 P4 S0 ; E0 physical drive 0.4 goes forwards; Set drive mapping
M584 X0 Y1 Z2:3 E4 ; Dual Z make sure drive 2 is left hand Z and 3 is right hand
M92 X80.00 Y80.00 Z400.00 E96.00 ; set steps per mm
M350 X16 Y16 Z16 E16 I1 ; configure microstepping with interpolation
M566 X600.00 Y600.00 Z12.00 E120.00 ; Set maximum instantaneous speed changes (mm/min) - Jerk
M203 X18000.00 Y18000.00 Z180.00 E1500.00 ; set maximum speeds (mm/min)
M201 X3000.00 Y3000.00 Z100.00 E10000.00 ; set accelerations (mm/s^2) (print moves)
M906 X1000 Y1000 Z1000 E1100 I30 ; set motor currents (mA) and motor idle factor in per cent
M84 S30 ; Set idle timeout; Leadscrew positions: The measurement is taken from X=0, Y=0. Therefore X will be negative, Y positive and middle of bed = 160
M671 X-100:415 Y160:160 S2.0; Axis Limits
M208 X-15 Y-12 Z0 S1 ; Set axis minima (adjust to make X=0 and Y=0 the edges of the bed)
M208 X310 Y310 Z380 S0 ; set axis maxima; Endstops
M574 X1 S1 P"!io0.in" ; configure active-low endstop for low end on X via pin io0.in
M574 Y1 S1 P"!io1.in" ; configure active-low endstop for low end on Y via pin io1.in
M581 P"!io2.in" T2 C0 ; configure active-low endstop to run a macro called trigger2.g
; created in sys/ and let it trigger at any time without restrictions; Z-Probe
M558 P1 C"io3.in" H5 F120 T6000 ; set Z probe type to unmodulated and the dive height + speeds
; G31: the P is the reported Z value when triggered. X,Y are offset coordinates. Z is trigger height, you can decrease value if nozzle is too close
; or increase if too far away.
G31 P500 X-30 Y-5 Z2.18 ; set Z probe trigger value, offset and trigger height; Mesh Grid
; The following M557 commands are not needed if you are using a bed.g file to perform bed compensation
;*** Adjust the XY coordinates in the following M557 commands to suit your build and the position of the Z probe
M557 X10:280 Y20:280 S50 ; Define small mesh grid
;M557 X10:280 Y10:280 S20 ; Define large mesh grid; Heaters/temperature sensors
M308 S0 P"temp0" Y"thermistor" T100000 B4138 ; configure sensor 0 as thermistor on pin temp0
M950 H0 C"out0" T0 ; create bed heater output on out0 and map it to sensor 0
M143 H0 S120 ; set temperature limit for heater 0 to 120C
M307 H0 B0 S1.00 ; disable bang-bang mode for the bed heater and set PWM limit
M140 H0 ; map heated bed to heater 0
M308 S1 P"temp1" Y"thermistor" T100000 B4138 ; configure sensor 1 as thermistor on pin temp1
M950 H1 C"out1" T1 ; create nozzle heater output on out1 and map it to sensor 1
M143 H1 S280 ; set temperature limit for heater 1 to 280C
M307 H1 B0 S1.00 ; disable bang-bang mode for the nozzle heater and set PWM limit
M307 H1 A299.8 C109.4 D4.0 S1.00 V12.3 B0 ; Autotune result for hotend
M307 H0 A109.8 C457.8 D2.1 S1.00 V12.3 B0 ; Autotune result for bed;CPU Temperature Calibration
M912 P0 S-10.0; Fans
M950 F0 C"out7" Q500 ; create fan 0 on pin out7 and set its frequency (parts fan)
M106 P0 S0 H-1 ; set fan 0 value. Thermostatic control is turned off
M950 F1 C"out8" Q500 ; create fan 1 on pin out8 and set its frequency (ext fan)
M106 P1 S1 H1 T45 ; set fan 1 value. Thermostatic control is turned on;Re-assigned fan pins
;CPU fan
M950 F2 C"out9" ; create fan 2 (CPU fan)
M308 S3 Y"mcutemp" A"mcutemp" ; set up a virtual sensor for cpu fan
M106 P2 T45 H3 ; set fan 2 value. Fan comes on when cpu temp is above 45 degrees
;Led Lighting
M950 F3 C"out4" Q500 ; create a fan 3 output to use for led lighting control on pin out4
M106 P3 S0 ; set output default to off; Tools
M563 P0 S"Extruder0" D0 H1 F0 ; define tool 0
G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C; Custom settings
;CPU Temperature Calibration
;M912 P0 S-15.8 ; Find correct value
;M42 P2 S255 ; Turn led lighting on full
;M98 P"LevelLeadscrews.g" ; Option to perform leadscrew levelling
;M98 PEnable Mesh Levelling ; Option to enable on start up
T0 ; select first tooland my trigger2.g:
;trigger2.g
; Macro to safeguard machine upon failure of Z probing;M291 P"Upper limit has been triggered!" R"Probe Failure!" S2
G91 ; relative positioning
G1 H2 Z5 F6000 ; lift Z relative to current position
G90 ; back to absolute positioning -
Ok here's what ive found:
In the M581 command I re-introduced the missing space between the "io2.in" and T2.
I operated the microswitch connected to io2.in and nothing happened.
I started a print and operated the microswitch and the trigger2.g executed.
It seems that the "C0" parameter to set the code to execute at anytime does not work and only operates when printing.
Or am I missing something? -
In the Gcode description for M581 it says:
M581 - RepRapFirmware 3
Parameters
P Specify one or more pin names
Tnn Logical trigger number to associate the endstop input(s) with, from zero up to a firmware-specific maximum
C Condition: whether to trigger at any time (C0, default) or only when printing a file from SD card (C1)The Condition for C indicates that when set to C0 will trigger at any time. This is not entirely true. It will trigger AFTER all current moves have finished.
So it is useless for my purpose. -
@chas2706 said in M581 in RRF3 not triggering trigger2.g:
It will trigger AFTER all current moves have finished.
i belive that could be a bug as it did behave like described in the documentation a while ago.
which versio are you using?
M115
will show it. -
@bearer
Oh right maybe it is a bug.I'm on version 3.0RC2.
-
Hmmm... I'd expect the trigger to instantly start executing the trigger2.g... however, I'd expect the commands inside that file to enter the planner Q like anything else.
Phrased another way: If there is a long running single G-Code command executing at the moment of trigger, the first command (other than M112 estop, which is handled in a special way) inside the file cannot start until the current command finishes. It also might be true that a chain of short moves that have been treated by the planner as a connected chain, that (dynamic) group of commands might have to finish.
I have no hands on to current or past behaviors. The above is just what I'd expect from the way the planner works.
-
@Danal Last time I tested it on my gen 3 main board (about 2 months ago) it worked as expected/intended (i.e. practically instantly even when printing). The only thing I'm aware of is that M581 is not currently supported for gen 3 expansion boards but both the OP and I are using it with the main board.
@chas2706 Try removing the H2 parameter from the G1 move in the macro. As long as the printer has been homes, it isn't necessary and maybe H2 moves within a print get ignored (because the H2 parameter is usually only used when homing).
If that doesn't work, can you add M118 S"Trigger 2" to the start of your macro. Then check if you see that message when you trigger the macro during a print. I'm just wondering if the macro itself is being called but something is preventing the contents of the macro from running. Adding a message at the start of the macro will prove if it is being called or not.
-
@deckingman said in M581 in RRF3 not triggering trigger2.g:
it worked as expected/intended (i.e. practically instantly even when printing).
That would certainly be preferred! I'll keep reading as you guys experiment with this. Very interested.
-
@Danal said in M581 in RRF3 not triggering trigger2.g:
That would certainly be preferred! I'll keep reading as you guys experiment with this. Very interested.
I used it (M581) a lot on Duet 2. On Duet 3, I've only set up external triggers to disable the bed heater fault parameters when I get a power failure. Basically, I have a 24V UPS which cuts in and keeps the rest of the printer running but the bed is mains powered so it will go off and start to cool, eventually triggering a fault. The UPS has contacts which close when it switches to battery power and that's what I've hooked up to an io port to disable or enable bed heater fault detection depending on the status of the UPS. It works the instant that the contacts change state (I use 2 triggers). On Duet 2, I used micro switches as axes maxima switches and hooked these up such that M598 would stop motion if I did something stupid (like attempt to move beyond axis max before it had been homed). I'll do likewise on Duet 3 but I need DC to implement M581 on expansion boards first.
-
Thanks for your suggestions. I have just tried them.
With H2 removed and M118 S"Trigger2" added, I press home all and just after X and Y are homed I deliberately activate the microswitch connected to io2.in and immediately I see the Trigger2 message appear but the rest of the code is ignored until Z has finished homing.
-
@chas2706 That's probably to be expected. You need to use H2 before an axis has been homed, but once homed, then you don't.
-
You could use M564 H0 which will allow moves prior to homing. If you put that in your config.g file, then it will run when you boot. That's what I do then I never need to use H2. But the danger is that if you inadvertently send a G1 command prior to homing that moves outside the bed limits, it will try to make that move. So instead of "globally" using M564 H0, you could put it at the start of your trigger file, then put M564 H1 at the end. So your trigger file would like like:
M564 H0 ; allow moves prior to homing
G91 ; relative positioning
G1 Z5 F6000 ; lift Z relative to current position (H2 parameter removed).
G90 ; back to absolute positioning
M564 H1 ; disallow moves prior to homing. -
Thanks for your suggested code.
Unfortunately it still does not work.
My idea of use was to use a spare Z endstop microswitch as a safety device to stop movements if the Z probe failed when homing.
The microswitch is activated if Z goes too low.
The easy solution is to configure M581 to activate the emergency stop but the problem then is that I would have to manually move Z off the microswitch to enable a reset.I have a workaround though, thanks to your suggestions.
I have placed M564 H0 in my config.g and the contents of my trigger2 file is now:M118 S"Probe Failed"
M999The reset stops all movements and the state of the microswitch is not saved upon reset so I can then move Z clear using the DWC controls.
-
Could you see if there is a difference in when the code is executed if you use
M112
(e-stop)?
Makes sure to try it when its okay to to do an e-stop, i.e. not mid print:) -
@chas2706 Yes, although M581 with a C0 should work at any time, I suspect that during a homing move where the firmware would normally be looking for an end stop to be triggered, would be a special case. Funnily enough, what you plan is one of the things that I used to do on Duet 2 and which I plan to do on Duet 3 when M581 for expansion boards gets implemented. The switch is still present and wired but I can't implement it yet. In my case, though I simply use M581 T0. In fact as well as a Z min backup in case of probe failure, I also have normally closed micro switches on all the axes maxima and wire them in series so that if any one of them breaks contact, it will initiate an emergency stop. It's useful when you use M564 H0 in config.g.
-
@deckingman
Thanks again for your help. I had the very same setup on my Duet 2 board which initiated an e-stop but I was sure that kept the software in an e-stop situation because the switch remained closed.
I don't know what is different but I just tried it again and it works. I can reset the board after the e-stop is initiated and with the switch still made.
So now I am using M581 T0 and it works a treat.