Arduino Pro Mini Controlling Robot Arm via Qt GUI

This project brings to fruition 3 components that I have been working on:-

1. Qt Serial interface with an Arduino that can transfer data upto 115200 kbps with rudimentary error checking. Source code (arduinotalker.cpp and arduinotalker.h) available here.

2. Custom PCB using a Arduino Pro Mini as a 6 servo controller. Circuit Diagram available (pro_mini_6_Servo_controller.fzz) here.

3. 6 DOF Robot Arm powered with a 6V 5A DC external power regulator.

6 DOF Robot ARm with Arduino Pro Mini Controller

6 DOF Robot ARm with Arduino Pro Mini Controller

The idea was to control a 6 DOF robot arm using a Qt GUI like the one shown below. Control of the joints should be effected by moving sliders/ turning knobs etc on the GUI.

Each slider controls one joint

Each slider controls one joint by activating a servo motor

Here is the Arduino program that receives control signals from the Qt GUI and translates them into PWM commands for each of the six servo motors on the robot arm. Since I was using an Arduino Pro Mini, I had to make sure that I selected the right “board” from the IDE drop down menu before uploading the program to the microcontroller.

</pre>

#include <Servo.h>
 #define NO_OF_FIELDS 6

Servo base, shoulder, foreArm, wristFlex, wristRotate, claw;

int inCommand[NO_OF_FIELDS];
 int ledPin = 13;

void EchoData(int echoWord[])
 {
 Serial.print("*");

float total;

for (int i = 0; i < NO_OF_FIELDS; i++)
 {
 Serial.print((int)echoWord[i]);

total+= inCommand[i];

Serial.print(",");
 }
 Serial.print((int)total);
 Serial.print(",");
 Serial.print("*");
 Serial.print("&");
 }

void ClearOldData(int oldData[])
 {
 for (int i = 0; i < NO_OF_FIELDS; i++)
 {
 oldData[i] = 0;
 }
 }

void setup()
 {
 Serial. begin(38400);

base.attach(3);
 shoulder.attach(5);
 foreArm.attach(6);
 wristFlex.attach(9);
 wristRotate.attach(10);
 claw.attach(11);

//initialise all arms

base.write(90);
 shoulder.write(150);
 foreArm.write(40);
 wristFlex.write(90);
 wristRotate.write(90);
 claw.write(175);

pinMode(ledPin, OUTPUT);
 }

void loop()
 {
 if(Serial.available())
 {
 for(int i = 0; i < NO_OF_FIELDS; i++)
 {
 inCommand[i] = Serial.parseFloat();
 }

unsigned long time1 = millis();

while (Serial.read() != -1)
 {
 //loops here until serial buffer becomes empty
 //Serial.println(millis() - time1);
 digitalWrite(ledPin, HIGH);
 }

digitalWrite(ledPin,LOW);

//echo the incoming command sequence

EchoData(inCommand);

//now do something with the inCommand[] array....

base.write(inCommand[0]);

shoulder.write(inCommand[1]);

foreArm.write(inCommand[2]);

wristFlex.write(180 - inCommand[3]);

wristRotate.write(inCommand[4]);

claw.write(inCommand[5]);

//clear the inCommand[] array

ClearOldData(inCommand);

}

}

Here is the youtube video I made that explains the circuit diagram in more detail and demonstrates the project in operation….

Advertisements

29 thoughts on “Arduino Pro Mini Controlling Robot Arm via Qt GUI

  1. Nice Project man! im starting now to learn abou qt, im having troubles whit serial port. but watching your projects im making progress, thank yu!

  2. Pingback: Experimental Robotic Platform Part 1 – Building the Chassis | Bayesian Adventures

  3. Arduino: 1.6.1 (Windows 7), Board: “Arduino Due (Programming Port)”

    sketch_mar26a.ino:1:1: error: expected unqualified-id before ‘ Preferences.

    How can i solve this error in the previous code please ???

  4. Hi, i was trying to do something similar before y found your proyect. I’m using Qt and a arduino UNO, it is possible for you to explain me this in a beginner way (both the arduino and the Qt code)? i want to do the same thing plus to implement a pick & place routine. How can i get it started? My trouble is to read the data send from the arduino. I’m having issues by reading the data from 2 analog inputs, my dial widgets just went crazy.

    • All you need to do is…

      1. In Qt, create an ArduinoTalker object and have it listen / send data using the member functions of my ArduinoTalker class.

      2. On the arduino side, you need to listen on the serial port and then you may send/ receive commands.

  5. Pingback: The Gift of Sight… | Bayesian Adventures

  6. I was the second year students, I come from Vietnam, I was doing 6 dof robot in my graduation thesis, you can provide detailed guidance for me, I do not do hardware I just write code for it only!

    • Sorry for the delay. I have been travelling and just checked my messages today. I have updated the links in the post. You can download the Qt c++ class for the Arduino communication and also the Fritzing circuit diagram for the PCB.

  7. – c:\work\build\qt5_workdir\w\s\qtbase\src\winmain\qtmain_win.cpp:131: error: undefined reference to `qMain(int, char**)’
    – collect2.exe:-1: error: error: ld returned 1 exit status

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s