CPM1A的指令系统.ppt

上传人:小飞机 文档编号:5423601 上传时间:2023-07-05 格式:PPT 页数:351 大小:5.32MB
返回 下载 相关 举报
CPM1A的指令系统.ppt_第1页
第1页 / 共351页
CPM1A的指令系统.ppt_第2页
第2页 / 共351页
CPM1A的指令系统.ppt_第3页
第3页 / 共351页
CPM1A的指令系统.ppt_第4页
第4页 / 共351页
CPM1A的指令系统.ppt_第5页
第5页 / 共351页
点击查看更多>>
资源描述

《CPM1A的指令系统.ppt》由会员分享,可在线阅读,更多相关《CPM1A的指令系统.ppt(351页珍藏版)》请在三一办公上搜索。

1、回到主目录,Instruction set of CPM1A serials PLC,掌握PLC的基本指令、编制梯形图的注意事项;掌握分支程序的处理方法;掌握定时器/计数器指令;数据比较CMP指令;数据传送MOV等指令。能够读懂梯形图程序和语句表程序,并能够互相转换;能够编写简单的梯形图程序。,3-1 概述 outline,1.CPM1A指令分类,直接对输入、输出进行操作。,进行数据处理、运算和程序控制等操作。,基本指令,应用指令,1.CPM1A Instruction classification,Operate input and output directly,do the follow

2、ing operations:data processing,operation and program control,Basic instructions,Application instructions,2.CPM1A指令格式,助记符(指令码)操作数1 操作数2 操作数3,助记符:表示指令的功能,指令码:是指令的代码,操作数:提供指令执行的对象或数据,2.CPM1A instruction format,助记符(instruction code)operand 1 operand 2 operand 3,助记符:specify instruction functionality,inst

3、ruction code:the codes of instruction,Operand:supply the object or data that instruction executes,操作数可以是通道号、继电器号或常数。,操作数的个数,取决于各种指令的需要。,关于操作数的讨论,操作数设为常数时,在数据前面要加#号。,operand can be channel number,relay number,or constant,the number of operand lies on all kinds of instructions.,discussion about operan

4、ds,When operand is set to be constant,a#should be added before the data.,操作数采用哪种进制,取决于指令的需要。,间接寻址的操作数用*DM来表示。,间接寻址的操作数,是以DM中的数据为地址的另一个DM通道中的数据。,DM中 的 内容 必须是BCD码,且不得超出 DM区的范围。,which system the operand use,lies on the instructions.,operands of indirect addressing is denoted with*DM,Operands of indirec

5、t addressing is the data in another DM channel of whose address is the data in DM.,The content of DM must be BCD code,and should not exceeds the range of DM section.,例如,计数器指令的格式为 CNT000 SV,If SV=200,表明000号计数器的设定值是200通道中的内容。indicate that the value of 000 counter is the content of 200 channel.,if SV=#

6、0200,表明000号计数器的设定值是常数200。Indicate the value of 000 counter is constant 200.,For example,the format of counter instruction is,例如:计数器的指令格式为 CNT000*DM1000,设DM1000的内容为0010,则 000号计数器的设定值是2500,设DM0010的内容为2500,如果设DM1000的内容为9990,如果设DM1000的内容08FA,超出DM范围,非BCD码,DM0000DM1023、DM6144DM6655,间接寻址的操作数。,For example:t

7、he counter instruction format is CNT000*DM1000,suppose the content of DM1000 is 0010,then the value of 000 counter is 2500,suppose the content of DM0010 is 2500,if the content of DM1000 is 9990,is the content of DM1000 is 08FA,Exceed DM range,Non BCD code,DM0000DM1023、DM6144DM6655,Operand of indirec

8、t addressing,3.执行指令对标志位的影响,SR区的2550325507是指令执行结果的标志位。,某些指令的执行结果影响标志位2550325507的状态。,标志位25503 25507的状态表示的意义要牢记。,p.30,3.influence on flag bit,2550325507 in SR section is the flag bits of instruction execution results,Certain instruction execution results have effect on the status of 2550325507 flag bit

9、s,Keep in mind the meaning of 25503 25507 flag bits,p.30,ER(25503):出错标志位。25503 ON时,表示当前执行的程序出错且停止执行。CY(25504):进位标志位GR(25505):大于标志EQ(25506):等于标志LE(25507):小于标志,当执行指令END(01)时,以上标志均置为OFF,ER(25503):error bit。When 25503 is ON,indicate the program being executing go error and stop running.CY(25504):carry b

