Go Down

Topic: How to deconstruct GCodes to control my robotic arm?  (Read 405 times) previous topic - next topic

emresurk

Hello Everyone!

I build a simple robotic arm with Arduino and servo motors.

It can make simple movement. For example it can make dots or draw arc. But all these movements are predefined by me. I defined the movements as degree of servo and I m sending servo positions to move robotic arm move. This is so limited. I m wanting to send coordinates, Arduino can calculate servos' positions.

So,
I can control robotic arm with sending servo degrees( with PWN values ).

I m wanting control robotic arm with sendind coordinates or GCodes.

How can deconstruct GCodes ( or coordinates ) to servo degrees?


After that, my robotic arm can draw shapes, write to paper or print objects !


The only way I can image is setting up a stereo came system and mapping all positions - servo degrees equations. So I will have all servo positions data for specific coordinates and I will know servos positions for all coordinates.

Is there any shorter way? A free&basic simulator program or a mathematical way or anything else ?

My code is really simple. I m sharing it.
Also I added robotic arms images.

Any help will be appreciated !

Code: [Select]
#include <Servo.h>

Servo x1Axis;
Servo y1Axis;
Servo y2Axis;


int pos = 0;  

// each NOTA variable keeps 3 servos' postions.  

struct NOTA {
    int x1;
    int y1;
    int y2;
  };

// I m sending these variables to notaHareketi function to make movements.
// These values represent servos' positions.

NOTA doBas = { 50, 50, 10 };
NOTA doSal = { 50, 70, 10 };

NOTA reBas = { 80, 50, 14 };
NOTA reSal = { 80, 70, 14 };

NOTA miBas = { 100, 50, 18 };
NOTA miSal = { 100, 70, 18 };

void setup() {
  x1Axis.attach(7);
  y1Axis.attach(8);
  y2Axis.attach(9);
  
}
void loop() {
  
  notaHareketi(doSal);
  delay(700);
  notaHareketi(doBas);
  delay(700);
  notaHareketi(doSal);
  delay(2000);

  notaHareketi(reSal);
  delay(700);
  notaHareketi(reBas);
  delay(700);
  notaHareketi(reSal);
  delay(2000);

  notaHareketi(miSal);
  delay(700);
  notaHareketi(miBas);
  delay(700);
  notaHareketi(miSal);
  delay(2000);
}

void notaHareketi(NOTA nota){
    x1Axis.write(nota.x1);
    delay(50);
    y1Axis.write(nota.y1);
    delay(50);
    y2Axis.write(nota.y2);
    
  }




























jremington

#2
Nov 13, 2017, 05:11 pm Last Edit: Nov 13, 2017, 05:12 pm by jremington
What you want is called "inverse kinematics", which involves having a mathematical model for the lengths and joints of the arm.

Your program will then take the desired final position and orientation of the "gripper" (if there is one) and calculate the best arm movements to achieve that goal, taking into account mechanically forbidden angles, obstructions, etc.

It is not at all a simple problem, but Google will provide plenty of information.

Go Up