3📅Update: 2020/09/04

DexArm is developed based on the world's leading open-source project Marlin, the DexArm firmware is completely open-source, and its control commands (G-code) are compatible with Marlin. Please visit GitHub for more details of our firmware project.

G-code commands are the general control commands for CNC machines, 3D printers, etc. It is composed of ASCII strings, such as G1 F2000 X0 Y300 Z0, G-code commands usually uses \n as the sending end character.

In Marlin, the slave device will reply ok after receiving the G-code commands, the host computer then can send the next commands after receiving the ok. In DexArm SDK (pydexarm - download below👇), we have encapsulated this sending and receiving mechanism and make it convenient for users to use.

Communication Parameters

  • Baud rate: 115200

  • Data bits: 8

  • Stop bits: 1

  • Parity: None

  • Flow control: None

  • Commands end with CR+LF, hereinafter referred to as 0D0A.

  • When the slave device receives a command, if the command is correct, it returns "ok"; if not, it returns "unknown command".


After the host computer is connected to the robot arm, please send the command M1112 first to move the arm to the HOME (X0 Y300 Z0) position.

Basic Motion Control Commands


  • Reset to the HOME position (X0 Y300 Z0)

Don't mix up with the M112 Emergency stop command.


  • Move to the recalibration position


  • Execute M1111 first, then M1112

G0 - Rapid Movement

  • X - Movement distance of X-axis in mm, accuracy 0.1mm

  • Y - Movement distance of Y-axis in mm, accuracy 0.1mm

  • Z - Movement distance of Z-axis in mm, accuracy 0.1mm

  • E - Movement distance of E-axis in mm, accuracy 0.1mm

  • F - Movement speed in mm/s, default speed is 40mm/s

G1 - Linear Movement

  • X - Movement distance of X-axis in mm, accuracy 0.1mm

  • Y - Movement distance of Y-axis in mm, accuracy 0.1mm

  • Z - Movement distance of Z-axis in mm, accuracy 0.1mm

  • E - Movement distance of E-axis in mm, accuracy 0.1mm

  • F - Movement speed in mm/s, default speed is 40mm/s

G90 - Absolute Positioning

Under this command, G0 and G1 movement is in absolute mode.

For example, the current position is X300 Y0 Z0, sending G0 X310, the Arm moves to X310 Y0 Z0.

G91 - Relative Positioning

Under this command, G0 and G1 movement is in relative mode.

For example, the current position is X300 Y0 Z0, sending G0 X10, the Arm moves to X310 Y0 Z0.

G92 X0 Y0 Z0 E0

Set the current position as the Work Origin

G92.1 - Reset G92 Command

For example, if the arm is currently at X300 Y0 Z0 E0, sending G92 X0 Y0 Z0 E0 will set the current position as the Work Origin. Sending M114 to read position, you will get X0 Y0 Z0 E0, the arm is working under the Work Object Coordinate System. Sending G92.1 will reset G92 command, and the arm will reset to the original coordinate system.

G4 - Dwell Command

  • P500 - dwell for 500ms

  • S10 - dwell for 10s

Return Values

M2010 - Return firmware version

M2011 - Return hardware version

M503 - Return device status info

M115 - Return Marlin firmware info

M897 - Whether the arm moved to the target position

M1004 - Check air pump box status

Air pump

  • In - pump in

  • Out - pump in

  • Neutral - release air

  • Off - turn off

M2014 - check the status of the conveyor belt, including moving direction and speed.

  • Forward xx mm/s

  • Backward xx mm/s

  • Stop

M6 - check the status of laser module

  • On - the laser is on

  • Off - the laser is off

M18 - motor deactivation command. After sending M18, the motor will go into deactivation and can be manually adjusted for recalibration or the teach & Play function.

Motion Commands

M114 - return the current position value, in mm. If the rotary module is connected, it also returns the R absolute angle value.

M204 - read and set robot arm moving acceleration value. The default setting is M204 P200 R60 T200.

  • When it is without any parameters, it reads the acceleration value.

  • P - printing acceleration value.

  • R - returning acceleration value.

  • T - idle stroke acceleration value.

M889 - Read magnet encoder value and set the initial calibration position.

  • X Y Z - set magnet encoder value of current position for recalibration.

M890 - get the magnet encoder position readings.


  • X Y - set the current XY slope value, usually used in 3D printing leveling.

M892 - read the current XY slope value

M893 - refresh the magnet encode value from the sensor

M894 - set a target value of the magnet encoder

  • X - the X-axis encoder value of target position, range

  • Y - the Y-axis encoder value of target position, range

  • Z - the Z-axis encoder value of target position, range


  • read the magnet encode values from the sensors and then convert it into actual coordinate values, displayed in the Cartesian coordinate system, in mm.

  • for teach & play function