10、itGR(25505):greater than bitEQ(25506):equal bitLE(25507):less than bit,4.指令的微分、非微分形式,微分型:要在指令的助记符前加标记。,两种指令的区别,4.differential and non-differential form,Differential form:add marker before 助记符,Differences between two forms,非微分型指令:,只要其执行条件为ON,每个扫描周期都执行该指令。,微分型指令:,仅在指令的执行条件由OFF变为ON时才执行一次。,Non-different

11、ial instructions:,As long as execution condition is ON,this instruction is executed every scanning period.,differential instructions:,Only execute once when the executing condition turn from OFF to ON,3-2 基本指令,LD 和 LD NOT 指令,LD:常开触点与母线相连,LD NOT:常闭触点与母线相连,不影响标志位,LD、LD NOT只能以位为单位进行操作,功能,3-2-1 常用的基本指令,

12、LD and LD NOT,LD:opening spot connected with generatrix,LD NOT:closing spot connected with generatrix,Do not affect flag bits,LD、LD NOT can only be operated in bit,function,3-2-1 frequently used basic instructions,2.OUT 和 OUT NOT 指令,功能,OUT:指令输出逻辑运算结果,OUT NOT:逻辑运算结果取反后输出,OUT、OUT NOT:只能以位为单位进行操作,不影响标志

13、位,IR,SR,HR,AR,LR,TC,TR,2.OUT and OUT NOT,function,OUT:output logic calculation results,OUT NOT:output logic calculation results after reversed,OUT、OUT NOT:can only do operation in bit,Do not affect flag bits,IR,SR,HR,AR,LR,TC,TR,(1).若输出位为PLC的输出点,则运算结果输出到PLC外部 若输出位为PLC的内部继电器,则运算结果为中间结果,不输出到PLC外部。if t

14、he output bit is PLC output point,calculation result output to PLC exterior.If output bit is PLC internal relay,calculation result is midway result without being output to the exterior.,(2).线圈并联输出时,可以连续使用OUT、OUT NOT。when the loop output in parallel,OUT、OUT NOT can be used in series.,说明note,例:,LD 000

15、00OUT 01000OUT NOT 01001LD NOT 00001OUT 01002,连续使用,3.AND,AND NOT,function,AND:表示常开触点与前面的触点电路相串联,或者说AND后面的位与前面的状态进行逻辑“与”运算。,IR,SR,HR,AR,LR,TC,TR,AND:denote opening spot connected with anterior spot in series,that is to say,the bit after AND does logic“and”operation with anterior status.,AND NOT:表示常闭触

16、点与前面的触点电路相串联,或者说AND NOT后面的位取“反”后与前面的状态进行逻辑“与”运算。,AND NOT:denote closing spot connect,that is to say,the bit after AND NOT get reversed and do logic“and”operation with the former status.,例:,LD 00000AND 00001OUT 01000LD 00000AND NOT 01000OUT 01001,说明note,(1).AND、AND NOT只能以位为单位进行操作,且不影响标志。AND、AND NOT c

17、an only be operated in bit,and do not affect flag.,(2).串联的触点数没有限制。No limitation with series-wound spot numbers.,例:两种输出形式,以上两图逻辑功能相同,但是(b)图用语句表编程繁琐,应尽量避免。,(a)连续输出 LD 00000 AND 00001 OUT 01000 AND 00002 OUT 01001,(b)连续输出次序颠倒 LD 00000 AND 00001 AND 00002 OUT 01001 LD 00000 AND 00001 OUT 01000,连续输出,For

18、example:two output forms,(a)连续输出 LD 00000 AND 00001 OUT 01000 AND 00002 OUT 01001,(b)连续输出次序颠倒 LD 00000 AND 00001 AND 00002 OUT 01001 LD 00000 AND 00001 OUT 01000,output in series,The above figures have the same logic functionality,but(b)using sentence table program which is trivial and should be avo

19、ided.,4.OR,OR NOT,function,OR:表示常开触点与前面的触点电路相并联,或者说OR后面的位与前面的状态进行逻辑“或”运算。,IR,SR,HR,AR,LR,TC,TR,OR:denote open spot connected with the anterior spot in parallel,that is to say,the bit after OR do“OR”operation with former status.,OR NOT:表示常闭触点与前面的触点电路相并联,或者说OR NOT后面的位取“反”后与前面的状态进行逻辑“或”运算。,说明(1).OR、OR

