In the interest of minimizing effort (and the possibility of mistakes, bad wifi, etc.) when I’m displaying the Arrakis 2.0 at makerfaires, etc., I’ve been using a macro file that automatically runs a sequence of patterns without any user input, except the power switch. The macro ran the same sequence every time the machine was powered up because I specified pattern file names like this:
; file name: 215_patterns
M98 P"/gcodes/_wipe_4mm_lines_15.gcode" ; erase the table
M98 P"/gcodes/231204_01_6000_30000.gcode" ; draw a pattern
G04 S60 ; delay 60 seconds
M98 P"/gcodes/_wipe_LL_4mm_circle.gcode"
M98 P"/gcodes/231225_01_6000_30000.gcode"
G04 S60
M98 P"/gcodes/_wipe_L_4mm_circle.gcode"
M98 P"/gcodes/240427_01_6000_30000.gcode"
G04 S60
M98 P"/gcodes/_wipe_R_4mm_circle.gcode"
M98 P"/gcodes/091721_02_18000_60000.gcode"
G04 S60
I was recently made aware of some updates (made long ago!) to the firmware in the Duet2 WiFi controller board I used in Arrakis 2.0. The firmware includes conditional and looping constructs, and a random function using the CPU clock ticks as a seed. With some help from the RepRap Firmware author, I figured out how to run a random sequence that is different every time the machine is powered up.
I now store drawing pattern files in a folder on the uSD card on the Duet2 WiFi controller like this:
/gcodes/draw/0.gcode, /gcodes/draw/1.gcode, /gcodes/draw/2.gcode, … /gcodes/draw/224.gcode
and I store erase patterns in a separate folder like this:
/gcodes/wipe/0.gcode, /gcodes/wipe/1.gcode, /gcodes/wipe/2.gcode, … /gcodes/wipe/22.gcode
The random function, invoked like “random(225)”, returns a random integer between 0 and 225-1=224.
The new macro looks like this:
M98 P{“/gcodes/wipe/”^random(23)^“.gcode”}; erase the table
M98 P{“/gcodes/draw/”^random(225)^“.gcode”}; draw a pattern
G04 S60 ; delay 60 seconds
M98 P{“/gcodes/wipe/”^random(23)^“.gcode”}
M98 P{“/gcodes/draw/”^random(225)^“.gcode”}
G04 S60
etc.
The sequence of erase and drawing patterns is different every time the machine is powered on!
I haven’t put the statements into a loop yet because I can just copy and paste them a few times and end up with a sequence that will run for weeks without interruption. But, if I add or remove either wipe or drawing patterns, I’ll have to edit all those statements to account for the new file numbers, so I’m going to add a loop to generate a random number between 0 and 999 with a conditional test to see if the file exists. If not, try again, and if it does, use it to draw or erase the table. That way I’ll be able to add or remove pattern and wipe files without having to edit the macro at all.