已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
外文翻译第 6章指令表、顺序结构图和结构 文本的程序设计方法 本章继续接着上一章讨论另外几种标准编程语言,例如,指令表(il)、顺序结构图(sfc)和结构文本(st)。 6.1指令表 指令表是一种采用文本形式进行梯形图程序设计的编程方法。指令表的程序由一系列的指令组成,每条指令占一行。程序指令由操作码及的一个至多个操作数组成,执行对象是操作码。梯形图中操作码被看作梯形图的构元素。每条指令都可以使用或更改存在记忆寄存器中的信息。为此,使用了助记符代码,每个代码对应一个操作码梯形图元素。尽管标准 iec 1131-3 已经被提出并广泛使用,但是不同制造商使用的指令一定程度上并不一样。表6.1 给出一些厂家所使用的指令,及本章所提议的标准指令(后面章节将讲述指令的其他功能。) 下面给出使用iec 113-1 标准操作码的例子: ld a(*加载a*) and b (*与b*) st q (*存储结果q,输出q*) 在程序的第一行,ld 是操作码,a 是操作数,在程序末尾括号中*之间的内容是评论,解释这行指令的作用,它是 plc 指令的一部分。ld a 这条指令表示将a 加载至寄存器中在之后的操作中可以调用它。第二行是 a 与b 的布尔运算中的与操作。最后一行是将结果存储在 q 中,即向q 输出。 标号可以用来标识不同的进入程序的入口,在程序跳转时十分有用。标号在指令的前面被冒号分隔开。因此有: pump_ok : ld c (*加载c*) 在程序之前面有一条指令,如果某个特殊的条件满足,那么程序就跳转执行pump_ok。 采用iec 113-1 标准的操作码,在值后面加上字符n 表示取反。例如: ld a (*加载a*) andn b (*and not b*) 其中,andn 操作把梯形图触点先“与”后“取反”。 6.1.1梯形图程序设计及指令表 下面看看梯形图的条件,当一个梯级开始工作,必须要使用一个“开始梯级代码 它以是ld 或l,用于指示梯级以常开触点开始。或者是ldi、ldn、ld not、an 或 ln,用来指示梯级以常闭触点开始。所有梯级必须以一个输出或存储结果的编码结束。它可以是 out、=或 st。下图描述了一个梯形图中各独立梯级是如何输入的,其中与门使用三菱的记忆,如图6.1a 所示。 此梯形图以操作码ld开始,因为它开始于常开触点。由于输入地址是x400,所以加载指令为 ldx400,其后还有一个常开触点作为输入,所以下一行程序指令用and 指令对元件地址逻辑与操作,相应语句为:and x401。因为,这个梯级要以输出终止,所以用输出指令 out 产生输出,即 out y430。因此,梯形图的单个梯级可以用程序指 令描述为: ld x400 and x401 out y430 同样的功能,采用西门子符号,如图 6.1b 所示。 a i0.1 a i0.2 = q2.0 再看另一个与门的例子,如图 6.2a 所示,采用的是三菱的符号。 梯形图以常开触点开始,指令为ld x400, 与x401并联,因此下一条指令为or x401。最后一条是输出,所以输出为 out y430。指令表如下: ld x400 or x401 out y430 如图6.2b 所示的是西门子符号的或门,指令表如下: a i0.1 o i0.2 = q2.0 字母 i 用来表示对这条指令的取反。紧接着串联一个常闭触点,其指令为 ani,i 再次表示对这条与指令的取反,当然 i 也是一个非门的指令。所梯形图中或非门的指令可以写成: ldi x400 ani x401 out y430 图 6.3b 是西门子的或非门符号。注意指令后面的字母 n 的作用是取反。指令表如下: ln i0.1 an i0.2 = q2.0 图6.4a 为三菱符号表示的与非门。 梯形图以常触点 x400 开始,指令语句为 ldi x400。下一条对应于一个并联的常闭触点,其指令为 or1 x401。最后一步是输出,指令为 out y430。因此,指令表如下: ldi x400 ori x401 out y430 图6.4b 为采用西门子符号的异或门。指令表如下: an i0.1 on i0.2 = y430 6.1.2分支代码 如图 6.5a 所示的采用三菱符号的异或门,它有两条并联的分支,每条分支分别由与关系构成 图中三菱公司使用orb 指令来表示或和并联分支的关系。第一条指令对应一个常开触点x400。下一条指令对应与之串联的常闭触点 x401,指令为ani x401。在读取前两条指令之后,第三条指令开始于新的一行。另起一行是因为它开始于指令 ldi,所有新的一行指令语句都是以 ld 或 ldi 开始。但是第一行不能以输出结束,所以plc 把与其并联的那行包含在第二行,这样读取以上所列内容直到orb 指令。助记码 orb(分支或模块间的或运算)用于将前两行及第三、四行的指令执行结果进行逻辑或运算。指令表以输出 out y430 终止。指令表如下: ld x400 ani x401 ldi x400 and x401 orb out y430 图 6.5b 是西门子的异或门。括弧用来表示将特殊指令结合在一起作为一个区块执行。 这种用法和数学方程中的括弧用法相同。例如,(2+3)/4表示2 和3相加的结果再除以 4。 因此,西门子指令表中从第 0 步的指令 a 开始,括弧到第三步结束,表示第 0 步的a 只能允许在第一步和第二步指令执行结束后才能够执行。 iec 1131-3 标准应用于此段程序就是使用上述西门子例子中的括弧来实现的。 图 6.6a 的电路图,采用三菱符号,可看成是两个分支模进行与操作。所采用的指令是anb。指令表如下: 图 6.6b 是用西门子符号来表示的同一个电路。本程序中的指令表使用了括弧。第0 步的指令a 应用到第1、2 步的结果中。第4 步中的指令a 应用到第5、6 步的结果中。所以程序的指令表如下: 6.1.3多个梯级 图 6.7a 是用三菱符号表示的梯形图,它有两层梯级。在编写指令表时,按顺序写出每行的指令。指令 ld 或ldi 表示plc 新的一层梯级开始。指令表如下: ld x400 out y430 ldi x400 out y431 此系统表明,当x400 没有被触发时,y431 有输出,y430 没有输出。当 x400被触发时,y430 有输 出,y431 没有输出。 图 6.7b 用西门子符号描述了同样的程序。=指令表示一行结束。a 或 an 指令可以表示一层梯级的开始。但不是必需的,因为还可以用 and 和and not 表示该指令。则指令表如下: a i0.0 = q2.0 an i0.0 = q2.1 6.1.4程序举例 下面介绍本节所述程序设计方法的具体应用,以 5.7 节的梯形图和功能块为例。对照5.7 节中梯形图的解释,在此只讲述和程序相关的指令表。 如果水泵在运行状态,且满足一定压力条件或指示灯开关闭合,那么信号灯亮。图6.8 给出了梯形图和相关的指令表。 对于一个用来提升负载的阀,当泵在运行并且提升开关闭合或有开关指示负载在底部提升槽中而没有被提升,那么阀工作。图 6.9 是其梯形图及与之对应的指令表 当四个传感器中的任意一个有输出时,系统都没有输出产生,否则有输出产生,图6.10 给出了梯形图程序及与之对应的指令表。 6.2 顺序功能图 如果想描述一个交通灯序列。一种方法就是把它看成是一系列的功能或状态,例如红灯 状态、绿灯状态,然后考虑每个状态的输人和输出。 如图 6.11 就是对此的描述。状态 0 的输人在绿灯持续亮一分钟后触发,然后以红灯亮 作为输出。状态 i 的输人在红灯持续亮一分钟后触发,然后以绿灯亮作为输出。 顺序功能图是一种系统操作的图形表示,它描述了一系列操作中的事件顺序。顺序功能图遵循以下规则: 1.这种操作用互相独立、相继连接的状态或动作来描述,用矩形方框来表示状态,每 个方框代表被控系统的某个状态。程序的初始化动作与其他动作的表示方法有所不同。图 6.12 给出了它的表示法。 2.在两个状态之间的连接线上有一条水平的短线,表示系统从一个状态到下一个状态 需要满足的转换条件。两个动作之间不能直接连接,它们中间必须加转换条件。两个转换条 件之间也不能直连,中间必须有动作状态。 3.下一状态的转换条件满足时,程序中的下一个状态或动作就开始执行。 4.从一个状态到下一个状态的程序进程将会持续执行直到一个完整的机器周期结束。 5.任一状态的输出/动作都由水平连接的方框表示,当状态转换条件满足时,产生输出。 图6.13 描述了部分顺序功能图及其等价的梯形图。 为了说明顺序功能图的规则,以庭洗衣机的部分洗漆周期为例。洗衣机滚桶内注满水 后便打开加热器开关,直到温度达到求的标准,然后滚桶转动一段特定时间。用一系列顺 序状态表示,如图6.14 所示 6.2.1分支和汇聚 如图6.15 所示,当跳转条件满足时,选择性分支便转移至相应的状态。 并联分支如图 6.16 所示,由一对平行线表示,可同时执行两个或多个不同的状态。 图 6.17 和图 6.18 给出了顺序功能图中汇聚的表示方法。在图 6.17 中,若in4 发生, 执行顺序从状态2 转移到状态4,或若in5 发生,可从状态3 转移到状态4。在图6.18 中, 若in4 发生,执行顺序可同时从状态 2、3 转移到状态4 6.2.2动作 对于某个状态来说,可以执行一个或多个动作。所谓“动作”就像上面例子中的输出,用方框表示。 动作的行为可以用梯形图、功能块、指令表和结构文本来描述。所以,当使用梯形图 时,动作的行为由方框中的梯形图表示。当有电流输人“动作框图”中时,方所表示的 动作就会被激活。如图 6.20 所示。 在动作框图前通常附一个限定符,用以说明动作执行的条件。若有限定符或限定符 在相关状态激活时,所要求动作就不能被存储及连续执行。限定符 p用于脉冲动作,当某一程序步骤激活时它只执行一次。限定符 d 用于延时动作,在一段时间之后相应动作才会激发。限定符 l 用于限时动作,在执行一段时间以后才停止相应动作,如图 6.21 所示。 6.3结构文本 结构文本是一种和 pascal 极其相似的编程语言。程序由一系列被分号隔开的陈述语句构成。这些语句使用预先定义的语句和子函数来改变变量,变量可以是已定义的值或内部存储值或输入/输出值。 赋值语句用于对欲改变的变量进行赋值。例如: light:=switcha; 表示变量light 的值将被改变,当开关 a 闭合或断开时,变量light 的值也随之变化。赋值语句的一般格式如下:x:=y ; 其中,x 是自变量,y 是因变量。再看另一个例子: light:switcha or switchb; 表示灯的开关由开关 a 或b 控制。 表6.2 给出了一些结构文本中的操作符, 如上面语句中的or。并且也列出了它们在 程序运行时的优先级。例如, inputa=6 inputb=4 inputc=2 outputq:=inputa/3+inputb/(3-inputc) 其中,(3-inputc)的值作为函数的除数,所以计算输出 q 语句的第二步是4/(3-2)=4。除法比加法优先,所以第一步在计算加法之前计算 6/3。因此,输出outputq 的值是2+1=3。 结构文本对字符大小写不敏感,因此为了增强可读性可任意使用大小写字母。同样,也可使用空格键或空行来增强可读性。所有表示变量的等式都以字符%开始,在其后面是一个或两个字母码用以标识其存储单元和其相应数据类型,其中存储单元包括输入/输出存储器或内部存储器,数据类型包括位、字节、字。例如: %ix100(*input memory bit 100*) %id200(*input memory word200*) %qx100(*output memory bit 100*) 第一个字母 i 是输入存储单元,q 是输出存储单元,m 是内部存储器。第二个字母x 表示位,8 表示字节i(8 位),w 表示字(16 位),d 表示双字(32 位),l表示长字(64 位)。 at 用来确定变量的存储单元。因此有: input at %ix100; (*input is located at input memory bit 100*) 英文原文6 il, sfc and st programming methods this chapter continues from the previous chapter and discusses the other iec 1131-3 (international electrotechnical commission) programming languages, i.e. instruction lists (il), sequential function charts (sfc), and structured text (st). 6.1 instruction lists a programming method, which can be considered to be the entering of a ladder program using text, is instruction lists (il). instruction list gives programs which consist of a series of instructions, each instruction being on a new line. an instruction consists of an operator followed by one of more operands, i.e. the subjects of the operator. in terms of ladder diagrams an operator may be regarded as a ladder element. each instruction may either use or change the value stored in a memory register. for this, mnemonic codes are used, each code corresponding to an operator/ladder element. the codes used differ to some extent from manufacturer to manufacturer, though a standard iec 1131-3 has been proposed and is being widely adopted. table 6.1 shows some of the codes used by manufacturers, and the proposed standard, for instructions used in this chapter (see later chapters for codes for other functions). table 6.1 instruction code mnemonics store result register an output into operand ld a (*load a*) and b (*and b*) st q (* store result in q, i.e. output to q*) in the first line of the program, ld is the operator, a the operand, and the words at the ends of program lines and in brackets and preceded and followed by * are comments added to explain what the operation is and are not part of the program operation instructions to the plc. ld a is thus the instruction to load the a into the memory register. it can then later be called on for further operations. the next line of the program has the boolean operation and performed with a and b. the last line has the result stored in q, i.e. outputted to q. labels can be used to identify various entry points to a program, useful as we will find later for jumps in programs, and these precede the instruction and are separated from it by a colon. thus we might have: pump_ok: ld c (* load c*) with there being the instruction earlier in the program to jump to pump_ok if a particular condition is realised. with the iec 113-1 operators, an n after it is used to negate its value. for example, if we have: ld a (*load a*) andn b (*and not b*) thus the andn operator inverts the value of ladder contacts and ands the result. 6.1.1 ladder programs and instruction lists when looked at in terms of ladder diagrams, whenever a rung is started, it must use a start a rung code. this might be ld, or perhaps a or l, to indicate the rung is starting with open contacts, or ldi, or perhaps ldn or ld not or an or ln, to indicate it is starting with closed contacts. all rungs must end with an output or store result code. this might be out or = or st. the following shows how individual rungs on a ladder are entered using the mitsubishi mnemonics for the and gate, shown in figure 6.1(a). the rung start with ld because it is starting with open contacts. since the address of the input is x400, the instruction is ld x400. this is followed by another open contacts input and so the next program line involves the instruction and with the address of the element, thus the instruction is and x401. the rung terminates with an output and so the instruction out is used with the address of the output, i.e. out y430. the single rung of a ladder would thus be entered as: ld x400 and x401 out y430 for the same rung with siemens notation (figure 6.1(b) we have: a i0.1 a i0.2 = q2.0 consider another example, an or gate. figure 6.2(a) shows the gate with mitsubishi notation. the instructions for the rung start with an open contact is ld x400. the next item is the parallel or set of contacts x401. thus the next instruction is or x401. the last step is the output, hence out y430. the instruction list would thus be: ld x400 or x401 out y430 figure 6.2(b) shows the siemens version of the or gate. the following is the siemens instruction list: a i0.1 o i0.2 = q2.0 figure 6.3(a) shows the ladder system for a nor gate in mitsubishi notation. the rung starts with normally closed contacts and so the instruction is ldi. i when added to mitsubishi instruction is used to indicate the inverse of the instruction. the next step is a series normally closed contact and so ani, again the i being used to make an and instruction the inverse. i is also the instruction for a not gate. the instructions for the nor gate rung of the ladder would thus be entered as: ldi x400 ani x401 out y430 figure 6.3(b) shows the nor gate with siemens notation. note that n added to an instruction is used to make the inverse. the instruction list then becomes: ln i0.1 an i0.2 = q2.0 consider the rung shown in figure 6.4(a) in mitsubishi notation, a nand gate. it starts with the normally closed contacts x400 and so starts with the instruction ldi x400. the next instruction is for a parallel set of normally closed contacts, thus the instruction is ori x401. the last step is the output, hence out y430. the instruction list is thus: ldi x400 ori x401 out y430 figure 6.4(b) shows the nand gate in siemens notation. the instruction list is then: an i0.1 on i0.2 = q2.0 6.1.2 branch codes the exclusive or (xor) gate shown in figure 6.5(a) in mitsubishi notation has two parallel arms with an and situation in each arm. in such a situation mitsubishi uses an orb instruction to indicate or together parallel branches. the first instruction is for a normally open pair of contacts x400. the next instruction is for a series set of normally closed contacts x401, hence ani x401. after reading the first two instructions, the third instruction starts a new line. it is recognised as a new line because it starts with ldi, all new lines starting with ld or ldi. but the first line has not been ended by an output. the plc thus recognises that a parallel line is involved for the second line and reads together the listed elements until the orb instruction is reached. the mnemonic orb (or branches/blocks together) indicates to the plc that it should or the results of the first and second instructions with that of the new branch with the third and fourth instructions. the list concludes with the output out y430. the instruction list would thus be entered as: ld x400 ani x401 ldi x400 and x401 orb out y430 figure 6.5(b) shows the siemens version of xor gate. brackets are used to indicate that certain instructions are to be carried out as a block. they are used in the same way as brackets in any mathematical equation. for example (2 + 3)/4 means that the 2 and 3 must be added before dividing by 4. thus with the siemens instruction list we have in step 0 the instruction a(. the brackets close in step 3. this means that the a in step 0 is applied only after the instructions in steps 1 and 2 have been applied. the iec 1131-3 standard for such programming is to use brackets in the way used in the above siemens example. figure 6.6(a) shows a circuit, in mitsubishi notation, which can be considered as two branched and blocks. the instruction used here is anb. the instruction list is thus: figure 6.6(b) shows the same circuit in siemens notation. such a program is written as an instruction list using brackets. the a instruction in step 0 applies to the result of steps 1 and 2. the a instruction in step 4 applies to the result of steps 5 and 6. the program instruction list is thus: figure 6.7(a) shows a ladder, in mitsubishi notation, with two rungs. in writing the instruction list we just write the instructions for each line in turn. the instruction ld or ldi indicates to the plc that a new rung is starting. the instruction list is thus: ld x400 out y430 ldi x400 out y431 the system is one where when x400 is not activated, there is an output from y431 but not y430. when x400 is activated, there is then an output from y430 but not y431. figure 6.7(b) shows the same program in siemens notation. the = instruction indicates the end of a line. the a or an instruction does not necessarily indicate the beginning of a rung since the same instruction is used for and and and not. the instruction list is then: a i0.0 = q2.0 an i0.0 = q2.1 6.1.4 programming examples the following tasks are intended to illustrate the application of the programming techniques given in this section and are the examples for which ladder diagrams and function block diagrams were derived in section 5.7. see that section for an explanation of the ladder diagrams; here we just show the instruction lists relating to the programs. a signal lamp is required to be switched on if a pump is running and the pressure is satisfactory, or if the lamp test switch is closed. figure 6.8 shows the ladder program and the related instruction list. for a valve which is to be operated to lift a load when a pump is running and either the lift switch is operated or a switch operated indicating that the load has not already been lifted and is at the bottom of its lift channel, figure 6.9 shows the ladder program and the related instruction list. for a system where there has to be no output when any one of four sensors gives an output, otherwise there is to be an output, figure 6.10 shows the ladder program and the instruction list. 6.2 sequential function if we wanted to describe a traffic lamp sequence, one way we could do this would be to represent it as a sequence of functions or states such as red light state and green light state and the inputs and outputs to each state. figure 6.11 illustrates this. state 0 has an input which is triggered after the green light has been on for 1 minute and an output of red light on. state 1 has an input which is triggered after the red light has been on for 1 minute and an output of green light on. the term sequential function chart (sfc) is used for a pictorial representation of a systems operation to show the sequence of the events involved in its operation. sfc charts have the following elements: 1 the operation is described by a number of separate sequentially connected states or steps which are represented by rectangular boxes, each representing a particular state of the system being controlled. the initial step in a program is represented differently to the other steps, figure 6.12 shows its representation. 2 each connecting line between states has a horizontal bar representing the transition condition that has to be realised before the system can move from one state to the next. two steps can never be directly connected, they must always be separated by a transition. two transitions can never directly follow from one to another, they must alway be separated by a step. 3 when the transfer conditions to the next state are realised then thenext state or step in the program occurs. 4 the process thus continues from one state to the next until the complete machine cycle is completed. 5 outputs/actions at any state are represented by horizontally linked boxes and occur when that state has been realised. as an illustration, figure 6.13 shows part of an sfc and its equivalent ladder diagram. figure 6.13 sfc and equivalent ladder diagram as an illustration of the principles of sfc, consider the situation with, say, part of the washing cycle of a domestic washing machine where the drum is to be filled with water and then when full a heater has to be switched on and remain on until the temperature reaches the required level. then the drum is to be rotated for a specified time. we have a sequence of states which can be represented in the manner shown in figure 6.14. 6.2.1 branching and convergence selective branching is illustrated in figure 6.15 and allows for different states to be realised depending on the transfer condition that occurs. parallel branching (figure 6.16), represented by a pair of horizontal lines, allows for two or more different states to be realised and proceed simultaneously. figures 6.17 and 6.18 show how convergence is represented by an sfc. in figure 6.17 the sequence can go from state 2 to state 4 if in 4 occurs or from state 3 to state 4 if in 5 occurs. in figure 6.18 the sequence can go simultaneously from both state 2 and state 3 to state 4 if in 4 occurs. 6.2.2 actions with states, there is an
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年度二手车交易大数据分析及咨询服务合同2篇
- 2024年包含多应用块石的采购协议范例2篇
- 2024年度北京车牌租赁咨询服务合同标准范本9篇
- 2024年度新能源项目购买居间合同2篇
- 2024年国际结算条款协议3篇
- 2024年度光伏电站施工安装合同2篇
- 2024年文化艺术培训机构教师艺术素养提升聘用合同3篇
- 2024年度地铁车辆采购与维护保养合同2篇
- 2024年度版权许可合同:著名导演电影作品版权授权2篇
- 2024年度房地产股权收益权转让合同范本3篇
- 白内障术后干眼症的护理
- 全国自然教育中长期发展规划
- 农民素质提升培训
- 冬季驾驶安全培训避免车辆失控和翻车的技巧
- 2024年考研政治真题与答案解析(完整版)
- 第四章-国防动员
- 护患沟通技巧培训课件让护患沟通更有温度
- 乡土中国差序格局
- 高中生物科组教研活动总结
- 社工站工作总结汇报
- 2024年度医院内科呼吸科述职报告课件
评论
0/150
提交评论