20、NOT只能以位为单位进行操作,且不影响标志。(2).并联的触点数没有限制。,note(1).OR、OR NOT can only be operated in bit,and do not affect flag.(2).No limitation with series-wound spot numbers.,OR NOT:denote closing spot connected with the anterior circuit in parallel,that is to say,the bit after OR NOT get reversed and then do logic“O

21、R”operation with the former status.,LD 00000OR 00001OUT 01000LD 00000OR NOT 00003OUT 01001,例:,5.结束指令END(01),功 能,表示程序结束。是程序的最后一条指令。END(01)后面的指令一概不执行。,利用END指令插在各程序段之间,可以进行分段调试。,无执行条件,5.END(01),function,Without execution condition,its the last instruction of a program,denoting the end of a program,inst

22、ructions after END(01)are not executed without exception.,Using END instruction which is inserted between program sentences,to debug section by section.,若程序中没有END指令,则PLC不执行程序,并显示出错信息:“NO END INST”。,执行END指令时,ER、CY、GR、EQ、LE标志置为OFF。,PLC does not execute program without the instruction END,and display t

23、he sentence:“NO END INST”。,When the instruction END executes,ER、CY、GR、EQ、LE flag bits are set OFF,6.空操作指令NOP(00),无梯形图符号、无操作数,功能:用来取消某一步操作。常用于修改梯形图。,改为:,LD 00000AND 00001OUT 01000,LD 00000NOP(00)OUT 01000,使步序号变更更少。,例如:,6.NOP(00),Convert to:,LD 00000AND 00001OUT 01000,LD 00000NOP(00)OUT 01000,Make ste

24、p sequence much less,example:,Function:to cancel a certain operation,commonly used to modify trapezoid diagram.,without trapezoid diagram symbol and operand,1.AND LD,功能:用于逻辑块串联连接,即对逻辑块进行逻辑“与”的操作。,3-2-2 AND LD,OR LD,Function:be used to logic block series connection,that is to do logic“and”operation o

25、n logic blocks.,(1).每个逻辑块都以LD或LD NOT 指令开始。(2).AND LD指令单独使用,后面没有操作数。(3).使用这条指令有两种方法:分置法和后置法。两种方法可以得到相同的运算结果,但使用分置法时触点组数是没有限制的,而采用后置法时触点组数不能超过8。,注 意note,(1).Every logic block starts with LD or LD NOT(2).AND LD is employed solely without operand.(3).two usage of this instruction:分置法and后置法.The same resu

26、lts can be obtained using the two methods,but there is no restrictions on the numbers of spot,while the numbers is limited within 8 when the latter method applied.,例:,方法1:分置法,方法2:后置法,LD 00000AND 00001OR NOT 00002LD 00003OR 00004AND LDLD 00005OR NOT 00006AND LDOUT 20000,LD 00000AND 00001OR NOT 00002L

27、D 00003OR 00004LD 00005OR NOT 00006AND LDAND LDOUT 20000,对逻辑块多少无限制,AND LD前面的逻辑块数少于8,No restriction on the numbers of logic blocks,The numbers of logic block before AND LD is less than 8,2.OR LD,功能:用于逻辑块并联连接,即对逻辑块进行逻辑“或”的操作。,function:be used to logic block parallel connection,that is to do“OR”operati

28、on on logic blocks.,注 意note,(1).每个逻辑块都以LD或LD NOT 指令开始。(2).OR LD指令单独使用,后面没有操作数。(3).使用这条指令有两种方法:分置法和后置法。两种方法可以得到相同的运算结果,但使用分置法时触点组数是没有限制的,而采用后置法时触点组数不能超过8。,(1).Every logic block starts with LD or LD NOT(2).OR LD is employed solely without operand.(3).two usage of this instruction:分置法and后置法.The same re

29、sults can be obtained using the two methods,but there is no restrictions on the numbers of spot,while the numbers is limited within 8 when the latter method applied.,例:,方法1:分置法,方法2:后置法,LD 00000AND NOT 00001LD 00002AND 00003OR LDLD NOT 00004AND NOT 00005OR LDOUT 01001,LD 00000AND NOT 00001LD 00002AND

30、 00003LD NOT 00004AND NOT 00005OR LDOR LDOUT 01001,例:利用以上指令对复杂梯形图编程example:make program for complex trapezoid diagram using above mentioned instructions,先找出逻辑块,LD 00000OR 00001AND NOT 00002LD 00005AND NOT 00006OR LDLD 00007AND 00008OR LDLD 00003AND 00004OR 20002AND LDLD 20000AND 20001OR LDOUT 01005,

