Skip to content

grblHAL/Plugin_SD_card

Repository files navigation

File system (SD card and littlefs) and related plugins

SD card

The SD card plugin adds a few $ commands for listing files and running G-code from a SD Card:

$FM

Mount card as the root (/) directory.

$F

List files on the card recursively. Only CNC related filetypes are listed: .nc, .ncc, .ngc, .cnc, .gcode, .txt, .text, .tap and .macro.

$F+

List all files on the card recursively regardless of filetype.

$F=<filename>

Run g-code in file. If the file ends with M2 or rewind mode is active then it will be "rewound" and a cycle start command will start it again.

$FR

Enable rewind mode for next file to be run.

$F<=<filename>

Dump file content to output stream.

$FD=<filename>

Delete file.

Dependencies:

FatFS library

NOTE: some drivers uses ports of FatFS provided by the MCU supplier.

YModem

Experimental ymodem upload support to SD card has been added as an option from build 20210422. Enable by setting SDCARD_ENABLE to 2 in my_machine.h.
This requires a compatible sender as the initial C used to start the transfer will not be sent by the controller. Transfer is initiated by the sender by sending the first packet.

littlefs

littlefs is a flash based file system that some drivers support. When available it will typically be enabled along the WebUI plugin and mounted in the /littlefs directory. It can be used for storing the WebUI application and its configurations, and may also be used to store G65 and tool change macros.

To write files to littlefs either use the WebUI maintenance page (forcefallback enabled) or ftp transfer.

Macros

The macros plugin is handling G65 calls by either redirecting the input stream to the file containing the macro or executing an inbuilt macro.

Syntax is G65P<n> where <n> is the macro number.
If <n> is >= 100 /littlefs/P<n>.macro, or /P<n>.macro if not present in littlefs, will be executed.
If <n> is < 100 it is considered to be an inbuilt macro of which a few are currently implemented.

Parameters can be passed to macros if expression support is enabled.

If the macro /littlefs/tc.macro or /tc.macro is present then the plugin will attach itself to the tool change HAL functions. tc.macro will then be called when a M6 command is executed.
If /littlefs/ts.macro or /ts.macro is also present it will be called when a T command is executed, this can be used to preposition a tool carousel or whatever else is needed to prepare for a tool change.

Similarly if /littlefs/ps.macro or /ps.macro is present it will be called when a M30 or a M60 (pallet shuttle) command is executed.

tc.macro and ts.macro can be used to add support for automatic tool changers (ATCs), this discussion contains examples and ideas for how to.


2024-09-25