Wire Bender doesnt seem to see my steppers

Hi, this is my first post hope it is in the right place.

I built a wire bender based off of this website. DIY Arduino based 2D wire bending machine - Electric DIY Lab I am using a cnc shield so the pins werent correct in the original program. I added the proper lines according to chatgpt. I also added the enable pins as per chatgpt.

The terminal or whatever its called in Arduino shows that it has run the program but the motors never move. Any insight would be appreciated.

Hardware is as follows.

BSROBOTICS # UNO R3 Board ATmega328P with USB Cable(Arduino-Compatible) for Arduino, Input Voltage 7-12V, 16MHZ,14 Digital 1/0 pins Support PWM, SRAW 2KB, Compatible with RPi 4B/3B+/3B/2B/B+/Zero/Zero W

CNC Shield is HiLetgo 2pcs A4988 V3 Engraver Drive Shield 3D Printer CNC Drive Expansion Board for Arduino 3D Printer CNC

Not sure what stepper drivers I have they were parts I had laying around from other builds.

This is the code


#include <Arduino.h>
#include "BasicStepperDriver.h"


#define Feed_step 200
#define Bend_step 200
#define Feed_RPM 80
#define Bend_RPM 30


#define MICROSTEPS 16
#define FEEDSTEPS 8
int Delay = 50;

#define Feed_DIR   6   // Y‑DIR on shield
#define Feed_STEP  3   // Y‑STEP
#define Bend_DIR   5   // X‑DIR
#define Bend_STEP  2   // X‑STEP
#define ENABLE_PIN 8   // common EN on the shield


int val = 0;
int data = 0;
int a = 0;
int b = 0;
int c = 0;

BasicStepperDriver Feed_stepper(Feed_step, Feed_DIR, Feed_STEP, ENABLE_PIN);
BasicStepperDriver Bend_stepper(Bend_step, Bend_DIR, Bend_STEP, ENABLE_PIN);


void setup() {
  Serial.begin(9600);
    Feed_stepper.begin(Feed_RPM, MICROSTEPS);
    Bend_stepper.begin(Bend_RPM, MICROSTEPS);
    Feed_stepper.enable();      // keep the drivers enabled
    Bend_stepper.enable();
    Serial.println("For Triangle enter (1,Side Length) ");
    Serial.println("For Square enter (2,Side Length) ");
    Serial.println("For Rectangle enter (3,Height,Length) ");
    Serial.println( "For Hexagon enter (4,Side Length) ");
    Serial.println( "For Spring enter (5,Spring Length) ");
    Serial.println( "**Note Enter value without bracket ");
}

void loop() {
  if (Serial.available()>0){

a = Serial.parseInt();
b = Serial.parseInt();
c = Serial.parseInt();
  }


if (a == 1){
  Serial.println("  ");
  Serial.print("Making Triangle of side Length "); 
  Serial.print(b);
  Serial.println("mm");
for (int x=0; x<3; x++){
  Serial.println("..");
  Feed_stepper.move(FEEDSTEPS*b*MICROSTEPS);
  delay(Delay);
  Bend_stepper.rotate(95);  
  delay(Delay);
  Bend_stepper.rotate(-95);
  }
  Feed_stepper.move(FEEDSTEPS*15*MICROSTEPS);
  Serial.println("Finish ");
  a = 0;
  b = 0;
}


  
if (a == 2){
  Serial.println("  ");
  Serial.print("Making Square of side Length "); 
  Serial.print(b);
  Serial.println("mm");
for (int x=0; x<4; x++){
  Serial.println("..");
  Feed_stepper.move(FEEDSTEPS*b*MICROSTEPS);
  delay(Delay);
  Bend_stepper.rotate(75);  
  delay(Delay);
  Bend_stepper.rotate(-75);
  }
  Feed_stepper.move(FEEDSTEPS*15*MICROSTEPS);
  Serial.println("Finish ");
  a = 0;
  b = 0;
}


if (a == 3){
  Serial.println("  ");
  Serial.print("Making Rectangle of  Length & Height "); 
  Serial.print(b);
  Serial.print(" & ");
  Serial.print(c);
  Serial.println(" mm");
  Serial.println("..");
 for (int x=0; x<2; x++){ 
  Feed_stepper.move(FEEDSTEPS*b*MICROSTEPS);
  delay(Delay);
  Bend_stepper.rotate(75);  
  delay(Delay);
  Bend_stepper.rotate(-75);
  delay(Delay);
  Feed_stepper.move(FEEDSTEPS*c*MICROSTEPS);
  delay(Delay);
  Bend_stepper.rotate(75);  
  delay(Delay);
  Bend_stepper.rotate(-75);
 }
 Feed_stepper.move(FEEDSTEPS*15*MICROSTEPS);
  Serial.println("Finish ");
  a = 0;
  b = 0;
}


if (a == 4){
  Serial.println("  ");
  Serial.print("Making Hexagon of Side Length "); 
  Serial.print(b);
  Serial.println("mm");
for (int x=0; x<5; x++){
  Serial.println("..");
  Feed_stepper.move(FEEDSTEPS*b*MICROSTEPS);
  delay(Delay);
  Bend_stepper.rotate(70);  
  delay(Delay);
  Bend_stepper.rotate(-70);
  }
  Feed_stepper.move(FEEDSTEPS*15*MICROSTEPS);
  Serial.println("Finish ");

  a = 0;
  b = 0;
}



if (a == 5){
  Serial.println(" a==5 ");
  Serial.print("Making Spring of Length "); 
  Serial.print(b);
  Serial.println("mm");
for (int x=0; x<b*5; x++){
  Serial.println("..");
  Feed_stepper.move(360);
  delay(Delay);
  Bend_stepper.rotate(60);  
  delay(Delay);
  Bend_stepper.rotate(-60);
  }
  Feed_stepper.move(FEEDSTEPS*15*MICROSTEPS);
  Serial.println("Finish ");
  a = 0;
  b = 0;
}

}
    

