Add commands to lr3

I recently built a voron and have it has a pi and I use fluidd to control the printer. It has a way to edit a printer.cfg file where I you can create g code scripts. For things like nozzle cleaning or bed leveling. I was thinking it would be nice to have the same type of things in my lr3. I do some with the shortcut buttons in repieter host but it’s not quite the same and I want more commands than the 5 buttons available. Would I be able to add things like that I could type in as a single command in repieter host that would run the script? if I compiled source myself could I add this. or does it require adding a pi or additional hardware.

2 Likes

Here are three ways to approach your problem, and I’m sure there are more.

  1. If you have a Rambo board with a display or a SKR Pro with a display in Marlin mode, you can access the V1 custom menu. It is easy to modify and add as many items (with accompanying g-code) as you like. It does require you to compile and reflash Marlin.

  2. This idea is untested by me, but Marlin g-code supports ten macros…M810-M819. Marlin also has Autostart. Assuming you have an SD card reader on your setup, you could combine these two concepts and program ten macros, have the macros installed at startup, and be able to execute them by just typing their identifier in Repetier-Host (or other g-code sender).

  3. You can make a pendant. There are several designs floating around. The idea is to program a microcontroller (like an Arduino), to send g-code commands at the push of a button. Typically, commands are sent over a serial connection to the control board. This is my solution. I use a membrane switch keypad.

image

4 Likes

If you are running repetier hist, you can just have a library of common Gcode scripts and just run one for whatever you need.

For me, RepRap Firmware has a “macros” directory that becomes a menu to run repetitive tasks. I have macros set up to define the current tool position as 0, 0 for example, one to use the Z probe, and a few other tasks that I do often.

For Marlin based boards with an LCD, you can get to the “Custom” directory and edit that, but it does take a recompile of the firmware.

2 Likes

Currently using ESP3D on ESP32 module for Octopus. ESP3D’s macro support is part of the reason . Before that was using ESP3D on SKR Pro. Didn’t like ESP3D keyboard support at first, worked with ESP3D dev to improve (e.g. adding keyboard shortcut support for Macros), he’s receptive/responsive to pull requests.

Currently using Amzn fire with BL keyboard as a “Pendant” for keyboard shortcut jogging, and creating/initiating macros via UI and/or custom keyshortcuts.

Still using Marlin despite seeing lots of people using klipper on PIs for the kinematic support. I don’t understand how much value that adds for the CNCs we’re building that are snail paced compared to fancy 100mm/s+ printers. This lack of understanding is partly why I have an unpowered PI gathering dust in my LR3 case.

1 Like

Thanks for all the different ideas. It definitely helps knowing what all options there are.

Along with getting something to run these macros how do you store values in a macro and the display them after the macro is ran. For example I wanted to create a z axis tilt check and have it report the difference after the macro is ran. So how would you store the z height after it touches the touch plate for displaying that after it did both sides?

ESP3D has a “terminal” window that displays gcode for the macro being executed, and also and output returned back from Marlin. E.g. M114 to get machine position are output to the terminal window.

There’s no variable support as far as I know, so you can’t do calculations based off variables, or parse gcode output. Currently… I see how that could be implemented, e.g. maybe extend ESP3D to support Macros with JavaScript that lets you have State, Variables and Compute.

Maybe that’s not required though and there’s a simpler option using existing simple Macros that just playback gcode?

So it would require an external program to interact with the controller via g code and then do the math and display the values.

What’s involved with the “z axis tilt check”, can you get the info you want using a Macro that just replays gcode to blindly home Z, set z to 0, do some kind of touch probe? Or do you need more complex calculations done, and conditional execution of code?

If more complex solution(s) needed, then…

One option is to modify ESP3D to add things that helps support your scenario (and similar scenarios in the future).

Another option is to have external program that does what you want. If you have ESP3D, the external program could even be a webpage with JavaScript that does the calculations. That webpage could live on the memory card or firmware if small enough. For ESP01S on the SKR1.2 it would have to be relatively small, they have much less memory than ESP32 module used with Octopus. Alternatively, you could have Python/C/whatever run from a PC/Pi/SBC that calls ESP3D apis to send gcode and get output response too. The ESP3D Web UI internally uses websocket to a ESP3D ‘server’ that proxies requests/responses to and from Marlin. You could write code that uses the websocket to send/get stuff. Do you write code, would this be interesting/fun for you?

Also, Other gcode based processors have been mentioned on the forum that already have Macros with variable/state support, I forget which? They might be better match for what you’re wanting.

Yes, you need some sort of external program to do the calculation you outline. Marlin g-code (and all g-code I’m aware of), is very primitive from a programming standpoint. There is little in the way of variables, and no control structures. Very few of the g-code commands return data to the host/external program.

For your specific problem of “Z axis tilt check,” an external program can use M114 to query Marlin about the current position. That position will come back as a formatted string. In order to make your calculation, the external program would need to parse that string to individually pull out the XYZ coordinates, and then convert the text representation of the coordinates to floating-point numbers.

1 Like

I got an ESP so I could setup ESP3D and try this route. I think I could write a visual studio code that uses the esp3d’s web sockets as I have written code like that before. However I am intrigued by the JavaScript solution and was wondering if you could put me in the direction on an example code?

1 Like

Hello @Tna_331, sorry won’t be able to provide helpful info/details for a while. Currently packing and driving from WA to CO, current plan is to leave the house 12hrs ago.

In the meantime, have you already seen this topic? Would ESP3D’s existing Macros be enough to get started, or do you need to parse output and doing some compute on state that gets passed as tokens/parameters to the gcode? Vaguely recall there’s a gcode executor out there that already supports parameters, but no idea how much functional/declarative code can be shoved in. Hope that helps for now, cheers!

1 Like

To add custom G-code scripts or commands to Repetier-Host, you would not necessarily need to compile the source code yourself or add additional hardware like a Raspberry Pi. Repetier-Host provides a feature called “Custom Commands” that allows you to define and execute custom G-code scripts.

Here’s how you can add custom commands in Repetier-Host:

  1. Open Repetier-Host and connect it to your printer.
    
  2. Go to the "Manual Control" tab.
    
  3. Look for the "Custom Commands" section on the right-hand side of the interface.
    
  4. Click on the "Configure" button next to "Custom Commands.
    
1 Like