Skip to content

6. Gcode

UFACTORY Gcode refers to the RS-274 standard and is compatible with LinuxCNC Gcode: http://linuxcnc.org/.

6.1 Interface Overview

  1. Run: Run the Gcode program.
  2. Pause: Pause the running Gcode program.
  3. Save: Save change to Gcode program.
  4. Withdraw: Withdraw 1 step.
  5. File Operation: New, Import, Downlaod, Rename, Delete.
  6. Run: Run 1 gcode command.

6.2 G Command

G CommandFormatDescription
G0G0 X Y Z A B CRapid Move
G1G1 X Y Z A B C FLinear Move
G2G2 X Y Z R P FG2 X Y Z I J K P FArc Move, clockwise arcR-radius, I- X offset, J- Y offset, K- Z offset, P-number of turns, default is 1
G3G3 X Y Z R P FG3 X Y Z I J K P FArc Move, counterclockwise arc
G4Dwell, Unit: s
G17Z-axis, XY-plane
G18Y-axis, XZ-plane
G19X-axis, YZ-plane
G20to use inches for length units
G21to use millimeters for length units
G90absolute distance mode
G90.1absolute distance mode for I, J & K offsets
G91incremental distance mode
G91.1incremental distance mode for I, J & K offsets

6.3 M Command

M CommandFormatDescription
M2/M30end program
M62M62 Pturn on digital output synchronized with motion
M63M63 Pturn off digital output synchronized with motion
M64M64 Pturn on digital output immediately
M65M65 Pturn off digital output immediately
M67M67 E Qset an analog output synchronized with motion
M68M68 E Qset an analog output immediately
P: IONUM(0-15, 0-7: CO0-CO7, 8-15: DO0-DO7)
E: IONUM(0-1), Q: value(0-10)
M100M100 P Qenable or disable the robotP1-enable, P0-disable, Q-joint ID(8 by default, stands for all joints).
M101clear error
M102clear warning
M103M103 Pset mode
M104M104 Pset state
M115M115 P Qset TGPIOP: IONUM 0/1/2/3/4Q: 0/ 1/ 10/ 11   Q0: turn off(low level) tool digital output synchronized with motion(wait=True).
   Q1: turn on(high level) tool digital output synchronized with motion(wait=True).
   Q10: turn off tool digital output immediately(wait=False).
   Q11: turn on tool digital output immediately(wait=False).
M116M116 P Qcontrol the end effectorP1: xArm Gripper, Q-positionP2: xArm Vacuum Gripper   Q0:open(wait=True),Q1:close(wait=True),  Q10:open(wait=False), Q11:close(wait=False)P3: xArm BIO Gripper   Q0: close, Q1: openP4/P5: Robotiq-2F-85 Gripper, Robotiq-2F-140 Gripper,    Q:position(0~255)P11: Lite6 Gripper   Q0:close(wait=True), Q1:open(wait=True),   Q10:close(wait=False),Q11:open(wait=False)P12: Lite6 Vacuum Gripper  Q0:close(wait=True), Q1:open(wait=True  Q10:close(wait=False),Q11:open(wait=False)

6.4 Firmware Request

  • Firmware Version: v2.2.0+
  • Port: 504
  • Response: 5 bytes
  1. byte0: return value. 0 is success
  2. byte1: mode and states
  3. byte2: error code
  4. byte3&byte4: buffer
  • Recommend to send 1-non-empty data at a time(with line breaks)
python
sock.send(b'G0 X300\n')
  • Need to receive the response, otherwise the buffer will be full.
python
sock.recv(5)
  • A maximum of 2000 commands can be accepted.