STM32 Controller Program Command Document
STM32 Controller Program Command Document
STM32 Controller Program Command Document
******************************
* Hardware version: CoreV4D2, BASE-BOARDV61, IO-BOARDV6.2;
* Update content: Cancel G04 command, cancel G24 command,
Increase G00 command, immediate value of absolute value, variable; incremental immediate
value, variable
Add 2 formats (angle and radians) Trigonometric operation instructions SIN, COS, TAN, ASIN,
ASOS, ATAN
**************************************************
*****************************/
Serial port parameters: baud rate 115200; data bit 8; stop bit 1.
Instruction format:
The control commands are hexadecimal 0X10 (idle mode), 0X11 (file mode), 0X12 (zero return
mode), 0X13 (run mode), 0X14 (debug mode), 0X15 (reset mode); 0X05 is the interrogation
mode;
The running instructions all start with 'GXX' and end with a carriage return;
The teaching instruction ends with a carriage return and a new line;
In the system version of 180521 and above, when _flagSoftRst=1 is set in the parameter file, the
serial port 1 can send 0X18 to output the output port o14 in any case. According to this function,
the e14 relay control NRST restart (emergency stop).
Instruction description:
//========================================================= ===============
G0n=GGN such as G06 O=P1.1 is equivalent to GG6 O=P1.1
Point-to-point command G00, G20
G00 J1=0 J2=0 J3=-90 J4=0 J5=-90 J6=0 //with acceleration and deceleration absolute joint
position command
G00 J1=VXX J2=0 J3=VXX J4=VXX J5=-90 J6=0 //With acceleration and deceleration Absolute joint
position command
G00 ... J2'4 J3'VXX ... //with acceleration and deceleration relative joint position command
G00 ... J2'4 J3'VXX J4=VXX J5=-90... //J2 is
G20 X=300 Y=100 Z=500 A=0 B=180 C=0 D=0 //with acceleration and deceleration
G20 X=300 Y=VXX Z=VXX A=VXX B=180 C=VXX D=0 //with acceleration and deceleration
G30 EQ01 J1=UXXXX, J2=UXXXX, J3=UXXXX Read memory contents G30 EQ01 J1=U30100
J2=U30120 J3=U30140 J4=U30160
G30 EQ02 U3060=XX.XX Write memory contents G30 EQ02 U30500=10
G30 EQ03 ASK=UXXXX Query memory contents
G30 EQ04 Vxx=UXXXXXX
G30 EQ05 UXXXXXX=Vxx
G40 X=300 Y=100 Z=500 A=0 B=180 C=0 D=0 //No acceleration/deceleration
Arc command G02 G03 G04 G22 G23 G06 DEGREE=ARC (or degree)
When DEGREE=ARC is going to be a three-point arc
Current point: G21 X=200 Y=0 Z=200 A=-180 B=150 C=0 D=0
Second point: G22 X=300 Y=100 Z=200 A=-180 B=150 C=90 D=0
Third point: G23 X=400 Y=0 Z=200 A=-180 B=150 C=300 D=0
Arc running: G06 DEGREE=300
//========================================================= ===============
G06 directive
G06 T=500 delay 500 milliseconds
G06 t=VXX Delay VXX content milliseconds (for example: G08 MOV V400=#2000 G06 t=V400 is a
delay of 2000 milliseconds)
G06 I=P1.1 Wait for P1 to be high
G06 I=P2.0 Wait for P2 to be low
G06 O=P1.1 makes output port P1 high (different port from input port)
G06 O=P2.0 makes the output port P2 low
G06 SCAN=I Read input port value, stored in V144-V150 unit
G06 SCAN=O Read output port value, stored in V160-V166 unit
G06 SCAN=RTC Read system clock value and store it in V176-V179 unit
G06 DEGREE=ARC robot takes a three-point arc
G06 DEGREE=35.2 The robot walks 35.2 degrees
G06 REPOS=J# J# Axis looks for HOME# sensor from angle increase direction (return to low level)
G06 REPOS=-J# J# axis finds HOME# sensor from angle reduction direction (return to low level)
G06 REPOS=J1 J1 axis finds HOME0 sensor from angle increase direction (return to low level)
G06 REPOS=-J1 J1 axis finds HOME0 sensor from angle reduction direction (return to low level)
G06 REPOS=JH# J# Axis finds HOME# sensor from angle increase direction (return to high level)
G06 REPOS=-JH# J# axis finds HOME# sensor from angle reduction direction (return to high level)
G06 REPOS=JH1 J1 axis finds HOME0 sensor from angle increase direction (return to high level)
G06 REPOS=-JH1 J1 axis finds HOME0 sensor from angle decrease direction (return to high level)
//========================================================= ===============
G07 command
G07 VE=250000 speed is 250,000 pulses per second
G07 AC=250000 Acceleration is 250,000 pulses per second squared
G07 DE=250000 Deceleration is 250,000 pulses per second squared
G07 VPP=250000 Maximum speed 250,000 pulses per second
G07 VP=20 Speed VE is 20% of the highest speed, VE=VPP*VP*0.01
G07 vp=VXX Speed VE is the content of the highest speed VXX, VE=VPP*VXX unit value
*0.01
G07 _h0=xx height change
G07 RCM=1 print run command, 0 does not print run command
G07 GCM=1 is output at right angle coordinates when teaching, 0 is joint coordinate output
G07 MARKPOS_HERE X1=0 Y1=0 X2=100 Y2=100 Template MARK point
G07 MARKPOS X1=10 Y1=10 X2=110 Y2=110 Match MARK point
G07 UNIT=1.0 Interpolation accuracy (in mm)
G07 P J#=XXXX calibration J# axis
// =================================================== ================
G08 instruction
G08 XXXX: Tags No comments are allowed after the tags. The length of the tags must be less than
15 bytes.
G08 ACALL XXXX Call XXXX label to G08 END
G08 END call ended
G08 AJMP XXXX Jump to XXXX operation
G08 FLTAB = # file jumps to T_ # file to run;
G08 IF VXX> = VXX ACALL XXXX Integer comparison Immediate number is # comparison> =, <=,
==,! =,>, <; (G08 IF VXX> = VXX AJMP XXXX)
G08 IF_ELSE VXX> = VXX? ACALL XXXX: ACALL XXXX Before the true value runs the colon, after the
false value runs the colon ACALL is the call and AJMP is the jump (G08 IF_ELSE VXX> = VXX?
AMMP XXXX: AJMP XXXX)
G08 IFF floating point comparison
G08 IF_ELSEF floating-point comparison
G08 MOV VXX = # XX Integer transmission (immediate G08 MOV V10 = # 12) (unit G08 MOV V10
= V12)
G08 MOVF VXX = # XX integer transmission (immediate G08 MOVF V10 = # 12.5) (unit G08 MOVF
V10 = V12)
G08 PRINT VXX prints the value of VXX as an integer
G08 PRINTF VXX prints the value of VXX, floating point
G08 ADDF VXX = VXX + VXX Floating point The immediate value is #
G08 SUBBF VXX = VXX-VXX floating point immediate number is #
G08 MULF VXX = VXX * VXX Floating point The immediate number is #
G08 DIVF VXX = VXX / VXX Floating point The immediate value is #
G08 SQRTF VXX = VXX Floating point The immediate value is #
G09 ENC .... It is a special instruction to connect with the absolute value servo motor, refer to the
zero return file example;
// =================================================== ================
VXX: Unit
#XX: Immediate
User arithmetic unit V0-V127, V400-V511
The system has used the computing unit to read the input port value and store it in the
V144-V150 unit.
Read the output port value and store it in V160-V166 unit
Read the system clock value and store it in V176-V179
Sending '0' as stop in running mode or when running G code, it is this instruction when
continuing; '.' Is also stop, it is the next instruction when continuing;
STA real-time key value is stored in V180 unit, key value is stored in V183 unit, V183 is cleared by
software
STO real-time key value is stored in V181 unit, key value is stored in V184 unit, V184 is cleared by
software
RST real-time key value is stored in V182 unit, key value is stored in V185 unit, V185 is cleared by
software
V186: Input port i03 or i04 is cancelled by command. V186 = 0 is not enabled (default), V186 = 1
is enabled.
V187: Limit and servo alarm master switch Not enabled when V187 = 1 (default), enabled when
V187 = 0
V188: Soft limit stop master switch Disabled when V188 = 1 (default), enabled when V188 = 0
V189: Input signal capture master switch Not enabled when V189 = 1 (default), enabled when
V189 = 0
V143: Running pulse width (value range 0 ~ 400, automatically modified)
V142: Pulse width threshold (value range 4 ~ 400, artificial modification)
V141: G41, G06 DGREE smooth value (stop speed, artificial modification)
V140: Speed timing value (automatic change)
(V288 ~ V303: capture time value, unit is millisecond, need to be cleared by software)
FLAGi00: p0 v288
FLAGi01: p1 v289
FLAGi02: p2 v290
FLAGi03: p3 v291
FLAGi04: p4 v292
FLAGi05: p5 v293
FLAGi06: p6 v294
FLAGi07: p7 v295
FLAGi08: P8 v296
FLAGi09: P9 v297
FLAGi10: P10 v298
FLAGi11: P11 v299
FLAGi12: P12 v300
FLAGi13: P13 v301
FLAGi14: P14 v302
FLAGi15: P15 v303
// =================================================== ================
Visual example
G08 CCD2:
G08 MOV V20 = # 0
G08 CCD2A:
G06 T = 401 // RCCD
G08 IF V20 == # 0 AJMP CCD2A
G08 END
When the host computer receives T = 401,
The upper computer sends instructions such as:
G20 X = 300 Y = 200 Z = 270 A = 0 B = 150 C = 0 D = 0 MOV V20 = # 1
G41 X = 300 Y = 200 Z = 270 A = 0 B = 150 C = 0 D = 0 MOV V20 = # 1
// ...................................... .....
Examples of input signals
1, initialization, enable enable ENi07: p7 v263
G08 CSH:
G08 MOV V189 = # 0
G08 MOV V263 = # 1
G08 END
2.Read the captured FLAGi07: p7 v295 value during the run
G08 INSCAN:
G06 T = 500
G08 IF V295> # 400 ACALL ZHOUO14
G08 MOV V295 = # 0
G08 AJMP INSCAN
G08 END
3, capture the v295 value greater than 400 milliseconds, then call ZHOUO14
G08 ZHOUO14:
G06 O = P14.1
G06 T = 400
G06 O = P14.0
G06 T = 400
G06 O = P14.1
G06 T = 400
G06 O = P14.0
G08 END
// =================================================== ================
C language for, while implementation on PFOP
// =================================================== ================
Parameter file
FILE = INI // File path
Parameter.ini // File name
510 // File length (counted from the fourth line to the end)
//// DH_PARAMETER: // DH parameters (unit: mm; h-bit length, d is distance)
_h0 = 203; // can be a dummy value
_d1 = 80;
_h2 = 260;
_d3 = 80;
_h4 = 288;
_h5 = 64.5;
_d6 = 40; // can be a dummy value
//// MOTOR_DIR: // Motor direction
_dir1 = -1;
_dir2 = 1;
_dir3 = 1;
_dir4 = -1;
_dir5 = 1;
_dir6 = -1;
//// JOINT_PUL: // Organization breakdown
_j1pul = 320000; // The mechanism needs 320000 pulses per circle
_j2pul = 326400;
_j3pul = 326400;
_j4pul = 320000;
_j5pul = 320000;
_j6pul = 320000;
//// VELOCITY:
_ac = 100000.0; // Acceleration
_de = 100000.0; // Deceleration
_vpp = 100000.0; // Full speed
_vp = 10; // speed degree
//// MODE:
_pve = 8.887 // Not used
_getCodeMode = 0; // 0 means teach for joint output, 1 teach for right angle output
_runCodeMode = 1; // 1 is the printing code, 0 is not printing the code
_prmTPUL = 120; // Pulse maximum width adjustment threshold (4 ~ 400) (V142)
_prmVLIM = 2000; // G41 smoothing value (V141)
// REPOS // ======== power-on default angle =======
_rePosJ1 = 0;
_rePosJ2 = 0;
_rePosJ3 = -90;
_rePosJ4 = 0;
_rePosJ5 = -90;
_rePosJ6 = 0;
// IRQ // ========== Interrupt switch ===========
_iIRQ = 1 // Inductor limit enable switch: _iIRQ = 1 enable off, _iIRQ = 0 enable on, default 1;
_sIRQ = 1 // Soft limit enable switch: _sIRQ = 1 enable off, _sIRQ = 0 enable on, default 1;
_flagSoftRst = 1 // Serial port restart controller enable: _flagSoftRst = 1 enable on, _flagSoftRst =
0 enable off, default 0;
_brkMotorEn = 0 // brake enable: _brkMotorEn = 1 enable on, _brkMotorEn = 0 enable off,
default 1;
// LIMIT // ========== software limit ===========
_sLp0 = 175 // Software positive limit angle of the 1st axis
_sLn0 = -175 // Software negative limit angle of the 1st axis
_sLp1 = 90 // The second axis limit angle
_sLn1 = -90 // The second axis limit angle
_sLp2 = 30 // 3rd axis limit angle
_sLn2 = -180 // 3rd axis limit angle
_sLp3 = 175 // 4th axis limit angle
_sLn3 = -175 // 4th axis limit angle
_sLp4 = 120 // 5th axis limit angle
_sLn4 = -120 // 5th axis limit angle
_sLp5 = 359 // The 6th axis limit angle
_sLn5 = -359 // The 6th axis limit angle
Progaram Case
FILE=ST
AM.ST
1719 //Sequence number of the program
code:
G07 VP=20 //Speed set to 20%
G00 J1=0 J2=0 J3=-90 J4=0 J5=-90 J6=0 //Run to door position
G20 X=300 Y=131 Z=55 A=0 B=180 C=0 D=0 //Run to a location
G06 O=P0.1 //Turn on output 00
G20 X=300 Y=131 Z=20 A=0 B=180 C=0 D=0 //Run to a location
G06 O=P0.0 //Turn off output 00
G06 T=500 //Delay 500 ms
G00 J1=0 J2=0 J3=-90 J4=0 J5=-90 J6=0 //Back door position
G08 EXIT //Exit the loop,Program ends