Tell the Artificial Idiot that it has got it wrong and ask it to correct the code.

Honestly, if you didn’t come here to address the initial problem, you should go back to GPT to complete the request.

The initial problem has not changed this is the original code. The changed lines are at the bottom

[code]

#include <Arduino.h>
#include "BasicStepperDriver.h"

#define Feed_step 200
#define Bend_step 200
#define Feed_RPM 80
#define Bend_RPM 30

#define MICROSTEPS 16
#define FEEDSTEPS 8
int Delay = 50;

#define Feed_DIR 6 // Y‑DIR on shield
#define Feed_STEP 3 // Y‑STEP
#define Bend_DIR 5 // X‑DIR
#define Bend_STEP 2 // X‑STEP
#define ENABLE_PIN 8 // common EN on the shield

int val = 0;
int data = 0;
int a = 0;
int b = 0;
int c = 0;

BasicStepperDriver Feed_stepper(Feed_step, Feed_DIR, Feed_STEP, ENABLE_PIN);
BasicStepperDriver Bend_stepper(Bend_step, Bend_DIR, Bend_STEP, ENABLE_PIN);

void setup() {
Serial.begin(9600);
Feed_stepper.begin(Feed_RPM, MICROSTEPS);
Bend_stepper.begin(Bend_RPM, MICROSTEPS);
Feed_stepper.enable(); // keep the drivers enabled
Bend_stepper.enable();
Serial.println("For Triangle enter (1,Side Length) ");
Serial.println("For Square enter (2,Side Length) ");
Serial.println("For Rectangle enter (3,Height,Length) ");
Serial.println( "For Hexagon enter (4,Side Length) ");
Serial.println( "For Spring enter (5,Spring Length) ");
Serial.println( "**Note Enter value without bracket ");
}

