Running macros in response to conditions?
-
I have two Smart Effectors, one with a standard E3D V6 and one with a Volcano because switching between them is so easy with the Smart Effector.
As they are different lengths, I need to set different heights and other parameters when I change them so was wondering - is there any way to have the Duet auto-detect which one is installed and run the appropriate macro at start up?
Without additional wiring and some way to add an identifier to each I can't think how this could be done but I'm asking anyway! The Duet ecosystem keeps surprising me so I'm hopeful!
Richard
-
See M581 and M582 in the GCode wiki page.
-
Really interesting, thank you David.
So I can use an unused endstop input to detect a condition. Now I must just figure out a way to automate the generation of the condition.
The kind of thing I was thinking about is a set of addressable jumpers on the Smart Effector, or a range of resistances between two pins. Set the two Smart Effectors up differently and the Duet would be able to detect which is installed. I'll give some thought to what I can add to the wiring to make this possible.
Thanks again.
Richard
-
I think I have a plan - and hope to test it over the weekend.
I am going to try a BerdAir type system for print cooling so won't need the print fan connector. I am therefore considering moving the wires to that to an unused endstop and then using a jumper on one Smart Effector to identify it in conjunction with the M581/M582 commands as David suggested above.
A quick look at the Smart Effector schematic seems to show this as viable - I'll re-check after my morning coffee kicks in!
Richard
-
David, could you please check my logic and understanding of this?
What I want to do is automatically identify which of two SmartEffectors I have installed at startup. To do this I want to configure things as follows. Does this sound right?
Configuration:
-
I am using a BerdAir type layer fan so have connected the fan out of the Duet to an external Mosfet and the layer fan connector on the Smart Effector does not have a fan on it
-
One of the two SmartEffector boards has a jumper on the layer fan pins
-
the layer fan cable is connected to endstop E0
-
the M581 command will be: M581 T0 E0 C0
-
the M582 command will be M582 T0
-
When M582 is called and it is triggered by the jumper on the layer fan pins it will call the macro sys/trigger0.g. If no jumper it will just return command
If I have all that correct, I put the M581 and M582 commands in the config.g file towards the end and it should work?
Thanks.
Richard
-
-
That sounds OK, except that triggers 0 and 1 have predefined meanings, so you will need to use trigger 2.
-
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.