Control Delta X S with some basic G-code commands

All versions of Delta X robot work by executing G-code commands sent through the UART protocol, Delta X S too. In this tutorial, we will guide you to control the Delta X S with basic G-code commands using Termite software.

1. Termite software

Termite is an easy to use and easy to configure RS232 terminal. We will use it to send the G-code commands to Delta X S and receive responses from the robot.
You can click here for more details and download the software.
When you open the Termite software, the first interface of the software will look like this:

2. Connection

After turning on Delta X S and plug the USB cable in your computer, we click the Settings button to config the connection.


The Serial port settings dialog box will appear, and you just set some parameters as below:


- Port: choose the COM port of the robot. The COM port name may be different on your computer.
- Baud rate: choose the ‘115200’ value.
- Transmitted text: the end of each command send to COM port of the robot must be a newline character (‘\n’). So, we choose Append LF (‘\n’) or Append CR-LF (‘\n\r’).

Next, click the OK button to connect to your robot.

3. Testing

To check the connection, send the “IsDelta\n’’ command, if connection is stable and the COM port belongs to Delta X, it will respond “YesDelta\n’’.


And now, you can send G-code commands to Delta X S. For example, send “G28\n’’ to make the robot go home. When robot go home successfully, it will respond “Ok”.


An important thing that you must know before controlling the robot is the Z value of the robot when it is in the Home position.
To get the coordinates at the current position of the end-effector, we send “Position\n”. And then, robot will send back the current X, Y and Z coordinates of the end-effector of robot.


In this case, at the home position: X=0, Y=0, Z=-450 (mm) (with Z value may be different for your robot). Note that, at the home position, Z value is not equal 0. For example, in this case, if you want to move Z down 10mm from the home position, you must input the Z value is -460.

4. Some basic G-code commands
+ G00/G01 - Linear move

With Delta X 1 and X 2, you cannot move the robot arm in the X and Y directions if your robot is in the home position. You must move Z down by at least 35mm with Delta X 1 or 37mm with Delta X 2 before you want to move in the X and Y directions.
But with Delta X S, at the home position, you can still move the robot arm in the X and Y directions.
For example, if you want to move the arm to X = 100, Y= -100, Z= -500 position, you can send a simple command: “G01 X100 Y-100 Z-500\n”.


You can also move the robot arm with the predetermined acceleration and speed. For example, now I want to move the robot arm to X = -100, Y=100 position with the acceleration is 1000 mm/s2 and the speed is 200 mm/s, so I send this command: “G01 A1000 F200 X-100 Y100\n”.

Note that, these acceleration and velocity values will still be applied to subsequent movements, until you change their values.
For example, if you want to change the acceleration value to 1200 mm/s2 and the travel speed value to 500 mm/s, you just send:
        “M204 A1200\n”
        “G01 F500\n”                    (for Delta X 1, X 2, X S)
or
        “G01 A1200 F500\n”       (only Delta X S)

In the case your robot has 4/5/6 axes, to control these axes, we use these parameters:
        W<angle>: A coordinate on the 4-axis, degree.
        U<angle>: A coordinate on the 5-axis, degree.
        V<angle>: A coordinate on the 6-axis, degree.
For example, if you want to move the robot arm to X=-150, Y0, Z-500 position, the 4-axis rotates 180 degrees, the 5-axis rotates 90 degrees and the 6-axis rotates 45 degrees, you will send: 
        “G01 X-150 Y0 Z-500 W180 U90 V45\n”


+ G02/G03 - Arc or circle move

Syntax:
        G2 I<offset> J<offset> [X<pos>] [Y<pos>]
with:
        I<offset>: An offset from the current X position to use as the arc center
        J<offset>: An offset from the current Y position to use as the arc center
        [X<pos>]: A coordinate on the X axis
        [Y<pos>]: A coordinate on the Y axis
For example:


If you want to move from A to B, you will send: “G02 I150 J0 X0 Y-150\n”
If you want to move from B to A, you will send: “G03 I0 J150 X-150 Y0\n”


+ G28 - Auto home

The G28 command is used to home one or more axes. The default behavior with no parameters is to home all axes.
For example, if you want all axes go to home position, you just send “G28\n” command. You can also go home individually for each axis: “G28 X0\n”, “G28 Y0\n” or “G28 Z0\n”.


