Send Secondary Serial Command

Hi all,
I've been tasked with getting a laser "welder" up and running for a project. It's running on a custom firmware/software combination that has some pretty major issues. One of the things that it's supposed to do is send serial commands to a laser supply while also sending gcode commands to the printer. Here's an example from the gcode that we have as samples:

;(SYSTEM:echo 'LAS:OUTPUT 1' > /dev/ttyusb0)
G01 X25 Y30 F2000

Which would send a command over serial to /dev/ttyusb0 to turn on the laser, and then send G commands to the printer to do the movement. Is there any way to implement this into octoprint?

It sounds like there are two different serial ports, one for the laser and one for the printer, is this correct?

This OctoPrint plugin, https://github.com/kantlivelong/OctoPrint-GCodeSystemCommands, might work. The only concern would be the timing.

Yeah, that's correct. As it sits right now, the welder is on ACM0 and the laser is on USB0.
What would be the concern about the timing? Is there a significant latency with that plugin?

OctoPrint sends gcode commands to the printer firmware and that firmware usually buffers them while it turns them into steps for each motor. This buffering could cause timing issues because there's no direct link between the gcode commands and the laser commands.

For example, the sequence (assume the laser is off):
G0 X100 Y0, laser on, G1 X100 Y100, lazer off, G0 X105 Y0, lazer on, G1 X105 Y100, lazer off would draw (burn) two parallel lines only if the laser commands are executed after each gcode command is actually completed by the firmware (and before the next gcode command is started).

If the plugin I mentioned above is used, this sequence becomes (for example):
G0 X100 Y0, OCTO101*, G1 X100 Y100, OCTO100*, G0 X105 Y0, OCTO101, G1 X105 Y100, OCTO100 and now we are depending on the firmware to execute the OCTO commands after each gcode command is actually completed by the firmware.

  • I'm using two different OCTO commands but it could be one command with parameters.

So as you noted, the latency of the plugin needs to be determined. Either by experimentation, examination of the source code, or a discussion with the author.

You didn't mention any details about the firmware that drives the printer. If it is, for instance, Marlin, there is a Marlin gcode command, M400, which could help with the timing but again, determining how this changes the timing needs to be determined probably by experimentation. Again if the firmware is Marlin, M3, M4, and M5 are already defined for laser control. Whether or not that's relevant is for you to determine.

1 Like

I managed to get everything to work okay. I'm using M400 before/after I change command types, i.e.:
G28 X Y
M400
OCTO1
M400
G00 X25 Y25
This is a little clunky but it seems to be working. Since I'm not doing any pwm or anything with the laser it works well.
I am using Marlin on it. I'd looked at M3, M4, M5 but because I have to interface with the laser supply over serial I didn't see any good way to implement that without being over my head in the development process.

Hello b-morgan. I have a similar need. I want to control a Temperature-Humidity module through an additional serial port connected to the raspbedrry pi. I have checked the pluguin you recomend and it looks it might work for me. However I dont know how to implement the script that would do de job. I guess I should firsts stablish the connection and then send the command. Where can I find out how to implement it?

Thanks a lot in advance!

Javier

Your need is different than this one and should probably be in its own topic. In that topic, please give more details about this module, i.e. how does it actually connect to the RPi, where did it come from, etc.

1 Like