回复:用FX1N直接带步进电机驱动器的一个例子,
以下是从三菱编程手册上录取的一个例子,让大家研究一下。
X0:STOP
X1:HOME RETURN
X2:JOG+
X3:JOG-
X4:ABSOLUTE POSITIONING TARGET POSITION:500000
X5:ABSOLUTE POSITIONING TARGET POSITION:100
X6:NEAR POINT SIGNAL INPUT
Y0:PULSE OUTPUT
Y4:ROTATION DIRECTION SIGNAL OUTPUT
LD X0 ;STOP SIGNAL INPUT
OUT M8145 ;ON:Y0 PULSE OUTPUT STOP
LDI S0
ANI S10
ANI S11
ANI S12
ANI S13
ANI M8145
OUT M5 ;ORIGIN
LD M8002
DMOV K100000 D8146 ;MAX SPEED
MOV K200 D8148 ;ACCELERATION/DECELERATION TIME
LDP X1 ;HOME RETURN INPUT ,SET S0
AND M5
RST M10
RST M12
RST M13
SET S0
LD X2 ;JOG+,SET S10
AND M5
RST M12
RST M13
SET M10
LD X3 ;JOG- ,SET S11
AND M5
RST M12
RST M13
SET S11
LDP X4 ;ABSOLUTE POSITIONING TARGET POSITION:500000
AND M5
AND M10
RST M12
RST M13
SET S12
LDP X5 ;ABSOLUTE POSITIONING TARGET POSITION:100
AND M5
AND M10
RST M12
RST M13
SET S13
STL S0 ;HOME RETURN
LD M8000
OUT M50
LD M50
DZRN K50000 K5000 X6 Y0 ;K50000 IS ZERO TURN SPEED
LD M8029 ;K5000 IS CREEP SPEED
SET M10 ;X6 IS NEAR POINT SIGNAL
LDI M8147
AND M50
RST S0
RET
STL S10 ;JOG+
LD M8000
OUT M51
LD X2
AND M51
DDRVI K999999 K30000 Y0 Y4
LDI M8147
AND M51
RST S10
RET
STL S11 ;JOG-
LD M8000
OUT M52
LD X3
LD M52
DDRVI K-999999 K30000 Y0 Y4
LDI M8147
AND M52
RST S11
RET
STL S12 ;ABSOLUTE POSITIONING
LD M8029
SET M12
LD M8000
OUT M53
LD M53
DDRVA K500000 K100000 Y0 Y4 ;K500000 IS TARGET POSITION
LDI M8147 ;K100000 IS OUTPUT PULSE FREQUENCIES
AND M53
RST S12
RET
STL S13 ;;ABSOLUTE POSITIONING
LD M8029
SET M13
LD M8000
OUT M54
LD M54
DDRVA K100 K100000 Y0 Y4; ;K100 IS TARGET POSITION
LDI M8147 ;K100000 IS OUTPUT PULSE FREQUENCIES
AND M54
RST S13
RET
END
|