31、Firstly,find out logic block,SET:当执行条件为ON时,使指定的继电器置位ON且保持。当执行条件为OFF时,指定的继电器不改变原状态。,3-2-3置位(SET)和复位(RESET)指令,function,SET:when execution condition is ON,set ON for specified relay and hold.When execution condition is OFF,the specified relay dose not change.,RESET:当执行条件为ON时,使指定的继电器复位为OFF。当执行条件为OFF时,指定

32、的继电器不改变原状态。,LD 00000SET 20000LD 00003RESET 20000,RESET:when execution condition is ON,set OFF for specified relay.When execution condition is OFF,the specified relay dose not change.,3-2-4 KEEP(11),功 能,当 S=ON,R=OFF时,继电器N保持为ON状态,即使S由ON变为OFF,继电器N的ON状态也不变。,when S=ON,R=OFF,relay N keeps ON status,even i

33、f S changes from ON to OFF,the ON status of relay N,Set input,reset input,LD 00002LD 00003KEEP(11)HR00000,当 R=ON时,继电器N的状态为OFF,when R=ON,relay N status is OFF,(1).KEEP(11)指令功能和SET、RESET指令的功能类似,但KEEP指令是一个整体,中间不允许插入任何指令。,注 意note,(1).The functionality of KEEP(11)is similar with that of SET、and RESET,but

34、 KEEP is a whole,any instructions are forbid to plug in.,(2).KEEP(11)指令完成一个起停保电路的功能。,(3).当用KEEP(11)指令对保持继电器编程时,可实现断电保持的功能。When program for hold relay using the instruction KEEP(11),power down hold functionality can be achieved.,3-2-5 上升沿微分指令DIFU(13)下降沿微分指令DIFD(14),3-2-5 rising edge differential inst

35、ruction DIFU(13)descending edge differential instruction DIFD(14),DIFU(13):when execution condition changes from OFF to ON,specified relay N is ON during one scanning period.,DIFD(14):执行条件由ON变为OFF时,指定继电器N在一个扫描周期为ON。,DIFD(14):when execution condition changes from ON to OFF,specified relay N is ON dur

36、ing one scanning period,DIFU(13)和 DIFD(14)指令的接通时间只有一个扫描周期。The ON duration of DIFU(13)and DIFD(14)is only one scanning period.,1.梯形图的每一行都是从左侧母线开始,线圈和指令应放在最右边。,3-2-6 基本编程规则和编程方法,2.线圈和指令不能直接与左侧母线连接(除少数没有执行条件的指令,如END等)。如果必须时,可以通过SR区的常ON标志25313的触点连接。,一.基本编程规则,错误,正确,一.basic program rules,wrong,right,3-2-6

37、 basic program rules and techniques,1.Each line of trapezoid diagram start from nearside generatrix,loop and instruction should be put on right side.,2.Loop and instructions should not be connected with nearside generatrix directly(except for few instructions without execution condition,such as END)

38、.If must can connect via the spot of ON flag 25313 in SR section.,3.在同程序中,同一编号线圈使用2次或多次,称为双线圈输出。这时前面的输出无效,最后一次输出才是有效输出,因此尽量避免出现双线圈输出。,4.触点不能画在垂直路径上,5.梯形图以END指令结束,否则不执行。,双线圈输出易引起逻辑分析上的混乱Double-loop output is apt to bringing logic analysis disorder,设:00000为ON,20000为OFF,01000最终为OFF,第一支路:01000得电,第二支路:01

39、001得电,第三支路:01000失电,01001 ON,01000 OFF,设:00000为ON,00001为OFF,,从第二支路看,01001要想得电01000必须为ON,由此看出上图逻辑混乱。For the second branch,if 01001 is ON,01000 must be ON,so the above circuit figure is logically disorder.,4.触点不能画在垂直路径上,二.基本编程方法,1.指令和线圈可以并联输出。,2.触点组与触点相并联时,将单个触点放在下面。(节省一个OR LD语句)图3.13,3.并联触点组与几个触点相串联时,

40、并联触点组放在左面。(节省一个AND LD语句)图3.14,3.When parallel spot set connect with several spots in series,parallel spot set is laid left(save one AND LD sentence)figure 3.14,4.若一条指令在PLC上电后只执行一次,则将SR区的25315作为执行条件。,5.若有些梯形图难以用语句表编程,可以重新根据逻辑关系安排梯形图结构,使之能够用基本指令的语句表编程。如图3.16,6.当某梯级有两个分支时,若其中一条分支从分支点到输出线圈之间无触点,该分支应放在上方

