1第5章步进顺控指令•5.1步进梯形图指令与状态转移图–5.1.1步进梯形图指令–5.1.2状态转移图和步进梯形图–5.1.3SFC图和STL图编程注意事项–5.1.4状态转移条件的有关处理方法•5.2SFC图的跳转与分支–5.2.1SFC图的跳转–5.2.2SFC图的分支2第5章步进顺控指令•5.1步进梯形图指令与状态转移图•5.1.1步进梯形图指令•步进梯形图指令STL(StepLadder)和RET,是一种符合IEC1131—3标准中定义的SFC图(SequentialFunctionChart顺序功能图)的通用流程图语言。顺序功能图也叫状态转移图,相当于国家标准“电气制图”(GB6988.6-86)的功能表图(FunctionCharts)。•SFC图特别适合于步进顺序的控制,而且编程十分直观,方便,便于读图,初学者也很容易掌握和理解。RETSTLSTLRET或指令梯形图符号步进指令步进结束指令可用软元件S表5-1步进梯形图指令35.1.2状态转移图和步进梯形图X3Y0S20S0M8002X0X1S0X3S20S0M8002X0X1SETSETY0S20(c)指令表(步进梯形图)(状态转移图)(a)SFC图(b)STL图STLANDOUTLDSTLS0S20Y0SETSETX3X0M8002S0S20LD初始状态步状态步转移条件转换条件转换条件驱动负载RETLDX1主母线副母线图5-1SFC图的三种表达方式4送料车自动循环控制图5-2送料车自动循环控制图X0X1X2X3COMSBSQ1SQ2SQ3(b)送料车自动循环控制PLC接线图KM1Y1Y0KM2ABOX2X3X1SQ1SQ2SQ3X0(a)送料车自动循环示意图进退原位(A点)(B点)起动电源起动KM1KM2Y1Y0进退COM15图5-3送料车自动循环控制程序X3X0X2X0S20S21S22S23S0M8002X0X1(c)指令表(步进梯形图)(状态转移图)(a)SFC图(b)STL图OUTOUTOUTOUTSTLSTLSTLLDLDLDLDENDRETS23原位SET原位Y1原位Y0(A点)S22(B点)X0起动SETS0S21SETY1S23S22S21X0X2X1S0步进梯形图结束ENDRET起动(B点)(A点)原位原位原位X3X2X0S20S21S22S23S23S0SETM8002X0X1SETSETS22X0SETS0S21S20SETY0Y1Y0Y1进退进退Y0Y1Y0Y1进退进退STLANDOUTLDSTLS0S20Y0SETSETX3X0M8002S0S20LD6图5-4增加控制信号的运料车PLC梯形图图5-5增加控制信号的运料车PLC接线图与主接线图X3Y0X0Y1X2Y0X0Y1S20S21S22S23S0M8002进退进退X0X1(状态转移图)(a)SFC图原位原位原位(A点)(B点)起动X6X6单循环连续循环(C)总梯形图(b)梯形图S0步进梯形图结束ENDRET起动(B点)(A点)原位原位原位X3X2X0S20S21S22S23S23S0SETM8002X0X1SETSETS22X0SETS0S21S20SETY0Y1Y0Y1进退进退S20X6X6ZRSTS20S23M8034M8034X3X4X5暂停X0X4Y1退ZRSTS20S23M8034M8034X3X4X5暂停X0X4Y1退X4X4手动回原位X0X1X2X3COMSB1SQ1SQ2SQ3KM1Y1Y0KM2进退原位(A点)(B点)起动电源KM1KM2SB2停止后退单次/连续SB3SAX4X5X6FRQS(a)运料车PLC控制接线图之二FU1KM1KM2FRM3~QSFU2(b)主接线图接PLCL1L2L3NCOM175.1.3SFC图和STL图编程注意事项Y0Y0Y2T1T1T1K300K100K250T1S20S21S22X0X1X2X3Y0Y2T1C1K300K2T1S20S21S22X1X2X3T1Y0Y1Y2Y3Y4Y2Y1M0SETY0RSTM1M2M3Y0T1K300X2Y1SETT1X3Y0M0S21SETC1K2S20S21S22T1Y2Y3Y2Y1Y0RSTX1M1M2S20S21S22SETSETY2Y4M3S25S25主母线副母线副母线副母线副母线副母线副母线接点组接点组连续步连续步连续步不连续步不连续步MPS、MRD、MPPMPS、MRD、MPP图5-6编程说明1图5-7编程说明285.1.4状态转移条件的有关处理方法•1、相邻两个状态步的转移条件同时接通时的处理S0S20S21RSTC0Y0T0C0K5K30S20X0X1M8002T0C0旋转S0S20S21RSTC0Y0T0C0K5K30X0X1M8002T0C0旋转PLSPLSM0M1M0M1(b)SFC图1(c)SFC图2起动按钮起动按钮限位开关限位开关SQ(a)圆盘示意图X1限位开关Y0X0起动按钮图5-8相邻两个状态步的转移条件同时接通时的处理92、利用同一信号的状态转移S0PLSX1M8002限位开关M0S20PLSY0X0正转起动按钮M1S21PLSY1反转M1S22PLSY1反转M2M3M2M3M0M0M0S0X1M8002限位开关S20Y0X0正转起动按钮S21Y1反转S22Y1反转M2800M2800M2800M2800SQ(a)圆盘示意图X1限位开关Y0(b)SFC图1(c)SFC图2X0起动按钮图5-9利用同一信号的状态转移例5-1圆盘旋转控制用PLC控制一个圆盘,圆盘的旋转由电动机控制。要求按下起动按钮后正转1圈,反转2圈后停止。103、用多个边沿接点作转移条件•用多个边沿接点作转移条件时,会出现一种特殊现象。X3S21X1S20SETY0X0S21X3S21S20SETY0M0S21X1X0M0(a)(b)图5-10用多个边沿接点作转移条件115.2SFC图的跳转与分支•5.2.1SFC图的跳转•SFC图的跳转有如下几种形式,•1、向下跳:•2、向上跳:•3、跳向另一条分支:•4、复位:S0S20S21S22跳转重复重复S0S20S21S22JumpJumpJumpS0S20S22*S1S30S31S32S0S20S21S22OUTOUTOUTOUTOUTRSTS0S20S21S22JumpJumpS21S31*S1S30S31S32ResetS32*跳转复位X0X1X2X3X4X5X6X7X4X10X11X12X13X14X15(a)(b)(c)(d)图5-11跳转的形式12例5-2小车运行控制•一辆小车在A、B两点之间运行,如图5-12所示。在A、B两点分别设有后限位开关SQ2和前限位开关SQ1,小车在A、B两点之间时可以控制小车前进或后退。小车运行后,在A、B两点之间自动往返运行,在B点要求停留10秒钟。SQ1SQ2后限位前限位X6X5Y0Y1后退前进AB图5-12小车运行示意图13Y0Y1后退前进结束停后限位前限位X0X1X5X6后退前进T0K100T0S0S20S21S22跳转重复重复X3QS~SQ1SQ2后限位前限位KM1KM2KM1X0X1X2X3X4X5立即停X6Y0Y1(急停)暂停后退KM2前进结束停COMCOM1SB0SB1SA1SA2SB2后退前进X3(b)小车运行SFC图(a)PLC接线图图5-13小车运行PLC接线图和SFC图14Y1后退后限位前限位X0X1X5后退前进T0K100T0S0S20S21S22Y0前进SETSETSETS0S20S21S22X6S20RETENDS22S0S20S21S22JumpJumpJumpS0S20S22JumpJumpJumpX2M8002SETS0X3X4立即停暂停ZRSTS20S22M8034X3结束停X6*(c)SFC图(a)步进梯形图(b)梯形图图5-14小车运行梯形图和SFC图155.2.2SFC图的分支S23S24S26S27S28X2X3X4X5Y1Y3X2X6Y2Y4Y5S22Y0(a)状态转移图(c)指令表S23S24S26S27S28X2X3X4X5Y1X2Y2Y4Y5S22Y0SETSETS23Y3SETS24SETS28X6S26SETS27SETS28(b)步进梯形图S24S27SETSETSETSETSETSETSTLSTLSTLSTLSTLSTLS23S24S26S27S28S28S22S23S24S26S27S28OUTOUTOUTOUTOUTOUTLDLDILDLDLDLDLDY0Y1Y2Y3Y4Y5X2X3X4X5X6X2STLS27STLS24左分支右分支选择分支选择合并左分支右分支选择分支选择合并图5-15选择分支单分支选择分支并行分支混合分支状态转移图可分为选择分支16图5-16并行分支并行分支S23S24S26S27S28X2X3X4X5Y1Y2Y4Y5S22Y0SETSETS23Y3SETS24SETS26SETS27S28S23S24S26S27S28X2X3X4X5Y1Y3Y2Y4Y5S22Y0S24S27SETSETSETSETSETSTLSTLSTLSTLSTLSTLS23S24S26S27S28S22S23S24S26S27S28OUTOUTOUTOUTOUTOUTLDLDLDLDLDY0Y1Y2Y3Y4Y5X2X3X4X5STLSTLS24S27(a)状态转移图(b)步进梯形图(c)指令表左分支右分支并行分支并行合并左分支右分支并行分支并行合并17S23S24S26S27S28X2X3X4X5Y1Y3X2X6Y2Y4Y5S22Y0S29Y6S23S24S26S27S28X2X3X4X5Y1Y3Y2Y4Y5S22Y0S28X10Y6X6X7X7(a)混合分支1(b)混合分支2图5-17混合分支混合分支18•一个传送机械手装置如图5-18所示,用于分捡大球和小球。机械臂原始位置在左限位,电磁铁在上限位。接近开关SQ0用于检测是否有球。SQ1~SQ5分别用于传送机械手上下左右运动的定位。•起动后,当接近开关检测到有球时电磁杆就下降,如果电磁铁碰到大球时下限位开关不动作,如果电磁铁碰到小球时下限位开关动作。电磁杆下降2秒后电磁铁吸球,吸球1秒后上升,到上限位后机械臂右移,如果吸的是小球,机械臂到小球位,电磁杆下降2秒电磁铁失电释放小球,如果吸的是大球,机械臂就到大球位,电磁杆下降2秒,电磁铁失电释放大球,停留1秒上升,到上限位后机械臂左移到左限位,并重复上述动作。•如果要停止,必须在完成一次上述动作后到左限位停止。SQ1SQ2SQ3SQ4SQ5SQ0接近开关上限位下限位小球位大球位左限位上移下移电磁铁X0X1X2X3X4X5X6X7启动停止Y0Y1Y2Y3Y4Y5原位指示M右移左移图5-18大小球分捡传送机械手装置示意图例5-3传送机械手19S0S21S22S23S24S25S26S27S28S29S30S31松开Y1X0X1X2X3X4X5X6X7Y0Y1Y2Y3Y5SET接近开关上限位下限位小球位大球位左限位上移下移电磁铁起动停止原位指示T1K10T2K10T0K20X7Y5X2X3RSTY1Y2Y3SET上限位下限位上移电磁铁T1K10Y0下移T0T1T2Y1Y2Y4T1X1X2X3YAYV4YV3YV2YV1HLCOM2COM1COM上移+24VX3SA上限位SB左移上限位右移左限位原位指示右移Y5左移Y4松开Y3吸小球Y2吸大球Y1右移Y0下限位停止原位起动连续X7M8002X6X5X4X3X2X1X0电磁铁下移上移左限位大球位小球位下限位上限位接近开关SQ0SQ5SQ4SQ3SQ2SQ1~QS小球分支→大球分支→手动控制梯形图图5-19大小球分捡传送PLC接线图及SFC图YAKM2KM1YV2YV1HLCOM2COM1COM+24VSASB左移右移原位指示Y5Y4Y3Y2Y1Y0停止起动X7X6X5X4X3X2X1X0电磁铁下移上移左限位大球位小球位下限位上限位接近开关SQ0SQ5SQ4SQ3SQ2SQ1~QSKM2KM120