CNC Shield + Servomotor using Z+

Hello Community,
I'm trying to connect a servomotor on Z+ pin of CNC Shield but is not working.
I'm very new with arduino/cnc and I don't know what I'm doing wrong. I tried to find the answer on internet but seems that everyone is using GRBL. I will have four stepper motors in my project (X will be duplicated)

This is my code:

#include<Servo.h>

const int StepX = 2;
const int DirX = 5;

const int StepY = 3;
const int DirY = 6;

const int StepZ = 4;
const int DirZ = 7;

const int speed= 1300;

int currentStepX =0;
int currentStepY =0;
int currentStepZ =0;

//servo settings 
Servo myservo;
const byte servoPin = 11; // Z+
byte pos = 0;


void setup() {
  Serial.begin(9600); // for monitor log.
    
  pinMode(StepX,OUTPUT);
  pinMode(DirX,OUTPUT);
  pinMode(StepY,OUTPUT);
  pinMode(DirY,OUTPUT);
 pinMode(StepZ,OUTPUT);
  pinMode( DirZ,OUTPUT);

 myservo.attach(11);


}


void loop() {
 myservo.write(0);
  delay(1000);

   myservo.write(180);
  delay(1000);
}

Thanks in advance,
Adrian

A RC-servo is not a stepper. You need +5V and GND, too. And make that delay(3000). ANd doublechack if your servo is on pin 11 or 7.

Thanks for your quick reply. Yes, I have +5V and GND from external power supply. I'm sorry that I didn't included it in my image. How can I check if servo is on pin 11 or 7? I used the same code in Arduino uno (without CNC) and servo is working as expected.

What's the pin schematics for the board? I don't have it available at the moment but other helpers have been posting it here in the past.

Yes but as @zwieblum has pointed out

The electronics in the CNC Shield are designed to drive stepping motors, so comes as no surprise that it can not drive servo.

I think that CNC shield should be able to drive also servo motors as we have multiple colleagues on this forum that are doing this, see:
CNC Shield V3 Servo Problem - Using Arduino / Motors, Mechanics, Power and CNC - Arduino Forum

Servo motor problem - Using Arduino / Motors, Mechanics, Power and CNC - Arduino Forum

DIY Pen Plotter with Automatic Tool Changer | Arduino based CNC Drawing Machine (youtube.com)

CNC Schema
cf988326f7e0baaa42da84e9b4440201e97f966a.jpeg (1500×1500) (discourse-cdn.com)

My electronic schema is

Thanks, I uploaded the CNC pin schema if you have time to take a look, I will appreciate

You have to connect servo GND and arduino GND

An absolute mess and not a schematic at all.

Hi @Grumpy_Mike , I made that schema in paint.. consider that C1-C4 modules are busy with steeper motors and I want to connect to Z+ the signal wire (in orange) for a servomotor. I have an external power supplier for + in red and - in brown. I also tried to use CNC shiet for + and - but still is not working. Please let me know if you have any doubts.

image

as written above: you must connect servo GND to arduino GND

1 Like

Thanks you all for your input. Seems that the problem is my power supplier which is too small...

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