How to create a robotic arm with your students

The G-Code. Programming the movements

The robot uses gcode commands. G-Code is a programming language for CNC machines. These commands will tell our robot to move the X, Y or Z coordinates, which are the motors that we have installed in our arm and connected to our RAMPS.

Although the G-Code is used in CNC machines and there are different implementations such as DIN66025, ISO 6983, Siemens, Haas or FANUC. Many manufacturers expand the instruction set to work with the machines they have designed. We will also expand the instructions to be able to control not only the arm but also the engines of a rover that is where we are going to place our robot.

Here are tips on the GCODE that Florin Tobler has programmed for the robot:

 

A valid gcode command looks like G1 X0 Y120 Z120There have to be spaces in between.

  • G0=G1: Move XYZ in mm (cartesian), F in mm/s. Always uses Absolute coordinates. Unlike 3D Printers, there is no E-Axis. On every move there is an acceleration and deacceleration.
  • G4: Dwell / Sleep T in milliseconds
  • M3: Close Gripper / Aux Motor T in Steps. Cannot move simultaneously to G
  • M5: Open Gripper / Aux Motor T in Steps. Cannot move simultaneously to G
  • M17: Enable Stepper Motors, also Enables Fan
  • M18: Disables Stepper Motors, also Disables Fan with delay
  • M106: Enables Fan
  • M107: Disables Fan

We are not going to use the M106 or M107 commands since we want to always have the fan running and not depend on the programming. That way we make sure that bad programming does not overheat the drivers and damage them.

In conclusion:

  • G commands. They are used to move the robot.
  • M commands. They are used to control the gripper, motors and fans.

Below is a video of the operation of our robotic arm. In it you can see how the commands are entered from the Arduino IDE serial port program to perform the arm movements:

The Demeter Project