Arduino 3D Wire Bending Machine

In this tutorial  I will show you how I built an Arduino based 3D wire bending machine. This is actually a typical mechatronic system because it involves mechanical, electrical and computer engineering. So therefore I believe many engineering students or anyone who is new into mechatronics found this project interesting.

Overview


Here’s the working principle of this 3D wire bending machine. So first, the wire goes through a series rollers, or straighteners. Using a stepper motor the wire is precisely fed to the wire bending mechanism which also uses a stepper motor as well as a small servo for the bending process.

Arduino 3D Wire Bending Machine Working Principle.jpgThere’s also another stepper motor, called the Z-axis, which actually enables the machine to create three dimensional forms. Of course, the brain of the machine is an Arduino board which along with the other electronics components is attached on a custom designed PCB.

Star shape - DIY Wire bending machine

As for the program, I made few custom functions for making various shapes, like a star, a cube and a simple stand, as well as a manual mode where we can make the wire forms by entering commands through the serial monitor.

DIY 3D Wire Bending Machine 3D Model

As usual, I started by making the project using a 3D modeling software. You can download and the 3D model below.

Wire Bending Machine 3D Model

Design inspiration: YouTube video

Solidworks:

STEP file:

STL files for 3D Printing:

For some of the parts, like the gears, the bearing pillow blocks and some shaft couplers I used a 3D printer to make them. The STL files of these parts, which are used for 3D printing, can be downloaded from the files above.

My new 3D printer, Creality CR-10, did a great job and printed the parts with great quality. Here’s a link to this 3D printer in case you want to check it out.

3D printed bearing pillow block

Building the Wire Bending Machine

I continued with preparing the other parts, for which I used MDF and plywood. So once I took all dimensions from the 3D model, using a circular saw, I cut the pieces to size. I used 8 mm tick MDF and 18 mm tick plywood. Once I got them ready I started with the assembly. First I made the base out of two MDF plates and 4 plywood columns. For securing them I used a wood glue and some screws.

Making the base out of MDF and plywood

Next on the top panel I attached the 3D printed bearing pillow blocks using some 8 mm bolts and nuts. We can notice here that I added 3 mm tick MDF plates between the top and the pillow blocks so that I get the proper height. Now in these blocks we can fit the 6202 bearings.

inserting the shaft through the bearings

Their outer diameter is 35 mm and the inner diameter is 15 mm. So now, through these bearings, we need to insert a 15 mm hollow shaft so that the wire could pass through it. This shaft is actually the Z-axis, which enables to bending mechanism to rotate around the wire and in that way make three dimensional forms. I used a copper tube for that purpose and its length needs to be around 30 cm.

In between the two bearings I also inserted a 3D printed gear with module of 1.5 and 30 teeth. The gear has custom design slots where we can insert M3 nuts and then using M3 bolts we can tighten the gear to the shaft.

3D printed gear with integrated slots for shaft fastening

Next we need install the Z-axis stepper motor. For that purpose I 3D printed a custom mounting bracket. So I secured the stepper to the bracket using M3 bolts, and then inserted the 18 teeth gear on the motors shaft. I used the same method for securing the gear to the shaft as shown earlier.

3d printed gear with shaft clamp for NEMA 17 stepper motor

Then using a 6 mm drill I made two holes on the top on which the mounting bracket will be secured. We can notice that the bracket instead of holes, has slots which enables the two gears to be properly paired.

pairing 3d printed gears

I moved on with installing the stepper motor for the feeder mechanism. This motor will be directly mounted on the top plate, so I drilled the appropriate holes on it. Then using four bolts I secured the stepper to the plate, and in case you wonder what those nuts do here, they actually act as distance nuts because the bolts I had were longer and couldn’t fit into the motors threads.

securing the feeder motor

So now on the shaft of this stepper we need to insert the feeder. For that purpose I 3D printed a custom shaft coupler on which I inserted a copper tube which will actually be the contact surface of the feeder.

Then on the opposite side of the motor I inserted a lever, on which I attached a bearing which will press against the feeder. For getting enough grip so the feeder could move the wire, I will attach a piece of plywood with a T-nut on it, and then using a bolt we will be able control the grip of the feeder.