void loop() {
if (Serial.available()>0){

a = Serial.parseInt();
b = Serial.parseInt();
c = Serial.parseInt();
}

if (a == 1){
Serial.println(" ");
Serial.print("Making Triangle of side Length ");
Serial.print(b);
Serial.println("mm");
for (int x=0; x<3; x++){
Serial.println("..");
Feed_stepper.move(FEEDSTEPSbMICROSTEPS);
delay(Delay);
Bend_stepper.rotate(95);
delay(Delay);
Bend_stepper.rotate(-95);
}
Feed_stepper.move(FEEDSTEPS15MICROSTEPS);
Serial.println("Finish ");
a = 0;
b = 0;
}

if (a == 2){
Serial.println(" ");
Serial.print("Making Square of side Length ");
Serial.print(b);
Serial.println("mm");
for (int x=0; x<4; x++){
Serial.println("..");
Feed_stepper.move(FEEDSTEPSbMICROSTEPS);
delay(Delay);
Bend_stepper.rotate(75);
delay(Delay);
Bend_stepper.rotate(-75);
}
Feed_stepper.move(FEEDSTEPS15MICROSTEPS);
Serial.println("Finish ");
a = 0;
b = 0;
}

if (a == 3){
Serial.println(" ");
Serial.print("Making Rectangle of Length & Height ");
Serial.print(b);
Serial.print(" & ");
Serial.print(c);
Serial.println(" mm");
Serial.println("..");
for (int x=0; x<2; x++){
Feed_stepper.move(FEEDSTEPSbMICROSTEPS);
delay(Delay);
Bend_stepper.rotate(75);
delay(Delay);
Bend_stepper.rotate(-75);
delay(Delay);
Feed_stepper.move(FEEDSTEPScMICROSTEPS);
delay(Delay);
Bend_stepper.rotate(75);
delay(Delay);
Bend_stepper.rotate(-75);
}
Feed_stepper.move(FEEDSTEPS15MICROSTEPS);
Serial.println("Finish ");
a = 0;
b = 0;
}

if (a == 4){
Serial.println(" ");
Serial.print("Making Hexagon of Side Length ");
Serial.print(b);
Serial.println("mm");
for (int x=0; x<5; x++){
Serial.println("..");
Feed_stepper.move(FEEDSTEPSbMICROSTEPS);
delay(Delay);
Bend_stepper.rotate(70);
delay(Delay);
Bend_stepper.rotate(-70);
}
Feed_stepper.move(FEEDSTEPS15MICROSTEPS);
Serial.println("Finish ");

a = 0;
b = 0;
}

if (a == 5){
Serial.println(" a==5 ");
Serial.print("Making Spring of Length ");
Serial.print(b);
Serial.println("mm");
for (int x=0; x<b5; x++){
Serial.println("..");
Feed_stepper.move(360);
delay(Delay);
Bend_stepper.rotate(60);
delay(Delay);
Bend_stepper.rotate(-60);
}
Feed_stepper.move(FEEDSTEPS
15*MICROSTEPS);
Serial.println("Finish ");
a = 0;
b = 0;
}

}

these lines are all that was changed

#define Feed_DIR 6 // Y‑DIR on shield
#define Feed_STEP 3 // Y‑STEP
#define Bend_DIR 5 // X‑DIR
#define Bend_STEP 2 // X‑STEP
#define ENABLE_PIN 8 // common EN on the shield

BasicStepperDriver Feed_stepper(Feed_step, Feed_DIR, Feed_STEP, ENABLE_PIN);
BasicStepperDriver Bend_stepper(Bend_step, Bend_DIR, Bend_STEP, ENABLE_PIN);

Whether you are using AI or the little grey cells, you need to walk before you can run.

Start off by connecting up one motor, and use a simple sketch to get it to run. You only need code to toggle the STEP pin (not too fast!). When you have one motor running, you now have a useful working reference, and it is easier to extend the code to multiple motors, and more complicated code.

It may be that the CNC shield or stepper driver is faulty, or wired incorrectly. If you post pictures of what schematic you followed, and what you are connections look like it would help.

2 Likes

I have a broken finger and cant really draw atm. I can get the steppers to move using ugs or cncjs just not from the program.

The problem is that the stepper library is not enabling the drivers. I added the two lines in setup();

  Feed_stepper.setEnableActiveState(LOW);
  Bend_stepper.setEnableActiveState(LOW);

Complete sketch

#include <Arduino.h>
#include "BasicStepperDriver.h"

#define Feed_step 200
#define Bend_step 200
#define Feed_RPM 80
#define Bend_RPM 30
#define MICROSTEPS 16
#define FEEDSTEPS 8

int Delay = 50;

#define Feed_DIR 6    // Y‑DIR on shield
#define Feed_STEP 3   // Y‑STEP
#define Bend_DIR 5    // X‑DIR
#define Bend_STEP 2   // X‑STEP
#define ENABLE_PIN 8  // common EN on the shield

int val = 0;
int data = 0;
int a = 0;
int b = 0;
int c = 0;

BasicStepperDriver Feed_stepper(Feed_step, Feed_DIR, Feed_STEP, ENABLE_PIN);
BasicStepperDriver Bend_stepper(Bend_step, Bend_DIR, Bend_STEP, ENABLE_PIN);

void setup()
{
  Serial.begin(9600);
  Feed_stepper.begin(Feed_RPM, MICROSTEPS);
  Bend_stepper.begin(Bend_RPM, MICROSTEPS);
  Feed_stepper.setEnableActiveState(LOW);
  Bend_stepper.setEnableActiveState(LOW);
  Feed_stepper.enable();  // keep the drivers enabled
  Bend_stepper.enable();
  Serial.println("For Triangle enter (1,Side Length) ");
  Serial.println("For Square enter (2,Side Length) ");
  Serial.println("For Rectangle enter (3,Height,Length) ");
  Serial.println("For Hexagon enter (4,Side Length) ");
  Serial.println("For Spring enter (5,Spring Length) ");
  Serial.println("**Note Enter value without bracket ");
}

