Hi Troy, not sure how much detail you need, but I’ll provide what I can off the top of my head.
First, I must correct that I am using a Pro Micro instead of a Nano. The reason for this is that the Pro Micro has a hardware UART available for communicating with the control board, which made it easier for me for programming and prototyping. Note that there are still several things I would like to change in the programming of my gcode feeder, but it does work as of now.
Second, my sand table is running GRBL on an Uno with cnc shield. My method for feeding gcode from the pro micro to the controller will work with other setups, such as ramps/mega, as long as it has UART pins (most arduinos do, as far as I know).
The pro micro has an SD card board attached to it. It also has RX and TX connected to the controller board’s TX and RX. It also has a momentary push button and a toggle switch connected between pin 2 and ground - these are used to tell the machine to draw the next pattern. If the toggle switch is off, the machine stops after each file is drawn and waits until the button is pushed. If the toggle switch is turned on, the table will draw each design, one after the other.
The design files are stored in the root directory, and have numeric names (1.g, 2.g, 3.g, etc.). There is one other file, called home.g, which contains the gcode to home the machine. On startup, the gcode feeder runs home.g, then gets a count of how many files are on the card (minus the homing file). It then creates a random array of that many numbers. It checks to see if pin 2 is low (button pushed or toggle switch on), and when it is, it starts drawing the file that matches the first number in the random array. When the file is finished, the code again checks to see if pin 2 is low, and then either waits or immediately starts the next file in the array.
That’s about it. Future plans are to figure out how not to need the files to be named numerically (create a randomized array of the file names, or open files based on an index number, rather than file name). I would also like to be able to interrupt a drawing in progress and just start the next one. I welcome any tips from anyone with ideas on how to do those things.
The current version of the code is available here: https://github.com/karltinsly/gcode-feeder.
Let me know if I can provide any other details for you.