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

    Running a macro on power-up and using wifi

    Scheduled Pinned Locked Moved
    Using Duet Controllers
    8
    10
    508
    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.
    • mrehorstdmdundefined
      mrehorstdmd
      last edited by

      I am trying to set up my sand table to run a macro when the table powers up, and I have that working by putting the macro call in the config.g file. The problem with that is the wifi doesn't work until the macro finishes running, which in this case takes several hours. Is there a way to enable wifi before the macro call, or is there a better place to put the macro call so that I will have immediate wifi access?

      https://drmrehorst.blogspot.com/

      chimaeraghundefined oliofundefined dc42undefined 3 Replies Last reply Reply Quote 0
      • chimaeraghundefined
        chimaeragh @mrehorstdmd
        last edited by

        @mrehorstdmd Is it possible to start the WiFi server in the macro? Possibly before any of your code runs?

        Duet 2 Wifi, Ooznest Workbee CNC 1510

        1 Reply Last reply Reply Quote 0
        • oliofundefined
          oliof @mrehorstdmd
          last edited by

          @mrehorstdmd mae sure M552 S1 is called before the macro is called and put a G4 S1 between the wifi enable and the macro call to ensure all is in order? That's what I'd try.

          <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

          mrehorstdmdundefined 1 Reply Last reply Reply Quote 0
          • mrehorstdmdundefined
            mrehorstdmd @oliof
            last edited by

            @oliof @chimaeragh There's an M552 S1 long before the macro call. I saw mention in the wiki page that the wifi module doesn't start until config.sys has ended, which in my case, isn't until after the several hours long macro file ends.

            Here's the entire config file. It's pretty simple since there are no fans, no heaters, and no z axis. Motors have integrated drivers so they are connected to an expansion board via step/dir/en lines:

            ; Configuration file for Duet WiFi (firmware version 3)
            ; executed by the firmware on start-up

            ; General preferences
            G90 ; send absolute coordinates...
            M550 P"Arrakis" ; set device name
            M669 K1 ; select CoreXY mode

            ; Network
            M551 P"dune" ; set password
            M552 S1 ; enable network
            M586 P0 S1 ; enable HTTP
            M586 P1 S0 ; disable FTP
            M586 P2 S0 ; disable Telnet

            ; Drives
            M569 P5 S1 R0 T4.0:5.0:6.0:12.0 ; drive 5 reverse, lo enable, timing parameters for servomotors
            M569 P6 S1 R0 T4.0:5.0:6.0:12.0 ; drive 6 reverse, lo enable, timing parameters for servomotors
            M584 X5 Y6 ; set drive mapping- X at drive 5, Y at drive 6
            M350 X1 Y1 ; configure microstepping without interpolation
            M92 X31.25 Y31.25 ; set steps per mm
            M566 X6000.00 Y6000.00 ; set maximum instantaneous speed changes (mm/min)
            M203 X96000.00 Y96000.00 ; set maximum speeds (mm/min)
            M201 X10000.00 Y10000.00 ; set accelerations (mm/s^2)
            M84 S3 ; Set idle timeout

            ; Axis Limits
            M208 X0 Y0 Z0 S1 ; set axis minima
            M208 X590 Y980 S0 ; set axis maxima

            ; Endstops
            M574 X2 S1 P"!xstop" ; configure active-high endstop for high end on X via pin xstop
            M574 Y1 S1 P"!ystop" ; configure active-high endstop for low end on Y via pin ystop

            ; macro to run at power up
            M98 P/macros/makerfaire2021

            As you can see from the macro name, there's a maker fair here this weekend, and I'm recovering from the flu, so I may not be able to be around to keep the table working, so I want it to be super easy to operate- power on, it runs the macro which calls a sequence of pattern files. The last pattern says "cycle power to restart", so it should be super easy for whoever is at the booth at the faire. There won't be any wifi available at the faire, so I can set it up for direct connection, but I'd rather not have to use networking at all.

            https://drmrehorst.blogspot.com/

            deckingmanundefined 1 Reply Last reply Reply Quote 0
            • deckingmanundefined
              deckingman @mrehorstdmd
              last edited by

              @mrehorstdmd Here is an idea until someone comes up with a better solution. Use an M581 trigger to invoke the macro. To make that happen automatically when power is applied, you need to sense the rising edge of a pin, so you need to have a delay circuit that will delay that rising edge for the period of time it takes for config.g to run. Probably the simplest way to do that without resorting to a soldering iron, is to buy a delay turn on/turn off relay module. So you apply power, the relay timer starts and config.g runs. After config.g completes, the relay timer reaches the set point so it energises the relay which in turn triggers the macro. Not very elegant but it might get you out of a hole......

              Ian
              https://somei3deas.wordpress.com/
              https://www.youtube.com/@deckingman

              1 Reply Last reply Reply Quote 0
              • gloomyandyundefined
                gloomyandy
                last edited by

                The WiFi module is not started until after config.g completes, so doing anything from there will be a problem. You could probably start your code from daemon.g and stop it from running again by setting (and testing) a global variable.

                1 Reply Last reply Reply Quote 2
                • JoergS5undefined
                  JoergS5
                  last edited by JoergS5

                  @mrehorstdmd said in Running a macro on power-up and using wifi:

                  M98 P/macros/makerfaire2021

                  Just an attempt is to set M98 R1 inside the macro, so the macro can be interrupted. https://duet3d.dozuki.com/Wiki/M98 If this is not sufficient, to interrupt and restart the macro could solve it.

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

                    @mrehorstdmd I can think of two ways that may work:

                    1. In config.g set up a trigger on an unused input pin and at the end of config.g use M582 to trigger it without needing a transition on the pin. The trigger will be set pending and the appropriate macro should be executed after config.g completes and WiFi is enabled.

                    2. Use the daemon.g file to perform the action and then go into a sleep loop.

                    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

                    mrehorstdmdundefined 1 Reply Last reply Reply Quote 0
                    • mrehorstdmdundefined
                      mrehorstdmd @dc42
                      last edited by

                      @dc42 Thanks. The table is at the Maker Faire now, but I'll try it when I bring it back home.

                      https://drmrehorst.blogspot.com/

                      o_lampeundefined 1 Reply Last reply Reply Quote 0
                      • o_lampeundefined
                        o_lampe @mrehorstdmd
                        last edited by

                        @mrehorstdmd
                        Get well soon!
                        I'd simply add the macro call to config-override. And put M501 in config.g as usual.

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