The next step is making the wire straightening system. Using three M8 bolts I secured a piece of plywood that I previously drilled according to the 3D model. Now on top of it I inserted the rollers. I made the rollers out of bearings and 3D printed grooved outer rings.

Three rollers go on this side, and two rollers on the other side. For the other side I made a slot in the plywood piece so that the bolts stay flush with the piece. Now using just two bolts we can pair the two side, and using the nuts we can tighten the straighteners appropriately.

Once finished with this step, I added two more pieces of plywood in front and after the straighteners which will serve as wire guides.

Ok, so now we can move on with making the wire bending mechanism. First on a piece of MDF we need to attach the bender motor.  Before I did that, the MDF piece that I had needed some shaping, so using a handsaw, a coping saw and a rasp I easily got the desired shape. Then using a 38 mm hole saw I made an opening for the bigger stepper that we will use for the bending, a NEMA 23 stepper motor. Also I drilled some smaller holes needed for attaching the other parts.

I secured the NEMA 23 stepper using M4 bolts and nuts and on its output shaft I attached a gear with module of 2.5 and 18 teeth. This gear will be paired with bigger 30 teeth gear which is a custom designed gear with integrated plate for mounting a MG996R servo. This servo will move a rack and pinion mechanism, which is actually a pin which will pop out of the gear and it will serve for bending the wire. Using a 5 minutes epoxy I secured a bearing onto the gear and also added a piece of copper tube onto the rack which will be the contact surface when bending the wire.

After the epoxy dried out, I paired the two gears by securing the bigger gear in place with a M8 bolt and a nuts. Then I inserted the rack and the servo in placed, and secured it using the screws provided in the servos package. Then I secured the pinion gear onto the round horn of the servo using two M3 bolts and nuts.

3d printed gear for servo motor rack and pinion mechanism

Finally I attached the horn to the servo and with this the bending mechanism was completed.

3d printed servo motor rack and pinion mechanism

What’s left to do now is to attach the bender to the Z-axis. I did that using the two 3D printed shaft clamps. First I secured them to the bender plate using M6 bolts and nuts, and then inserted them into the Z-axis. I inserted the two nuts in place, and using the bolts I tightened the clamps to the shaft. So now all moving parts are working properly.

3d printed shaft clamps supports

Actually there are two more small details to be added. That’s this 3 mm nozzle on the shaft where the wire comes out.

nozzle for the wire

And at the bottom of bender I placed a micro limit switch which will be used for setting initial position of the bender.

mirco limit switch for the bender initial position

And that’s it, our 3D wire bending machine is almost done. I say almost, because now we need to give live to this machine, or connect the electronics components and program it.

Circuit Diagram

Here’s the circuit diagram of this project.

Arduino 3D Wire Bending Machine Circuit Diagram

So the three stepper motors are controlled using the three DRV8825 stepper drivers. For powering the steppers and the whole project we will use 12V power supply with at least 3A of current rate.

For powering the servo, we could use the 5V coming from the Arduino, but the MG996R servo can be power hungry and the 5V voltage regulator of the Arduino might not be able to handle it. Therefore, I decided to use a separate 5V voltage regulator, the LM7805, which is good enough to power the servo for this project. There is also a limit switch for the bender which has a pull up resistor it’s connected to a digital pin of the Arduino board.

You can get the components needed for this project from the links below:

*Please note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

PCB Design

Next, in order to get rid of wiring mess and keep the electronics components organize I designed a custom PCB using the EasyEDA free online circuit design software. The circuit has many connection, so I used both the top and the bottom layers to organize them. I also added pins for selecting the steppers resolution, added one more limit switch connection and provided additional digital and analog pins coming from the Arduino in case we need them for something.

Here’s a link to the project files of this PCB design. So once finished with this design I generated the Gerber file needed for manufacturing the PCB.

Gerber file:

Then I ordered the PCB from JLCPCB, which is actually the sponsor of this project.

Here we can simply drag and drop the Gerber file and once uploaded, we can review our PCB in the Gerber viewer. If everything is all right then we can go on, select the properties that we want for our PCB, and then we can order our PCB at a reasonable price. Note that if it’s your first order from JLCPCB, you can get up to 10 PCBs for only $2.

