Project tutorial
WIZnet Controlled Robotic Arm

WIZnet Controlled Robotic Arm © Apache-2.0

Control your robotic arm from long distance using Ethernet.

  • 1,917 views
  • 0 comments
  • 12 respects

Components and supplies

Apps and online services

About this project

If you want to communicate with a serial device then possibly maximum cable length is the main barrier. The maximum cable length for standard baud rate can be 50 ft. You can increase the cable length further by sacrificing the data rate. Moreover now a days most of the PC come without the serial port. An Ethernet to Serial converter may be an ideal solution of the above problems. You can transfer data to a serial device in a high speed through Ethernet port. Cable length can be 100 meters or more.

In this projec, I used WIZnet's Serial to Ethernet (S2E) device (WIZ750SR) for controlling a 3D-printed robotic arm. This is a prof of concept project and the capacity of the arm is very much limited. I developed a Windows application using open source Processing environment for controlling the arm from my desktop PC.

Before going further, please watch the demo video.

Demo video

First, I configured the WIZnet device using S2E configuration tool from WIZnet as follows (note the IP address and the port number). WIZnet device is configured as TCP server. The Baud rate of serial communication should be 115200 (ignore the rate on the image).

Then I connected a 3.3V USB FTDI converter to the WIZ750SR to check the serial communication. I used PuTTY to test the communication.

I open two PuTTY windows one as Telnet client and another as Serial client.

After successfully checking the serial communication I connected an Arduino board to the WIZ750SR using TX and RX pin.

For connecting WIZ750SR with Arduino board it is safe to use a level converter because WIZ750SR works at 3.3V where Arduino works at 5V. Here I connected a level shifter between WIZ750SR an Arduino board. High voltage side of the level shifter must be connected with Arduino and low voltage side of the level shifter must be connected with WIZ750SR.

I tested the WIZ750SR device with both Arduino NANO and Arduino UNO.

For controlling the robotic arm from my PC through Ethernet I developed an desktop application using Processing. Processing is sending data to Arduino using a virtual COM port.

A virtual COM port or a virtual serial port is an ideal solution for when a legacy software application expects a connection to a serial device port (COM port) but cannot connect, due to a physical lack of available serial ports. Instead, we reconfigure the computer to send serial port data over a local area network or the Internet as if over a true serial port. When the legacy application sends data to a serial COM port, it is actually transmitted over a TCP/IP network and back from the network to your legacy application -- and presto! -- we have a virtual serial or virtual COM port.

To set up a virtual COM port to your PC you will be required a third party tool. You may use WIZ VSP for this purpose.

After configuring the virtual COM port as COM20 I developed a Processing program to interact graphically to Arduino robotic arm using WIZ750SR. To run the processing code you need to add the ControlP5 GUI library for Processing. Download the library from here: http://www.sojamo.de/libraries/controlP5/. Please note the COM port number which must be the number of the virtual COM port you created.

The graphical output of the Processing program is as follows:

From five slider I can control the rotation of the five servo motors of the robotic arm very smoothly and easily.

The complete source code for the application is attached to the code section.

The following figure shows the connection among PC, WIZ750SR and Arduino.

The tiny robotic arm is 3D-printed and design files are available in Thingiverse. I used five servo motor to control the arm. The servo motors are connected to Arduino digital pins.

The arm is controllable from a long distance using Ethernet. No need to have a serial port in your PC. The complete Arduino sketch of for the arm is also attached to the code section. So make and enjoy!

Code

Code for Desktop ApplicationProcessing
The app was developed using processing. Before running the program add the ControlP5 library from the link: http://www.sojamo.de/libraries/controlP5/
/**
Wiznet controlled robotic arm
Author: Md. Khairul Alam
 */
import controlP5.*;
import processing.serial.*; //import the Serial library

Serial myPort;  //the Serial port object
PImage img;
PImage img1;
PImage img2;

ControlP5 cp5;
int myColor = color(0,0,0);
int topColor = color(110,110,110);
int bottomColor = color(110,110,110);
int tColor = color(0,200,0);