void loop()
{
  if (Serial.available() > 0)
  {
    a = Serial.parseInt();
    b = Serial.parseInt();
    c = Serial.parseInt();
  }

  if (a == 1)
  {
    Serial.println("  ");
    Serial.print("Making Triangle of side Length ");
    Serial.print(b);
    Serial.println("mm");
    for (int x = 0; x < 3; x++)
    {
      Serial.println("..");
      Feed_stepper.move(FEEDSTEPS * b * MICROSTEPS);
      delay(Delay);
      Bend_stepper.rotate(95);
      delay(Delay);
      Bend_stepper.rotate(-95);
    }
    Feed_stepper.move(FEEDSTEPS * 15 * MICROSTEPS);
    Serial.println("Finish ");
    a = 0;
    b = 0;
  }

  if (a == 2)
  {
    Serial.println("  ");
    Serial.print("Making Square of side Length ");
    Serial.print(b);
    Serial.println("mm");
    for (int x = 0; x < 4; x++)
    {
      Serial.println("..");
      Feed_stepper.move(FEEDSTEPS * b * MICROSTEPS);
      delay(Delay);
      Bend_stepper.rotate(75);
      delay(Delay);
      Bend_stepper.rotate(-75);
    }
    Feed_stepper.move(FEEDSTEPS * 15 * MICROSTEPS);
    Serial.println("Finish ");
    a = 0;
    b = 0;
  }

  if (a == 3)
  {
    Serial.println("  ");
    Serial.print("Making Rectangle of  Length & Height ");
    Serial.print(b);
    Serial.print(" & ");
    Serial.print(c);
    Serial.println(" mm");
    Serial.println("..");
    for (int x = 0; x < 2; x++)
    {
      Feed_stepper.move(FEEDSTEPS * b * MICROSTEPS);
      delay(Delay);
      Bend_stepper.rotate(75);
      delay(Delay);
      Bend_stepper.rotate(-75);
      delay(Delay);
      Feed_stepper.move(FEEDSTEPS * c * MICROSTEPS);
      delay(Delay);
      Bend_stepper.rotate(75);
      delay(Delay);
      Bend_stepper.rotate(-75);
    }
    Feed_stepper.move(FEEDSTEPS * 15 * MICROSTEPS);
    Serial.println("Finish ");
    a = 0;
    b = 0;
  }

  if (a == 4)
  {
    Serial.println("  ");
    Serial.print("Making Hexagon of Side Length ");
    Serial.print(b);
    Serial.println("mm");
    for (int x = 0; x < 5; x++)
    {
      Serial.println("..");
      Feed_stepper.move(FEEDSTEPS * b * MICROSTEPS);
      delay(Delay);
      Bend_stepper.rotate(70);
      delay(Delay);
      Bend_stepper.rotate(-70);
    }
    Feed_stepper.move(FEEDSTEPS * 15 * MICROSTEPS);
    Serial.println("Finish ");

    a = 0;
    b = 0;
  }

  if (a == 5)
  {
    Serial.println(" a==5 ");
    Serial.print("Making Spring of Length ");
    Serial.print(b);
    Serial.println("mm");
    for (int x = 0; x < b * 5; x++)
    {
      Serial.println("..");
      Feed_stepper.move(360);
      delay(Delay);
      Bend_stepper.rotate(60);
      delay(Delay);
      Bend_stepper.rotate(-60);
    }
    Feed_stepper.move(FEEDSTEPS * 15 * MICROSTEPS);
    Serial.println("Finish ");
    a = 0;
    b = 0;
  }
}

I tested with CNC shield and it appears to work correctly.

I will try that. Thanks for the response it is greatly appreciated.

Very strange. Still nothing it seems odd that it will run the steppers with ugs or cncjs but not with the code. I really only built this because it seemed really straight forward. I am obviously not familiar with arduino. My other machines run Mach3

You could try putting a jumper on the EN/GND pins

Wrap your code in a code block.

Hi, @mangfu25

Then write some simple Arduino code that JUST makes one stepper turn.

Forget your main code and write things in stages, that way you will find where the bug is easier.

Tom.... :smiley: :+1: :coffee: :australia:
PS. Basic coding procedure, write your code in stages and get each stage to work, BEFORE, puting them together.

Does this mean you are loading grbl onto the Uno? And that grbl is currently working with those?

The result is the same with or without grbl

I will try that though I know nothing about arduino code

Not exactly sure what you are telling me to do, sorry.

I tried that but it didnt work. I will try to mark up a pic of how my cnc shield is wired if that would be helpful

Post #7 is the example of what I wrote. You did this to get an account.

I also added the jumper from the en to gnd as Bobcousins suggested

nm I see now.