+ M03 - Turn on output pin

Delta X S includes the following output pins:
       Pin 0, 1, 2, …, 13, 14, 15: Digital pin
       Pin 0, 1, 2, 3, 4, 8, 9, 10, 14, 15: PWM pin
       Pin 16, 17, 18, 19, 20, 21: E_GND
       Pin 22, 23, 24: 24V
To turn the digital pin on, we use the syntax:
       M03 Dx,              with x is the digital pin
For example, if you want to turn on the digital pin 10, you will send “M03 D10\n”.
You can also turn on two digital pins at the same time, like “M03 D5 D12\n”.

To turn the PWM pin one, we use the syntax:
        M03 Px Wy,        x is the PWM pin
                                      y is the PWM value 0-255, corresponding to 0-100% duty cycle of PWM pulse
For example, if you want to turn on the PWM pin 10 with the PWM value is 64 (25% duty cycle), you will send:
        “M03 P10 W64\n”
If you want to turn on two PWM pins with the same PWM value at the same time, like: 
        “M03 P3 P4 W127\n”


You can also use M04 to turn on the PWM pins with the PWM value is 0-65535.
For example, if you want to turn on the PWM pin 10 with the PWM value is 16384 (25% duty cycle), you will send:
        “M04 P10 W16384\n”


+ M05 - Turn off the output pin.

To turn off the digital output pin, we send:
        “M05 Dx\n”,       x is the digital pin
To turn off the PWM output pin, we send:
        “M05 Py\n”,       y is the PWM pin


+ M07 - Read input

Delta X S includes the following output pins:
       Digital Input: 1, 2, 3, 4, 5, 6, 7, 8
       Analog Input: A1, A2, A3, A4
       E_GND: 9, 10
       24V: 15
- Read digital input value:
For example, to read the value from the digital input pin-1, you send this command:
        “M07 I1\n”
You can also send this command “M07 I3 I4” to read the values from the pin 3 and pin 4 at the same time.
The value of digital input pin is 0 or 1.


- Read analog input value:
To read input value from the analog pin A1, we send:
        “M07 A1\n”
You can also read multiple analog pins at the same time:
        “M07 A2 A3\n”
The feedback analog value will be between 0 and 4095.


+ M08 - Read input automatically

When you use M08, the robot will automatically resend the digital value when the value changes.
For example, to read value of digital pin 5 automatically, we send:
        “M08 I5 B1\n”


When the value of pin 5 changes from 0 to 1, we will receive the new value automatically.


If you don’t want to read the value from pin 5 automatically anymore, you send this command:
        “M08 I5 B0\n”


About read input analog value automatically, we use the syntax:
        “M08 Ax Cy\n”,       x is the analog pin
                                           y is time (microseconds) to update the value.
                                           If y < 100us, turn off the automatic reading.
                                           If y >= 100us, turn on the automatic reading.
For example, to automatically read value of analog pin A1 every 500 microseconds, we send this command:
        “M08 A1 C500\n”


And the value of pin A1 will be update every 500us.
When you want to turn off this automatic reading, you send:
        “M08 A1 C0\n”

+ M210 - Set the movement parameters of X, Y, Z axes

To set the movement parameters of X, Y, Z axes, we use the syntax:
               “M210 Fx Ax Jx Sx Ex\n”
with:     Fx – motion speed, x(mm/s)
               Ax – motion acceleration, x(mm/s2)
               Jx – jerk of X, Y, Z axes, x(mm/s3)
               Sx – start motion speed, x(mm/s)
               Ex – finish motion speed, x(mm/s)
For example:


Same as M210:  M211 to set the movement parameters of 4-axis
                               M212 to set the movement parameters of 5-axis
                               M213 to set the movement parameters of 6-axis

+ M220 - Read the movement parameters

To know the movement parameter values of the axes, we use the syntax:
           “M220 Ix\n”
with x=0: get the movement parameters of the X, Y, Z axes
          x=1: get the movement parameters of the 4-axis
          x=2: get the movement parameters of the 5-axis
          x=3: get the movement parameters of the 6-axis
For example, to read the current movement parameters of the X, Y, Z axes, we send “M220 I0\n”.


Above are the basic G-code commands to control Delta X S. You can refer to other G-code commands here.