M81 - turn off the fan, heating or other functions.

M410 - stop the arm movement quickly, send G0 and G1 commands to continue the movement.

M112 - emergency stop command, the arm will not respond to any commands. Need to reboot the arm for more action.

Basic Controls

Motion Mode


Switch G0 to linear movement.


Switch G0 to rapid movement.

Basic Movement commands

G91: enter relative mode.

G0 X1: move +1mm on the X-axis.

G90: enter absolute mode.

Front-end Module Switch


P0 - set the front-end module as the pen holder module

P1 - set the front-end module as the laser module

P2 - set the front-end module as the pneumatic module

P3 - set the front-end module as the 3D printing module

P4 - set the front-end module as the rotary module

P10 - turn on the safety enclosure laser protection

P11 - turn off the safety enclosure laser protection

P13 - check safety enclosure door status

No Parameter/send M880 directly - check the current module

Each time when you enter a module function interface, you need to send the module setting command.


Process of G-Code files:

  1. send by code line, each line ends with 0D0A

  2. only sending the next code when it receives the "ok" return value from the server

  3. the code line starting with";" will be automatically filtered by the host computer, and will not be sent to the server

  4. Pause/Resume, corresponding to pause or continue sending commands in the host computer.

Laser Module

M3 - command to turn on laser


  1. S corresponds to the laser power duty cycle, the range is 0-255. Special definition: when it is S1, the laser power is very low, suitable for laser engraving borders.

  2. Example: M3 S10 - turn on the laser with a duty cycle of 10.

M5 - Turn off the laser module.

M6 - Return to laser on/off status.

Pneumatic Module

M1000 - air pump box pump in/soft grip start gripping

M1001 - air pump box pump out/soft grip start opening

M1002 - air pump box/soft grip return to original status

M1003 - all air pump boxes stop working

Teach & Play

  • Teach: Send M893, the arm returns M894 + the magnet encoder value of 3-axises, the software or touch screen saves the corresponding data.

  • Replay: Resend the saved information and the arm will repeat the previously recorded movement.

3D Printing

M104 Sxx - set the extrusion head temperature, during which the motion command is possible.

  • Sxx - target temperature, accuracy 1°C

  • Example: M104 S200 - Set the extrusion head target temperature to 200°C.

M105 - get the current extrusion head temperature

M108 - get the extruder speed

M109 Sxx - Set the extruder target temperature xx and wait for the temperature to rise. No command will be executed during this period. The server unit will return the current temperature in real-time.

Sxx - target temperature, precision 1°C

Example: M109 S200 - Sets the extrusion head target temperature to 200°C and wait for the temperature to rise.

M106 Sxx - Set fan speed xx

M107 - turn off the fan

M130 - Set heater bar PID P value

M131 - Set the heater bar PID I value

M132 - Set heater bar PID D value

G0 EXXX FXXX - Extrude E length at F speed

Conveyor Belt

M2012 - control the rotation of the conveyor belt

  • Parameters: F speed (in mm/min), D direction (0 is clockwise, 1 is counterclockwise)

  • For example:

    • M2012 F1000 D0 - rotate clockwise in 1000mm/min speed.

    • M2012 F200 D1 - rotate counterclockwise in 200mm/min speed.

M2013 - stop the conveyor belt

M2014 - check the status of the conveyor belt

M1115 - M1119 - return the color recognition sensor data. For the scratch color recognition function and other demos. Parameters:

  • 1115: item - means there is an item.

  • 1116: red - indicates a red block.

  • 1117: green - indicates a red block.

  • 1118: blue - indicates a blue block.

  • 1119: yellow - Indicates a yello block.

Sliding Rail

M2005 - E axis return to the home point. With the locked rotor test function of TMC2209, it drives the slide back to the home point twice, when the TMC is pushed to the limit, the slide is returned to the home point successfully.

  • Parameters: XYZE must be fully set, otherwise use the default values (30, 10, 60, 60).

    • X - HOME maximum speed

    • Y - HOME lowest speed

    • Z - the 1st TMC detection threshold value

    • E - the 2nd TMC detection threshold value

M2006 - check if the return operation is completed.

M914 - set the sensitivity of TMC blocking for the E-axis.

Rotary Module

M888 P6 - set the offset value and initialize the rotary module

M2100 - initialize the rotary module