custom pcb design order from JLCPCB

After several days the PCBs have arrived. The quality of the PCBs is great and everything is exactly the same as in the design.

pcb for arduino 3d wire bending machine project

So now we can move on and install the electronics components onto the PCB.  I started by soldering pin headers to the PCB. This enables easier connecting and disconnecting of the components when needed. As for the smaller components, like the capacitors, the resistors, the voltage regulator and the terminal blocks I soldered them directly onto the PCB.

Arduino and DRV8822 Circuit PCB for 3D Wire Bending Machine

Once finished with this step, now we can insert the stepper drivers and the Arduino in place. Then we need connect the power plug and the power switch to the terminal blocks, connect the cables to the stepper motors on one side and connect them to the PCB on the other side. The servo is connected to digital pin number 2 and powered with the 5V coming from the LM7805 voltage regulator. Finally we can select stepper resolution by connecting the resolution pins below the drivers.

DRV8825 stepping resolution selection

I decided to use 16th step resolution so we need to connect the right pins instead of the middle ones as seen on the photo above. So the electronic components are now ready and we can move on with programming the wire bending machine.

Arduino Code for 3D Wire Bending Machine Project

As the code is a bit longer, for better understanding, I will post the source code of the program in sections with description for each section. And at the end of this article I will post the complete source code.

For controlling the stepper motors I will use the AccelStepper library by Mike McCauley. So we need to include this library, as well as the servo library for controlling the servo motor.  Then we need to define the pins to which the steppers are connected and some variables needed for the program below.

#include <AccelStepper.h>
#include <Servo.h>

#define limitSwitch 11

// Define the stepper motors and the pins the will use
AccelStepper feederStepper(1, 5, 6); // (Type:driver, STEP, DIR)
AccelStepper zAxisStepper(1, 7, 8);
AccelStepper benderStepper(1, 9, 10);

Servo servo01;
String dataIn = "";
String manualStatus = "";
int count = 0;
int dist;

In the setup section we set the initial position of the servo or the bending pin, and also set the initial position of the bender gear. This is done with the help of the limit switch. The stepper rotates toward the switch and once it’s pressed the motor starts counting the steps from zero and position itself to zero degrees, ready for bending.

