Using a Servo HowTo

Hey all,

first things first: i love LB!
Currently I’m building a pen plotter machine that uses 2 steppers and a servo for pen lift. The machine is driven by a ESP32 running grbl. I want LB to lift the pen whenever a line was drawn and lower the pen when a new line is to be drawn. In the “move” panel, i can use the arrow controls to lift and lower the servo (although there’s a hefty delay of up to 5 seconds. why’s that btw?)

Now I’ve read all topics on the forums about servos but I’m still struggling to understand how i can get lightburn to lift and lower the pen properly. I read about tieing the servo to laser power but I don’t know how. In the screenshots in this thread theres even a max and min value for the laser power. In my LB the min value is greyed out. I can not make sense of all this yet. Can anybody point me the right direction or give me a small how to?

thanks in advance!

LightBurn isn’t made to issue commands to run a small servo for pen lifting, so anything you do will likely need to happen on the controller or firmware side. The EleksDraw machines use a version of GRBL that sends RC servo pulses instead of just a normal motor PWM output.

In that case, the Max Power value set in LightBurn controls the drop of the servo / pen, and 0 power is used to mean ‘fully raised’. This version of GRBL also has a slight delay when the power output value changes to allow the pen time to lower / lift. This is the approach I’d recommend, as it’s simplest on the LightBurn side.

The Min / Max power values in LightBurn are only available in GRBL for grayscale engraving. Otherwise the Min value is always 0.

@bogus - I assume you are using this version of GRBL https://github.com/bdring/Grbl_Esp32 ??
If so, that uses the Z axis and not spindle/laser PWM to control whether the pen servo is up or down. This is despite the fact that the PWM pin for the servo is the same as the PWM pin for spindle/laser control.
However, while LightBurn does have Z-axis control my understanding is that’s just for laser focus. I don’t believe there’s way to actually have Z move during a cut job. (@LightBurn can you confirm?)
What would need to happen is have the pen motion controlled by the spindle speed / laser power commands instead. Though, even if that’s possible, you’d have to make sure that GRBL is not in laser mode ($32=0) as laser mode assumes that spindle/power changes are instantaneous.
If you are using the GRBL port I mentioned above, I recommend checking out the GRBL_ESP32 slack channel and inquire there if it’s possible to set it up to use spindle/laser commands to handle pen lift… you can find that slack channel here: https://buildlog.slack.com/messages/CBXNG9YKS

In theory, if Grbl_ESP32 will not easily support S commands, you could probably post-process the output of LightBurn to replace S commands with Z movements with a simple script.

@LightBurn Is there a chance you guys can implement some kind of “servomode” in the future? I feel people would really love controlling a penplotter with LB.

@adammhaile exactly, I use bart drings GRBL port for ESP32. Works like a charm so far except with Lightburn. I’ll try the slack channel. If i get towards a solution, I’ll post it here.

@bogus - cool. Figured, since there’s only one I know of :wink:
Not really why Bart did it with the Z-axis… or at least only the Z axis.
I’m going to take a look at what code he added for that and see if I can make a modified version that uses the Sxxxx command to handle it. Will probably start with the ATMega328 grbl version first, since the code is a bit simpler. But I too am going to need pen functionality soon and I’d really prefer to use LightBurn.

Regarding “servomode” that’s really a firmware thing not a control thing. LightBurn is limited by the gcode commands it has available… what is done with those commands is up to the controller. Only thing I can imagine could be done is to allow controlling Z axis during a cut which would only make sense for this one case.

@adammhaile wow that would be awesome! Maybe it can then be transferred into grbl_esp32 if it’s not too much change from the original file. Maybe you can post your progress in this thread…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.