void setup() {
  size(600,400);
  noStroke();
  
  
  cp5 = new ControlP5(this);
  img = loadImage("wiznet.png");
  img1 = loadImage("nano.png");
  img2 = loadImage("hackster.png");
  
  // create five slider 
  cp5.addSlider("BASE")
     .setPosition(100,100)
     .setSize(20,200)
     .setRange(0,180)
     .setValue(90)
     ;
     
  cp5.addSlider("SHOULDER")
     .setPosition(160,100)
     .setSize(20,200)
     .setRange(70,170)
     .setValue(90)
     ;
     
     
  // add a vertical slider
  cp5.addSlider("ELBOW")
     .setPosition(230,100)
     .setSize(230,20)
     .setRange(25,170)
     .setValue(80)
   
     ;
  
  // add a vertical slider
  cp5.addSlider("WRIST")
     .setPosition(230,195)
     .setSize(230,20)
     .setRange(0,180)
     .setValue(90)
     ;
     
  // add a vertical slider
  cp5.addSlider("GRIPPER")
     .setPosition(230,280)
     .setSize(230,20)
     .setRange(80,180)
     .setValue(90)
     ;
  
  //myPort = new Serial(this, Serial.list()[4], 9600);
  myPort = new Serial(this, "COM20", 115200);
  myPort.bufferUntil('\n'); 

}

void draw() {
  background(165,165,165);
  
  fill(topColor);
  rect(0,0,width,100);
  
  textSize(39);
  fill(255, 102, 200);
  text("WIZnet Controlled Robotic Arm", 10, 50); 
  
  fill(myColor);
  rect(0,80,width,240);
  
  fill(bottomColor);
  rect(0,320,width,100);
  image(img, 0, 280, width/2, height/2);
  image(img1, 280, 320, width/3, height/3);
  image(img2, 490, 320, width/6, height/5);
}

void controlEvent(ControlEvent theEvent) {
 /* events triggered by controllers are automatically forwarded to 
 the controlEvent method. by checking the name of a controller one can 
 distinguish which of the controllers has been changed.
 */ 
 
 /* check if the event is from a controller otherwise you'll get an error
 when clicking other interface elements like Radiobutton that don't support
 the controller() methods
 */
 
 if(theEvent.isController()) { 
 
 print("control event from : "+theEvent.getController().getName());
 float posValue = theEvent.getController().getValue();
 println(", value : "+posValue);
 int temp = int(posValue);

 
 if(theEvent.getController().getName()=="BASE") {
  println("Base is moveing");
  String pos = str(temp);
  myPort.write(pos);          //send position
  myPort.write('\n'); 
  delay(100);
 }
 
 if(theEvent.getController().getName()=="SHOULDER") {
  println("Shoulder is moveing");
  String pos = str(temp+180);
  myPort.write(pos);          
  myPort.write('\n'); 
  delay(100);
 }
 
 if(theEvent.getController().getName()=="ELBOW") {
   println("Elbow is moveing");
   String pos = str(temp+360);
   myPort.write(pos);         
   myPort.write('\n'); 
   delay(100);
 }
 
 if(theEvent.getController().getName()=="WRIST") {
  println("Wrist is moveing");
  String pos = str(temp+540);
  myPort.write(pos);         
  myPort.write('\n'); 
  delay(100);
 }
 
 if(theEvent.getController().getName()=="GRIPPER") {
  println("Gripper is moveing");
  String pos = str(temp+720);
  myPort.write(pos);          
  myPort.write('\n'); 
  delay(100);
 }
 
 }
}

void serialEvent (Serial myPort) {
  // get the byte:
  int inByte = myPort.read();
  // print it:
  println(inByte);
}
Arduino Sketch for controlling the ArmArduino
This code was developed to control five servo based on the data received from serial port.
/*************************************
 * Author: Md. Khairul Alam
 * This code is for controlling a robotic arm containing 5 servos
 */

#include <Servo.h>

Servo servo1, servo2, servo3, servo4, servo5;
String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete

int gripper = 2;
int wrist = 3;
int elbow = 4;
int shoulder = 5;
int base = 6;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  servo1.attach(gripper);
  servo2.attach(wrist);
  servo3.attach(elbow);
  servo4.attach(shoulder);
  servo5.attach(base);
  inputString.reserve(200);
}

