Duet3D Logo Duet3D
    • Tags
    • Documentation
    • Order
    • Register
    • Login

    Running macros in response to conditions?

    Scheduled Pinned Locked Moved
    General Discussion
    2
    25
    3.7k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RGN01undefined
      RGN01
      last edited by

      I should have said, the Duet is detecting the jumper - the LED lights so it doesn't appear to be a physical issue.

      Richard

      1 Reply Last reply Reply Quote 0
      • dc42undefined
        dc42 administrators
        last edited by

        You left out the S parameter.

        Duet WiFi hardware designer and firmware engineer
        Please do not ask me for Duet support via PM or email, use the forum
        http://www.escher3d.com, https://miscsolutions.wordpress.com

        1 Reply Last reply Reply Quote 0
        • RGN01undefined
          RGN01
          last edited by

          Thank you! That now works perfectly!

          Richard

          1 Reply Last reply Reply Quote 0
          • RGN01undefined
            RGN01
            last edited by

            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
            
            
            1 Reply Last reply Reply Quote 0
            • dc42undefined
              dc42 administrators
              last edited by

              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.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 0
              • RGN01undefined
                RGN01
                last edited by

                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

                1 Reply Last reply Reply Quote 0
                • dc42undefined
                  dc42 administrators
                  last edited by

                  I'll look at whether it makes sense to support M582 within config.g in a future firmware release.

                  Duet WiFi hardware designer and firmware engineer
                  Please do not ask me for Duet support via PM or email, use the forum
                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                  1 Reply Last reply Reply Quote 0
                  • RGN01undefined
                    RGN01
                    last edited by

                    Thanks, David, that would be great as I can imagine quite a few uses for this approach.

                    Richard

                    1 Reply Last reply Reply Quote 0
                    • RGN01undefined
                      RGN01
                      last edited by

                      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

                      1 Reply Last reply Reply Quote 0
                      • dc42undefined
                        dc42 administrators
                        last edited by

                        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?

                        Duet WiFi hardware designer and firmware engineer
                        Please do not ask me for Duet support via PM or email, use the forum
                        http://www.escher3d.com, https://miscsolutions.wordpress.com

                        1 Reply Last reply Reply Quote 0
                        • RGN01undefined
                          RGN01
                          last edited by

                          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

                          1 Reply Last reply Reply Quote 0
                          • dc42undefined
                            dc42 administrators
                            last edited by

                            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.

                            Duet WiFi hardware designer and firmware engineer
                            Please do not ask me for Duet support via PM or email, use the forum
                            http://www.escher3d.com, https://miscsolutions.wordpress.com

                            1 Reply Last reply Reply Quote 0
                            • RGN01undefined
                              RGN01
                              last edited by

                              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

                              1 Reply Last reply Reply Quote 0
                              • dc42undefined
                                dc42 administrators
                                last edited by

                                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.

                                Duet WiFi hardware designer and firmware engineer
                                Please do not ask me for Duet support via PM or email, use the forum
                                http://www.escher3d.com, https://miscsolutions.wordpress.com

                                1 Reply Last reply Reply Quote 0
                                • RGN01undefined
                                  RGN01
                                  last edited by

                                  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

                                  1 Reply Last reply Reply Quote 0
                                  • dc42undefined
                                    dc42 administrators
                                    last edited by

                                    I was suggesting a way in which you can make your macro run automatically and defer the G28 until after the macro has run.

                                    Duet WiFi hardware designer and firmware engineer
                                    Please do not ask me for Duet support via PM or email, use the forum
                                    http://www.escher3d.com, https://miscsolutions.wordpress.com

                                    1 Reply Last reply Reply Quote 0
                                    • RGN01undefined
                                      RGN01
                                      last edited by

                                      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

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post
                                      Unless otherwise noted, all forum content is licensed under CC-BY-SA