Running macros in response to conditions?
-
Thank you very much, David!
Richard
-
I'm trying to get this working but must have the syntax wrong - I suspect it is how I am referring to the E0 endstop.
The example on the wiki says "M581 E1:2 S1 T2 C1 - ; invoke trigger 2 when a rising edge is detected on the E1 or E2 endstop input and a file is being printed from SD card" so I have tried M581 T2 E1 C0 and it has no effect. I then tried E0, E1, E0:1 and E1:2 and none detect the input.
I then tried M581 T2 to see what the condition was and it always returned the response below (regardless of which of the above I used).
[[language]] Trigger 2 fires on a rising edge on (none) or a falling edge on (none) endstop inputs ```so I guess I'm not referring to it correctly but can't figure it out. What am I missing? This is all with v1.21 Thanks in advance. Richard
-
I should have said, the Duet is detecting the jumper - the LED lights so it doesn't appear to be a physical issue.
Richard
-
You left out the S parameter.
-
Thank you! That now works perfectly!
Richard
-
Is there some sort of priority to the commands in config.g when starting up?
I'm setting the M665 for the taller Volcano in the config.g, and calling "M581 T2 E0 C0 S0" right near the beginning. A bit further down the config.g I run M582 T2, which, when triggered, should call trigger2.g. At the end of config.g I run a G28 and a G32 and these always run before the commands in trigger2.g
It appears that the trigger check waits until all other commands in config.g have run and then runs at the same time as
the WiFi initiates. The M291 in the trigger2.g file runs after the M291 in the config.g so this would tend to support the order I see.Is this correct? Is there any other way to do that check before the G32 runs? Alternatively, is it possible to run a different macro if the trigger 2 test is false?
Thanks for your assistance.
Richard
[[language]] ;RGN_Delta ; Communication and general M111 S0 ; Debug off M550 PRGN_Kossel ; Machine name and Netbios name (can be anything you like) M586 P1 S1 ; Enable FTP ; M551 PPassword ; Machine password (used for FTP) M540 P0xBE:0xEF:0xDE:0xAD:0xFE:0xED ; MAC Address ;*** Networking - Enable for both WiFi and Ethernet boards. M552 S1 ; Turn network on ; Configure Trigger for Smart Effector detection (uses jumper on layer fan to detect one Smart Effector) M581 T2 E0 C0 S0 ; Set Trigger 2 (0 & 1 are reserved) on endstop extruder 0 M555 P0 ; Set output to look like RepRap G21 ; Work in millimetres G90 ; Send absolute coordinates... M83 ; ...but relative extruder moves ; Axis and motor configuration M569 P0 S0 ; Drive 0 goes backwards M569 P1 S0 ; Drive 1 goes backwards M569 P2 S0 ; Drive 2 goes backwards M569 P3 S1 ; Drive 3 goes forwards M574 X2 Y2 Z2 S1 ; set endstop configuration (all endstops at high end, active high) ; M665 R228 L440.375 B185 H420 ; (e3dv6) set delta radius, diagonal rod length, printable radius and homed height M665 R228 L440.375 B185 H410 ; (Volcano) set delta radius, diagonal rod length, printable radius and homed height M666 X0 Y0 Z0 ; put your endstop adjustments here, or let auto calibration find them M350 X16 Y16 Z16 E16 I1 ; Set 16x microstepping with interpolation M92 X200 Y200 Z200 ; Set axis steps/mm M906 X900 Y900 Z900 E450 I30 ; Set motor currents (mA) and set idle current to 30% M201 X1200 Y1200 Z1200 E1000 ; Accelerations (mm/s^2) M203 X22000 Y22000 Z22000 E1200 ; Maximum speeds (mm/min) M566 X1500 Y1500 Z1500 E400 ; Maximum instant speed changes mm/minute ; Thermistors M305 P1 X200 ; RGN added for PT100 on extruder M305 P0 X201 ; RGN added for PT100 on Bed M570 S180 ; Hot end may be a little slow to heat up so allow it 180 seconds ; Fans M106 P1 T45 H1 ; Set hot end fan to thermostatic mode and turn on when temp greater than 45°C M106 P2 H100:101 T18:40 L0.6 B0.2 ; RGN - for electronics cooling fan https://www.duet3d.com/forum/thread.php?pid=21953#p21953 ; Tool definitions M563 P0 D0 H1 F0 ; Define tool 0 (P0) to use Extruder Drive (D0), Heater (H1) and Fan (F0) G10 P0 S0 R0 ; Set tool 0 operating and standby temperatures M92 E2612 ; Set extruder steps per mm ; Z probe and compensation definition M558 P5 R0.4 F1000 T8000 H3 ;Z-probe Smart Effector (H is Dive Height - it probes from here. Set high to test) G31 P100 X0 Y0 Z-0.1 ;Z-Probe Smart Effector Probe threshold settings ;*** If you are using axis compensation, put the figures in the following command M556 S78 X0 Y0 Z0 ; Axis compensation here M208 S1 Z-0.2 ; set minimum Z ; M912 P0 S-1.8 ; adjust internal temperature sensor that was over reading by 1.8°C https://duet3d.com/wiki/Calibrating_the_CPU_temperature T0 ; select first hot end M80 ; Turn on 24V & 12V PSU M307 H7 A-1 C-1 D-1 ; Set Heater 7 for PWM for LED driver. Use pin 16 on expansion header M42 P7 S35 ; Using heater 7 for PWM, set output at 25 / 255 (PWM value of 0 = LEDs off, 255 full on) M557 R185 S20 ; set the parameters for bed probing radius = 185mm, 20mm apart M376 H10 ; set bed compensation taper (H10 means taper over 10mm) M207 S0.8 F1500 T1500 Z0.5 ; Set FW retraction length and speed" 0.8 retract, 25mm/s, unretract 25mm/s, 0.5mm lift. M200 D1.75 ; set all extruder filament diameters to 1.75mm ; G29 S1 ; Load previously set bed map G28 ; home all M582 T2 ; if the jumper is on the layer fan connector on the Smart Effector then this will run sys/trigger2.g that contains the M665 setup for the e3D v6\. If not, the Volcano settings above will be used. M291 P"Run Delta configuration (G32)" R"Delta startup tasks" S1 T10 G32 ; do delta bed calibration ;M98 P/sys/delta_start.g
-
I don't expect M582 to work within config.g. Try putting it somewhere else, e.g. in your homing files, or start.g, or slicer start script.
-
Ah, thanks, that explains the behaviour I'm seeing.
That makes my idea a non-starter - I need it to run the M582 and want to run G232 as part of the start up routine so I can set up the correct Smart Effector. Doing both those every time I home the printer will become annoying. I'll continue to do it manually but am very glad I found out about this - I may be able to use M581 / M582 for other purposes.
Thanks.
Richard
-
I'll look at whether it makes sense to support M582 within config.g in a future firmware release.
-
Thanks, David, that would be great as I can imagine quite a few uses for this approach.
Richard
-
In the mean time, I have configured this to prompt me with a blocking message box as below. Posting this in the hope it will help others.
In my config.g I have the following statement as the last line. This waits for response from me on the PanelDue and the DWC:
[[language]] M291 P"Please run Delta Start macro to set correct Smart Effector and do delta configuration" R"Startup tasks" S1 T30
I have a macro that this prompts me to run:
[[language]] ; Delta_Start.g M400 ; wait for all moves to stop ; first set Volcano settings again (safer option) M665 R228 L440.375 B185 H410 ; (Volcano) set delta radius, diagonal rod length, printable radius and homed height ; Check for Smart Effector installed M582 T2 ; if the jumper is on the layer fan connector on the Smart Effector then this will run sys/trigger2.g that contains the M665 setup for the e3D v6\. If not, the Volcano settings above will be used. M400 ; wait for all moves to stop G32 ; do delta configuration
and then trigger2.g:
[[language]] ; trigger2.g M400 ; Wait for all moves to stop M291 P"v6 Smart Effector detected" R"Auto detect Smart Effector" S1 T10 M400 ; Wait for all moves to stop M665 R228 L440.375 B185 H420 ; (e3dv6) set delta radius, diagonal rod length, printable radius and homed height
This makes it very difficult for me to forget to run the delta configuration but auto-detects which Smart Effector I have installed and ensures that the delta configuration is run.
Richard
-
I have just checked the code and I can't see why M582 would not work from config.g. Are you certain that it doesn't?
-
Hi David. It does work, but after everything else has finished working - almost as if it is at a lower priority or something.
This is what I saw yesterday: "I'm setting the M665 for the taller Volcano in the config.g, and calling "M581 T2 E0 C0 S0" right near the beginning. A bit further down the config.g I run M582 T2, which, when triggered, should call trigger2.g. At the end of config.g I run a G28 and a G32 and these always run before the commands in trigger2.g
It appears that the trigger check waits until all other commands in config.g have run and then runs at the same time as
the WiFi initiates. The M291 in the trigger2.g file runs after the M291 in the config.g so this would tend to support the order I see."Is it perhaps that it calls trigger2.g but first completes running the commands in config.g?
Richard
-
Yes, it will wait until config.g has finished processing before the trigger function is called.
I do not advise putting G32, G29 without parameters, or any other commands that perform movement in config.g. Use those commands either in a macro that you run before printing, or in your slicer start script. Also it's generally better to heat up at least the bed before running those commands.
-
Thanks, David. In the arrangement I have now, the only movement command in config.g is G28. The others are all in the macros.
Understood on heating the bed first - I generally do G32 again after getting the bed and nozzle to temperature. The first G32 is only intended to make sure I at least do one before printing even if it is approximate - without it I used to forget and ended up carving notches in the print surface!
Richard
-
If you really want to run your trigger followed by G28 you could set up trigger 3 to do the G28, using a spare endstop input that is always high (e.g. on the expansion connector or on CONN_LCD). The triggers will be run in trigger number order.
As you only want to run each trigger macro once, for safety I suggest you end each macro with a M581 command to disable the trigger.
-
I'm missing something, David, I'm sorry but I don't understand.
At the moment I only run a blocking message and a G28 (last line) in the config.g. This is on a large delta and it homes to max Z. Do you recommend not putting the G28 in the config.g?
The hold message reminds me to run the delta_start macro that will call the trigger function. After reading your note above I will move the M581 command from the config.g to this macro so that it is only called when I run that macro. I will also use the S-1 notation to disable it afterwards.
Thanks for your help.
Richard
-
I was suggesting a way in which you can make your macro run automatically and defer the G28 until after the macro has run.
-
Oh, OK, thanks for clarifying.
I'm very happy with where this ended up - when the printer starts up it displays a message telling me to run the Delta_Start macro.
This sets the trigger (M581), checks which Smart Effector is installed, then homes the printer, runs delta config and then disables the trigger condition.
It works great and I won't get caught out with the Volcano installed and think I have the shorter v6!
Thanks for your help.
Richard