Running a macro on power-up and using wifi
-
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?
-
@mrehorstdmd Is it possible to start the WiFi server in the macro? Possibly before any of your code runs?
-
@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.
-
@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/makerfaire2021As 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.
-
@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......
-
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.
-
@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.
-
@mrehorstdmd I can think of two ways that may work:
-
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.
-
Use the daemon.g file to perform the action and then go into a sleep loop.
-
-
@dc42 Thanks. The table is at the Maker Faire now, but I'll try it when I bring it back home.
-
@mrehorstdmd
Get well soon!
I'd simply add the macro call to config-override. And put M501 in config.g as usual.