void loop() {
  
  if (stringComplete) {
    int pos = inputString.toInt();
    if(pos <= 180){//if received message = pos1
        set_base(pos);
        delay(20);
      }
    else if(pos>250 && pos <=350){
        set_shoulder(pos-180);
        delay(20);
      } 
    else if(pos>385 && pos <=530){
        set_elbow(pos-360);
        delay(20);
      }  
    else if(pos>540 && pos <=720){
        set_wrist(pos-540);
        delay(20);
      }
    else if(pos>800 && pos <=900){
        set_gripper(pos-720);
        delay(20);
      }
    // clear the string:
    inputString = "";
    stringComplete = false;
  }

}

void servo_rotate(int num, int value){
  switch(num){
    case 1:
    servo1.write(value);
    break;

    case 2:
    servo2.write(value);
    break;

    case 3:
    servo3.write(value);
    break;

    case 4:
    servo4.write(value);
    break;

    case 5:
    servo5.write(value);
    break;
    }
 }
 
//this function grip an object  
//this function drive servo 5 to set x position in angle
void set_base(int pos){
  int previous_pos = servo5.read();
  if(pos>previous_pos){
    for(int i=previous_pos; i<pos; i+=2){
      servo_rotate(5, i);
      //delay(25);
      delay(5);
      }
    }
  if(pos<previous_pos){
    for(int i=previous_pos; i>pos; i-=2){
      servo_rotate(5, i);
      //delay(25);
      delay(5);
      }
    } 
 }
//set sevo 3 position
void set_elbow(int pos){
  int previous_pos = servo3.read();
  if(pos>previous_pos){
    for(int i=previous_pos; i<pos; i+=2){
      servo_rotate(3, i);
      delay(5);
      }
    }
  if(pos<previous_pos){
    for(int i=previous_pos; i>pos; i-=2){
      servo_rotate(3, i);
      delay(5);
      }
    } 
 }
//set sevo 2 position
void set_wrist(int pos){
  int previous_pos = servo2.read();
  if(pos>previous_pos){
    for(int i=previous_pos; i<pos; i+=2){
      servo_rotate(2, i);
      delay(5);
      }
    }
  if(pos<previous_pos){
    for(int i=previous_pos; i>pos; i-=2){
      servo_rotate(2, i);
      delay(5);
      }
    } 
 }

//set sevo 1 position
void set_gripper(int pos){
  int previous_pos = servo1.read();
  if(pos>previous_pos){
    for(int i=previous_pos; i<pos; i+=2){
      servo_rotate(1, i);
      delay(5);
      }
    }
  if(pos<previous_pos){
    for(int i=previous_pos; i>pos; i-=2){
      servo_rotate(1, i);
      delay(5);
      }
    } 
 }
//set sevo 4 position
void set_shoulder(int pos){
  int previous_pos = servo4.read();
  if(pos>previous_pos){
    for(int i=previous_pos; i<pos; i+=2){
      servo_rotate(4, i);
      delay(5);
      }
    }
  if(pos<previous_pos){
    for(int i=previous_pos; i>pos; i-=2){
      servo_rotate(4, i);
      delay(5);
      }
    } 
 }

void serialEvent() {
  while (Serial.available()) {    
    // get the new byte:
    char inChar = (char)Serial.read();     
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
    else
    // add it to the inputString:  
      inputString += inChar;
  }
}

Schematics

Connection of servo motors to Arduino
Arm schematic ytlxulke1o
Graphical Interface of Desktop Application
Output buisyhmsxc
Virtual COM Port
Vcom notional1 knuho9ovxd
WIZ750SR Pinout
Wiz750sr all pinout 20160628 nzs9bne 2batdiisrh shyh4taxag

Comments

Similar projects you might like

PC Controlled Robotic Arm

Project tutorial by AhmedAzouz

  • 8,454 views
  • 12 comments
  • 67 respects

Robotic Arm Controlled by Human Arm

Project showcase by zezarandrade

  • 3,687 views
  • 0 comments
  • 5 respects

Nunchuk Controlled Robotic Arm (with Arduino)

Project tutorial by Igor Fonseca Albuquerque

  • 4,613 views
  • 5 comments
  • 36 respects

Chatbot controlled Robotic Arm

Project tutorial by Keval Doshi

  • 3,074 views
  • 0 comments
  • 25 respects

Android Controlled 6DoF Robotic Arm

Project in progress by Team Mans

  • 11,065 views
  • 0 comments
  • 17 respects
Add projectSign up / Login