41、,这样可以使语句表的语句更少(连续输出)。,7.尽量使用操作数少,执行时间短的指令,以缩短扫描周期,提高I/O响应速度。,3-3-1 分支/分支结束指令(IL(02)/ILC(03)),若IL的执行条件为 ON,位于IL和ILC之间的程序正常执行。,功能:用来处理梯形图中的分支电路,IL和ILC一起使用。,3-3 常用的应用指令 commonly used application instructions,若IL的执行条件为OFF,位于IL和ILC之间的程序不执行。此时IL和ILC之间各内部器件的状态为:所有OUT和OUT NOT输出位为:OFF所有定时器:复位所有计数器、移位寄存器、有保持功

42、能指令的操作位都保持以前状态,if the execution condition of IL is OFF,the program between IL and ILC does not execute.Here,the status of every internal equipments between IL and ILC is:All OUT and OUT NOT output bits:OFFAll timers:resetAll counters,shift registers,operation bits with hold functionality keep the fo

43、rmer status.,(1).不论IL前面的执行条件为OFF或ON,PLC都要对ILILC中间的程序进行处理,要占用扫描时间。(2).IL和ILC可以成对使用,也可以多个IL指令配一个ILC指令,但不允许嵌套。IL-IL.ILC(允许)IL ILILC ILC(不允许),使用分支/分支结束指令(IL(02)/ILC(03))时应注意:,Be careful when using branch/branch end instructions(IL(02)/ILC(03)):,(1).No matter the former execution condition of IL is OFF o

44、r ON,PLC should transact the program between IL and ILC,which will take up scanning time.(2).IL and ILC can be used in pair,or several IL instructions match one ILC,but no nesting allowed.IL-IL.ILC(allowed)IL ILILC ILC(unallowed),例1:分支电路如下:Branch circuit is as follows,LD 00000IL(02)LD 00001OUT 01000

45、LD NOT 00002OUT 01001LD 00003AND NOT 00004OUT 01002ILC(03)LD 00005OUT 01003,可见,00000为后面3个分支的执行条件Obviously,00000 is the execution condition of the following three branches.,例2:分支电路如下:,LD 00000IL(02)LD 00001OUT 01000LD 00002IL(02)LD 00003OUT 01001LD 00004OUT 01002ILC(03)LD 00005OUT 01003,说明:连锁嵌套,多个IL公

46、用一个ILC,在程序检查时会出现错误信息,但不影响程序执行。Declaration:chain nesting,several ILs use one ILC,error info will come out when program checked,yet without affect program running.,注意区别并联输出、连续输出和复合输出的结构及其编程方法,并联输出,连续输出,输出线圈并联Output loop in parallel,上支路无触点;下支路有触点。Upper branch has spot;Lower branch has not,输出为并列关系,执行条件均

47、为00000Outputs are in parallel relationship,all execution condition is 00000,后一个触点支路与前一个触点为“与”关系The latter spot branch and the former one is in“AND”re,Pay attention to differentiating the structures and program techniques of parallel output,serial output and compound output.,IL,复合输出compound output,分支

48、点上下支路均有触点both upper and down branches of branch point have touch points,用分支指令use branch instruction,3-3-2 暂存继电器TR(TR0TR7),处理梯形图的另一种方法。把一个TR置于一个分支点处,则当前结果就会存在指定TR中。,LD 00000OUT TR0AND 00001OUT 01000LD TR0AND 00002OUT 01001LD TR0AND 00003OUT 01002,another method of dealing with trapezoid diagram.put o

49、ne TR at one branch point,and the current result stored at TR.,(1).同一程序段中,同一个TR号不能重复使用;在不同程序段中,同一个TR号可以重复使用。(2).TR不是编程指令,只能和LD或OUT等指令一起使用。,说明,3-3-3 跳转/跳转结束指令(JMP(04)/JME(05)),.当 JMP N 的执行条件为OFF时,跳过JMP N 和JME N 之间的程序段,转去执行JME N 后面的程序。JMP N 和JME N 之间的所有输出、定时器和计数器的状态保持不变,JMP 和JME之间的程序不执行,不占用扫描时间。.当 JMP

50、 N 的执行条件为ON时,执行JMP N 和JME N 之间的程序段。,.when JMP N executing condition is OFF,jump over the program segment between JMP N and ME N,and execute the program segment behind JME N.all the output between JMP N and JME N,state of timer and counter keep unchanged.no execution of the program between JMP and JM

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号