M2101 - get the rotary module angle value, control the movement, with 1-degree accuracy. Parameters:

  • Without parameters: get the absolute angle of the rotary module.

  • R(relative) - rotate the module by n degrees from the current position, n can be greater than 360.

    1. Clockwise rotation n degrees, M2101 Rn

    2. Counterclockwise rotation n degrees, M2101 R-n

  • P(position) - rotates the rotary joint to an absolute angle n.

    1. M2101 Pn - rotate the module to an absolute angle n, the range of n is 0 - 360.

  • S - set the module rotates continuously, speed range from 0-100. S0 refers to speed zero(stop). S1 refers to rotation at a low speed, S100 refers to rotation at the highest speed.

    • clockwise rotation continuously, M2101 Sn

    • counterclockwise rotation continuously, M2101 S-n

M2102 - Upgrade the firmware of the rotary module

Parameter U - Upgrade step number, default is 0.

  • 0 - no operation

  • 1 - enter boot

  • 2 - set the file size with the s parameter

  • 3 - receive the file

M2103 - check the current rotary module firmware version

  • For example, M2103, return Rotary Firmware V1.1.2

Firmware Upgrade

M2002 - enter Bootloader

M2003 - confirm the upgrade, enter Bootloader

  • Once enter Bootloader, send numbers 1-5 to view device data, send firmware, etc.

    • 1 - download firmware to the robot arm

    • 2 - upload firmware from the robot arm

    • 3 - execute firmware

    • 4 - enter boot protection mode, no firmware transfer

    • 5 - print the device firmware and hardware version data.

M2004 - Cancel upgrade

M2007 - Reboot the device.

Error Report

ERROR 100-199, motion and initialization related, such as M1112

ERROR 200-299, motion and initialization related, 3D printing related, such as heating, temperature, etc.

Error:100, Position Sensor Read Error

  • Position sensor error

  • Exceed the sensor reading maximum range, such as 65535

  • Possible causes: usually 8Pin wire loose, off, or magnetic code board damage

Error:103, Position Sensor Diff Error

  • M1112 M1111 sensor DIFF exceeds the maximum angle range

  • Possible causes: calibration error, magnet off

Error: 101, 102 Home Error

  • Home Error (Axis data).

  • Possible causes: wrong magnet, magnet off, motor wire loose, motion out of step, etc.

Error: 203, MINTEMP triggered, system stopped! Heater_ID: 0

  • When the heating is turned on, the minimum temperature is triggered, usually, the temperature sensor is not inserted, or the temperature sensor is disconnected.

Error: 202, MAXTEMP triggered, system stopped! Heater_ID: 0

  • the maximum temperature is triggered, usually caused by a broken temperature sensor.

Error:200, Heating failed, system stopped! Heater_ID: 0

  • No significant temperature change (<2°C) after a certain heating time (20S)

Error: 201, Thermal Runaway, system stopped! Heater_ID: 0

  • After heating up to the specified temperature, the temperature drops significantly.

Set leveling coefficient

M891 Xn Yn

Read leveling coefficient


Read current encoder position data


Move to a specific encoder value position

M894 Xn Yn Zn

End effector control commands

Pneumatic module control commands

  • M1000 - air pump box to pump in

  • M1001 - air pump box to pump out

  • M1002 - air pump box to release air

    • To return to original status when the suction cup/soft gripper is not working.

  • M1003 - stop air pump box

Laser engraving module control commands

Related control commands M003 M005

3D printing control commands

Accessory control commands

Conveyor belt control commands

set conveyor belt working speed as 2000mm/min, clockwise

M2012 F2000 D0

set conveyor belt working speed as 2000mm/min, counter-clockwise

M2012 F2000 D1

stop conveyor belt


Reset the touchscreen firmware

Connect the touchscreen to DexArm after sending the following commands:


Reset DexArm Settings

Reboot DexArm and enter bootloader

Send commands M2002, M2003 in sequence to enter bootloader mode.

Reboot DexArm commands


Re-calibrate the initial position

The DexArm HOME position and motion coordinates are based on the initial position. The initial position has been calibrated before leaving the factory. If there is an error in the arm movement, please re-calibrate the initial position according to the following instruction:

1. Adjust the arm to the following position, make sure Axis 1 and Axis 2 is in the maximum position:

2. Send command M889

Advanced commands

page[Marlin] G020 - Inch Unitspage[Marlin] G021 - Millimeter Unitspage[Marlin] M906 - TMC Motor Currentpage[Marlin] M500 - Save Settingspage[Marlin] M501 - Restore Settingspage[Marlin] M502 - Factory Resetpage[Marlin] M503 - Report Settingspage[Marlin] M082 - E Absolutepage[Marlin] M083 - E Relativepage[Marlin] M092 - Set Axis Steps-per-unitpage[Marlin] M200 - Set Filament Diameterpage[Marlin] M400 - Finish Movespage[Marlin] M410 - Quickstoppage[Marlin] M504 - Validate EEPROM contents

Last updated