void setup() {
  Serial.begin(9600);
  pinMode(limitSwitch, INPUT_PULLUP);
  servo01.attach(2);
  servo01.write(40); // Initial position, bending pin up
  // Stepper motors max speed
  feederStepper.setMaxSpeed(2000);
  zAxisStepper.setMaxSpeed(2000);
  benderStepper.setMaxSpeed(2000);
  // Homing
  while (digitalRead(limitSwitch) != 0) {
    benderStepper.setSpeed(1200);
    benderStepper.runSpeed();
    benderStepper.setCurrentPosition(0); // When limit switch pressed set position to 0 steps
  }
  delay(40);
  // Move 1400 steps from the limit switch to starting position
  while (benderStepper.currentPosition() != -1400) {
    benderStepper.setSpeed(-1200); // if negative rotates anti-clockwise
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
}

Now in the loop section, we wait for commands coming from the serial monitor. If we type manual, we will enter the manual bending mode or if we type for example star, the start() custom function will be executed and the machine will automatic make a star form for us.

void loop() {
  String mode = Serial.readString();
  if (mode.startsWith("manual")) {
    manual();
  }
  if (mode.startsWith("star")) {
    star();
  }
  if (mode.startsWith("cube")) {
    cube();
  }
  if (mode.startsWith("stand")) {
    stand();
  }
}

Let’s take a look at this custom function.

void star() {
  while (count != 5) {
    int feed = 38; //  mm
    int feedDistance = feed * 48; // 48- constats that map the mm value to number of steps the stepper show move
    while (feederStepper.currentPosition() != feedDistance) { // run until it reaches the distance value
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0); // reset the current position to 0
    servo01.write(40); // Set the bender pin up
    delay(200);
    int angleConst = 18; // angle constant
    // Bend the wire 52 degrees
    while (benderStepper.currentPosition() != -52 * angleConst) {
      benderStepper.setSpeed(-700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    // Go back 52 degrees to initial position
    while (benderStepper.currentPosition() != 52 * angleConst) {
      benderStepper.setSpeed(1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    // Feed the same distance again
    while (feederStepper.currentPosition() != feedDistance) {
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0);
    delay(100);
    servo01.write(130); // Set the bender pin down
    delay(200);
    // Set bender to new initial position, for bending in the other direction
    while (benderStepper.currentPosition() != -42 * angleConst) {
      benderStepper.setSpeed(-1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(200);
    servo01.write(40); // Bender pin up
    delay(200);
    while (benderStepper.currentPosition() != 105 * angleConst) {
      benderStepper.setSpeed(700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(50);
    while (benderStepper.currentPosition() != -63 * angleConst) {
      benderStepper.setSpeed(-1200);
      benderStepper.run();
    }
    delay(100);
    servo01.write(130);
    benderStepper.setCurrentPosition(0);
    count++;
  }
}

So here we enter a while loop which is executed 5 times, because obviously the star has 5 points. We start by setting the feed value, or that’s how much wire will be feed in millimeters. This value is then multiplied by 48 which translates feed value into appropriate steps for the stepper motor to move. Then using the run() function, we rotate the feeder motor with a speed set by the setSpeed() function. We stops when the above feedDistance value is reached, and right after that we set the current position value of the stepper zero.

int feed = 38; //  mm
    int feedDistance = feed * 48; // 48- constats that map the mm value to number of steps the stepper show move
    while (feederStepper.currentPosition() != feedDistance) { // run until it reaches the distance value
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0); // reset the current position to 0

In the next step we bend the wire 52 degrees. This is done in similar way as explained above. Here we also have an angle constant which is multiplied with the desired angle. Once that value is reached by the motor, the motor stops, reset its current position to 0, and then runs the same number of steps in the opposite direction which actually returns the motor to its initial position.

// Bend the wire 52 degrees
    while (benderStepper.currentPosition() != -52 * angleConst) {
      benderStepper.setSpeed(-700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    // Go back 52 degrees to initial position
    while (benderStepper.currentPosition() != 52 * angleConst) {
      benderStepper.setSpeed(1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);

Then again we feed the same length of wire and we set the pin down so that the bender can move to a new initial position which is used for bending in the other direction. The bender pin is then raised, and so we bend the wire 105 degrees in the opposite direction. The commands are repeated 5 times and that’s how we get the star form.

In similar way as explained above we make the cube shape or actually any other shape we can come up with. As for the manual mode, the working principle of the commands are the same, except that we have few more lines for reading the commands coming from the serial monitor. For example for feeding the wire, we need to type “f”, plus the distance in millimeters, for bending the wire, we need to type “b”, plus the angle in degrees, and for rotating the Z-axis, we need to type “z”, plus the angle in degrees.

if (dataIn.startsWith("f")) {
      dataInS = dataIn.substring(1, dataIn.length()); // reads the feed value
      dist = dataInS.toInt();
      Serial.print("Feed ");
      Serial.print(dist);
      Serial.println("mm wire.");
      dist = dist * 48;
      while (feederStepper.currentPosition() != dist) {
        feederStepper.setSpeed(1200);
        feederStepper.run();
      }
      feederStepper.setCurrentPosition(0);
      delay(100);
    }

So that’s how the program that I made works, but of course, there are many other ways this to be coded. Here’s the complete Arduino code for this 3D Wire Bending Machine:

/*
  Arduino 3D Wire Bending Machine
  by Dejan Nedelkovski
  www.HowToMechatronics.com
  Library - AccelStepper by Mike McCauley:
  http://www.airspayce.com/mikem/arduino/AccelStepper/index.html
*/

#include <AccelStepper.h>
#include <Servo.h>

#define limitSwitch 11

// Define the stepper motors and the pins the will use
AccelStepper feederStepper(1, 5, 6); // (Type:driver, STEP, DIR)
AccelStepper zAxisStepper(1, 7, 8);
AccelStepper benderStepper(1, 9, 10);

Servo servo01;
String dataIn = "";
String manualStatus = "";
int count = 0;
int dist;

void setup() {
  Serial.begin(9600);
  pinMode(limitSwitch, INPUT_PULLUP);
  servo01.attach(2);
  servo01.write(40); // Initial position, bending pin up
  // Stepper motors max speed
  feederStepper.setMaxSpeed(2000);
  zAxisStepper.setMaxSpeed(2000);
  benderStepper.setMaxSpeed(2000);
  // Homing
  while (digitalRead(limitSwitch) != 0) {
    benderStepper.setSpeed(1200);
    benderStepper.runSpeed();
    benderStepper.setCurrentPosition(0); // When limit switch pressed set position to 0 steps
  }
  delay(40);
  // Move 1400 steps from the limit switch to starting position
  while (benderStepper.currentPosition() != -1400) {
    benderStepper.setSpeed(-1200); // if negative rotates anti-clockwise
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
}

void loop() {
  String mode = Serial.readString();
  if (mode.startsWith("manual")) {
    manual();
  }
  if (mode.startsWith("star")) {
    star();
  }
  if (mode.startsWith("cube")) {
    cube();
  }
  if (mode.startsWith("stand")) {
    stand();
  }
}
void star() {
  while (count != 5) {
    int feed = 38; //  mm
    int feedDistance = feed * 48; // 48- constats that map the mm value to number of steps the stepper show move
    while (feederStepper.currentPosition() != feedDistance) { // run until it reaches the distance value
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0); // reset the current position to 0
    servo01.write(40); // Set the bender pin up
    delay(200);
    int angleConst = 18; // angle constant
    // Bend the wire 52 degrees
    while (benderStepper.currentPosition() != -52 * angleConst) {
      benderStepper.setSpeed(-700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    // Go back 52 degrees to initial position
    while (benderStepper.currentPosition() != 52 * angleConst) {
      benderStepper.setSpeed(1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    // Feed the same distance again
    while (feederStepper.currentPosition() != feedDistance) {
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0);
    delay(100);
    servo01.write(130); // Set the bender pin down
    delay(200);
    // Set bender to new initial position, for bending in the other direction
    while (benderStepper.currentPosition() != -42 * angleConst) {
      benderStepper.setSpeed(-1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(200);
    servo01.write(40); // Bender pin up
    delay(200);
    while (benderStepper.currentPosition() != 105 * angleConst) {
      benderStepper.setSpeed(700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(50);
    while (benderStepper.currentPosition() != -63 * angleConst) {
      benderStepper.setSpeed(-1200);
      benderStepper.run();
    }
    delay(100);
    servo01.write(130);
    benderStepper.setCurrentPosition(0);
    count++;
  }
}

void cube() {
  int feed = 40; //  mm
  int feedDistance = feed * 48;
  int angleConst = 16;
  // Step 1
  while (count != 3) {
    while (feederStepper.currentPosition() != feedDistance) {
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != -90 * angleConst) {
      benderStepper.setSpeed(-700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != 90 * angleConst) {
      benderStepper.setSpeed(1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    count++;
  }
  count = 0;
  // Step 2
  while (zAxisStepper.currentPosition() != 88 * angleConst) {
    zAxisStepper.setSpeed(500);
    zAxisStepper.run();
  }
  zAxisStepper.setCurrentPosition(0);
  delay(100);
  //Step 3
  while (count != 2) {
    while (feederStepper.currentPosition() != feedDistance) {
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != -90 * angleConst) {
      benderStepper.setSpeed(-700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != 90 * angleConst) {
      benderStepper.setSpeed(1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    count++;
  }
  count = 0;
  // Step 4
  while (zAxisStepper.currentPosition() != 85 * angleConst) {
    zAxisStepper.setSpeed(500);
    zAxisStepper.run();
  }
  zAxisStepper.setCurrentPosition(0);
  delay(100);
  // Step 5
  servo01.write(130);
  delay(200);
  while (benderStepper.currentPosition() != -42 * angleConst) {
    benderStepper.setSpeed(-1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  while (count != 3) {
    delay(100);
    servo01.write(40);
    delay(200);
    // Step 6
    while (feederStepper.currentPosition() != feedDistance) {
      feederStepper.setSpeed(1200);
      feederStepper.run();
    }
    feederStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != 90 * angleConst) {
      benderStepper.setSpeed(700);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    while (benderStepper.currentPosition() != -90 * angleConst) {
      benderStepper.setSpeed(-1200);
      benderStepper.run();
    }
    benderStepper.setCurrentPosition(0);
    delay(100);
    count++;
  }
  count = 0;
}

void stand() {
  int feed = 20; // mm
  int feedDistance = feed * 48;
  int angleConst = 16;
  // Step 1
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != -90 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 90 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);

  // Step 2
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != -70 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 70 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);

  // Step 3
  feed = 80; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  delay(100);
  // Step 4
  servo01.write(130);
  delay(200);
  while (benderStepper.currentPosition() != -42 * angleConst) {
    benderStepper.setSpeed(-1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  servo01.write(40);
  delay(200);
  while (benderStepper.currentPosition() != 108 * angleConst) {
    benderStepper.setSpeed(700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != -66 * angleConst) {
    benderStepper.setSpeed(-1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);

  //Step 5
  servo01.write(130);
  delay(200);
  // Step 6
  feed = 80; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  servo01.write(40);
  delay(200);
  // Step 7
  while (zAxisStepper.currentPosition() != -90 * angleConst) {
    zAxisStepper.setSpeed(-500);
    zAxisStepper.run();
  }
  zAxisStepper.setCurrentPosition(0);
  delay(100);

  // Step 8
  while (benderStepper.currentPosition() != -90 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 90 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  // Step 6
  feed = 45; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  // Step 10
  while (benderStepper.currentPosition() != -90 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 48 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);

  // Step 11
  while (zAxisStepper.currentPosition() != 90 * angleConst) {
    zAxisStepper.setSpeed(500);
    zAxisStepper.run();
  }
  zAxisStepper.setCurrentPosition(0);
  delay(100);
  feed = 80; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);

  // Step 12
  while (benderStepper.currentPosition() != 110 * angleConst) {
    benderStepper.setSpeed(700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != -68 * angleConst) {
    benderStepper.setSpeed(-1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  //Step 13
  servo01.write(130);
  delay(200);
  feed = 80; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  servo01.write(40);
  delay(200);

  // Step 14
  while (benderStepper.currentPosition() != -70 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 70 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);

  //Step 15
  feed = 25; // mm
  feedDistance = feed * 48;
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
  delay(100);
  // Step 16
  while (benderStepper.currentPosition() != -90 * angleConst) {
    benderStepper.setSpeed(-700);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);
  while (benderStepper.currentPosition() != 90 * angleConst) {
    benderStepper.setSpeed(1200);
    benderStepper.run();
  }
  benderStepper.setCurrentPosition(0);
  delay(100);

  // Step 17
  while (feederStepper.currentPosition() != feedDistance) {
    feederStepper.setSpeed(1200);
    feederStepper.run();
  }
  feederStepper.setCurrentPosition(0);
}

void manual() {
  int sign;
  String dataInS;
  int angle;
  int angleConst;
  Serial.println("  // MANUAL MODE //");
  while (!dataIn.startsWith("end")) {
    servo01.write(130);
    delay(200);
    dataIn = Serial.readString();
    if (dataIn.startsWith("f")) {
      dataInS = dataIn.substring(1, dataIn.length()); // reads the feed value
      dist = dataInS.toInt();
      Serial.print("Feed ");
      Serial.print(dist);
      Serial.println("mm wire.");
      dist = dist * 48;
      while (feederStepper.currentPosition() != dist) {
        feederStepper.setSpeed(1200);
        feederStepper.run();
      }
      feederStepper.setCurrentPosition(0);
      delay(100);
    }
    if (dataIn.startsWith("b")) { 
      if (dataIn.charAt(1) == '-') { 
        dataInS = dataIn.substring(2, dataIn.length()); ///reads the angle value
        angle = dataInS.toInt();
        Serial.print("Bend -");
        Serial.print(angle);
        Serial.println(" degrees.");
        angleConst = 16;
        // Set "negative" bending initial position
        while (benderStepper.currentPosition() != -43 * angleConst) {
          benderStepper.setSpeed(-1200);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
        servo01.write(40);
        delay(200);
        // Bend the wire
        while (benderStepper.currentPosition() != angle * angleConst) {
          benderStepper.setSpeed(700);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
        while (benderStepper.currentPosition() != (-1) * angle * angleConst) {
          benderStepper.setSpeed(-1200);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
        servo01.write(130);
        delay(200);
        // Get back to original "positive" bending initial poistion
        while (benderStepper.currentPosition() != 43 * angleConst) {
          benderStepper.setSpeed(1200);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
      }
      else {
        dataInS = dataIn.substring(1, dataIn.length());
        angle = dataInS.toInt();
        Serial.print("Bend ");
        Serial.print(angle);
        Serial.println(" degrees.");
        angleConst = 16;
        servo01.write(40);
        delay(200);
        while (benderStepper.currentPosition() != (-1) *angle * angleConst) {
          benderStepper.setSpeed(-700);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
        while (benderStepper.currentPosition() != angle * angleConst) {
          benderStepper.setSpeed(1200);
          benderStepper.run();
        }
        benderStepper.setCurrentPosition(0);
        delay(100);
      }
      dataInS = dataIn.substring(2, dataIn.length());
      angle = dataInS.toInt();
      angleConst = 16;
      while (benderStepper.currentPosition() != sign * angle * angleConst) {
        benderStepper.setSpeed(-700);
        benderStepper.run();
      }
      benderStepper.setCurrentPosition(0);
      delay(100);
      while (benderStepper.currentPosition() != sign * angle * angleConst) {
        benderStepper.setSpeed(1200);
        benderStepper.run();
      }
      benderStepper.setCurrentPosition(0);
      delay(100);
    }
    // Z-Axis Control
    if (dataIn.startsWith("z")) {
      if (dataIn.charAt(1) == '-') {
        dataInS = dataIn.substring(2, dataIn.length());
        angle = dataInS.toInt();
        Serial.print("Move Z-Axis -");
        Serial.print(angle);
        Serial.println(" degrees.");
        angleConst = 16;
        while (zAxisStepper.currentPosition() != angle * angleConst) {
          zAxisStepper.setSpeed(500);
          zAxisStepper.run();
        }
        zAxisStepper.setCurrentPosition(0);
        delay(100);
      }
      else {
        dataInS = dataIn.substring(1, dataIn.length());
        angle = dataInS.toInt();
        Serial.print("Move Z-Axis ");
        Serial.print(angle);
        Serial.println(" degrees.");
        angleConst = 16;
        while (zAxisStepper.currentPosition() != (-1) *angle * angleConst) {
          zAxisStepper.setSpeed(-500);
          zAxisStepper.run();
        }
        zAxisStepper.setCurrentPosition(0);
        delay(100);
      }
    }
    manualStatus = dataIn;
  }
}

At the end I would like to point out that the wire straightening system of the wire bending machine is actually not working like it should work, because if I tighten it more, the feeder loses grip and the wire doesn’t move.

For solving this issue you could try to use different, stronger material than the copper tube or make a different feeder system.

So that’s it. I hope you enjoyed this video and learned something new. Feel free to ask any question in the comments section below and check my Arduino Projects Collection.

28 Responses

  1. brian alley

    where is the gerber file? i have all the printed parts, and am cutting the wood now. i have no experience with designing a pcb, and no idea where to find the gerber file i am supposed to upload to the pcb maker.
    thanks

    Reply
    • Dejan

      Hey, I updated the article and included the Gerber file in the PCB design section above. You can order the PCB just as explained in the video or in the text.

      Reply
  2. David Smith

    Hi Dejan,
    what a great project. i can not wait to start building it. i noticed is your links to part the Arduino link show that Arduino MEGA but the PCB is made for the Arduino NANO. did you make a change to design?

    Best Regards
    David

    Reply
    • Dejan

      Hey, thanks! Sorry I’ve put wrong links. Now the part list is updated, the Arduino Nano is what you need for sure.

      Reply
  3. Fabricio

    Hi Dejan, great project! did you print the pieces in PLA? how % infill did you used? Regards,

    Reply
  4. Dennis

    Hey Dejan,

    I love the project! As far as your wire feeder losing grip, could you perhaps put a small radius wide rubber band on the copper to increase grip?

    Reply
  5. Abok

    Hi,

    Great project.

    What size ball bearings did you use to make the rollers?

    Thanks.
    Abok

    Reply
  6. Jerome Häckel

    Hi Dejan,
    this is a great project! Thanks for sharing this.
    Is it possible that you add a complete list of all materials used to make it easier to recreate this project?
    It would be great if you could provide the corresponding links to Amazon / Banggood too (if possible).
    In addition:
    The Servo Motor SDLPRT is missing in the rar-file.

    Keep on with the good work 🙂

    Reply
    • Dejan

      Thank you! Well the list of the main components can be found in the article above, in the section where the circuit diagram is. I guess you have seen them and as for the others they are regular common components, like the capacitors and the LM7805 voltage regulator. I actually added the micro limit switch in the list.
      And thanks for the comment for the missing part, I added it both in the STEP and Solidworks file. I’ve just updated the article. 🙂

      Reply
  7. Michel

    Hi Dejan,
    This is a great project! I Love it.
    Very well explained (not too detailed just right).
    Thanks for sharing this.

    Cant wait for other stuff from you!
    Michel

    Reply
  8. Matt

    Your work is really well done! It allows for student for example to mix different aspects of their teaching. Thanks a lot for that! If there was a suggestion: a complete list of material can be interesting to av oid missing a component.

    Reply
  9. Mark

    Hi Dejan

    This wonderful project should be mandatory for all engineering students.

    Covers: Mechanics, electronics, CAD, pcb design, embedded programming, hand tools and 3d printing.

    Would love to see a video/article by you on 3d printing.

    Thanks

    Reply
    • Dejan

      Thank you! Yeah, I will definitely keep creating content like this, I enjoy making it and I love when people find it useful and like it. 🙂

      Reply
  10. Jess R

    In your photos, you have a plastic mount with gear attached, described as ” This gear will be paired with bigger 30 teeth gear which is a custom designed gear with integrated plate for mounting a MG996R servo” – I can’t find this object in the STL files anywhere, is it missing?

    Reply
  11. Soni

    hey,Dejan .
    I am student on mechanical enng, and I have choosen this project for thiz semester , could you send me the solidworks link ,?
    If that wont be anything for you//

    hope to hear soon from you.

    Reply
  12. Tony

    How did you know what the feed rate was? I was wondering how you calculated the force needed to send the wire through the entire assembly.

    Reply
    • Dejan

      Well the feed rate depends on the circumference of the feeder. If it’s 22mm in diamter, such as in my case, the circumference is 69.115mm, so full rotation of the feeder will feed 69.11mm wire. However, you should simply test it out and measure what you get with your feeder.

      Reply
  13. Hans

    Hello, Dejan.
    I am a mechanical education student and have also chosen this project for this semester. Can you convert the Solidworks files into dwg or dxf?

    Thanks in advance
    Greeting

    Reply
  14. Peter Watz

    Hi Dejan.

    I’ve built this machine according to your specs, and it’s useless…
    Or I’ve made some serious errors during construction…

    It won’t bend a 0,5mm brass wire without stalling at the tip at some point.
    The Z-axis won’t turn above 5 degrees and there’s nothing keeping the wire from turning (z-axis) on it’s own…
    I knew the feeder action was questionable from the start so I’m not blaming you for that… 😉

    Any immediate thoughts on what might be the problem?

    Peter

    PS. I have only used the components specified in your BOM…

    Reply
    • Dejan

      Hi Peter,
      Actually I had the same problems. The machine is far from perfect.
      Try to increase the stepper drivers current limit. You can do that using the small screw on the driver. In that way the steppers will draw more current and will have enough power to bend the wire and turn the Z-axis.
      It’s true, the Z-axis motor is on it’s limit of turning the shaft, even at higher driver current limit but it still works, as seen on my video. As for the bender try the same thing, and also try to increase the distance from the nozzle to the bending pin, or shorten the nozzle or the shaft.
      It’s also true that the wire tends to turns along with the Z-axis, which eventually disturbs the form you are making.
      Sorry for not pointing all of these things in the video. But you know, these kind of videos and tutorials should not be taken for granted. You will always need to modify something.

      Reply

Leave a Reply

Your email address will not be published.