[SOLVED] Servo motor not rotating via UGS

Hello!

I'm making a pen plotter, I got everything working so far except the servo that's supposed to pull the pen up and down

When I write m03 s250 in UGS it mostly doesn't spin, yet when I tested the servo with just arduino uno and example code it worked perfectly.

One time it did spin after m03 s250, and UGS freaked out right after:

When I press the Z+ and Z- buttons, I hear a long high-pitched noise coming from the servo, the same one that the servo made when actually rotating with the example code

I'm using:
Arduino UNO
CNC shield
2x nema 17 stepper motors
2x ddrv2285 motor drivers
SG90 servo

The code is just grbl upload:


#include <grbl.h>

// Do not alter this file!

Here's the wiring:


(the colors for the servo wires are accurate, the rest isn't)
The motors work properly

I don't think there's anything that could be the problem except the Universal Gcode Sender program

Here are the firmware settings (the only thing I changed in the program):

I guess the fact that I had to lower the travel resolution so much is weird, too

I hope that I provided sufficient information!

Some versions of GRBL use a different pin arrangement. Make sure you have not been caught out by that. See both HERE and HERE If you could include your settings as a FILE (not a picture) they are easier to read. Also ensure you have set VREF correctly and installed the required jumpers for the drivers you are using.

1 Like

UGS will drive a servo? Did not know that.

1 Like

I cant upload the .settings file, so I changed it to .txt:
firmware_2025-05-10.txt (7.8 KB)

I think you can change it back to .settings on your pc and it will work

The pinout should be correct, I used this video for reference:

And it works fine for him

There are a couple of "FORKS" for UGS but I cannot for the life in me remember where they were. Only reason I know is that I used UGS when I first started out with GRBL
You may have to dig around a little to find them but the original UGS does not fully support servos.

That was a long long time ago and I moved onto lasergrbl as one of my main programs.
It was easier to control things and gave me a wider usage.
There are a few more options too as far as a "sender" program goes.
LaserGrbl does however support making your own macros which means you can use spare pins such as COOLANT etc to do things besides just switch on a relay.

I actually found transitioning to other programs quite easy once I got the hang of UGS.
Even have a machine using MACH3 thanks to learning UGS.

Plotting is a simple process that I got bored with quite quickly and moved into more eleborate things with a proper third axis. Once you get a spindle or laser your world will open up.

Will try find the links to the UGS fork but it was a few years ago.

1 Like


Well... It works, and, honestly, seems much better than ugs

However, how do I control the spindle? There isn't even a Z axis button

That's what it tells me twhen I press the laser button:

The servo doesn't spin when I send m03 s250 through serial monitor either:

I thought maybe that's because I need the servo library, but it sends an exit status 1 error

For Spindle you use the "S" command in your code the MAX / MIN "S" is defined in the grbl settings under $30 $31.
Leave MIN at zero and set MAX lets say to 180. Most servos only work through 180 degrees so you dont really need to go over that.
In case of a real spindle or laser it would probably be 100 or 1000 and you use that as a percentage figure.

No you dont need a servo library
Most servos dont need one for rudimentary functions.

RIGHT click on the toolbar section the click ADD BUTTON.
Set a two state button up and use this code for the first state.
G1 F100 M3 S180
Then this for the second state
G1 F100 M3 S0

Had occasion where LaserGrbl need to be restarted but mostly it works right away so click on your new button and see if that does anything.

Aoother method is to use a forked version of GRBL itself. That means uploading a different GRBL firmware but it is simple enough to do. With that you should be able to use the above button or GCODE in your program for sure.
There may be a newer version out there but that was just one of many ways around it.

Like all things Arduino/CNC there may still be some tinkering to do with the "$" settings to help speed things up. :wink:
Let me know if that helps.

1 Like

I installed grbl1.1h-servo, and it did work... then the whole thing dropped on the ground

The servo kinda works, the motors work for .5 secs and stop. My first assumption was that the drivers got fried(when the plotter fell down only the psu wires disconnected, everything else that's electrical stayed where it used to). But:


Here's what it says when I try to upload any code, even simply grbl.upload

Does that mean the uno is broken? Or maybe the CNC shield? I'll order a new one, but I don't know which is broken

...I went on walk, came back, and tried to test the plotter one last time... It fixed itself, somehow lmao

Praise be to the machine spirit, I guess, the motors work :slight_smile:

As for the servo through lasergrbl, it doesn't work reliably

Glad it seems to have fixed itself.
Went through a few driver boards myself in the early stages and now I have a surplus LOL.

I think you may have to revert to one of the other FORKED versions.
I know its a PITA but I ent through a lot of the same types of issue until I found something that worked. "GRBL with SERVO" will bring up a good selection of hits. Try to stay in GITHUB as I found they were the more reliable. My small laser is a bit of a frankenstien but everything is bolted to it so I dont have loose wires dangling around too much. Bit of plywood bolted to the side helps a lot and you can refine the layout as you develop.

1 Like

Thanks!

I tried running a program, and the board resets every time the servo rotates. That's with modified grbl. Its github page says that to fix this problem I can power the servo through and external psu. But how do I do it? Do I connect the ground wire to minus and 5v to plus? Internet says that I need to connect psu's ground(which apparently is minus) to arduino's ground, but then I can't connect servo's gnd anywhere🤔

I'm trying to power the servo with a phone charger

There are multiple grounds on the shield itself.
However ALL grounds should be commoned. (tied together) So you also need to split the ground from your phone charger and run one to the shield.

See also this topic. by my good friend Perry.

2 Likes

Good news: It worked! And the plotter now writes stuff!!!

Bad news: I still get random resets and sometimes the plotter starts going in a single direction

Now, for some reason, the servo started freaking out every time I power it
(UPDATE: Fixed the servo! One of the cogs jutt slipped off)

Here's what I'm getting from both programs:


Grbl doesn't always cancel the stream, sometimes it just stops working

I've no idea what could be the reason

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