PLC基本知识 -- 34 基本编程示例 (顺便学英文)
Basic Program Example / 基本编程示例
Now let's compare a simple ladder diagram with its real world external physically connected relay circuit and SEE the differences.
现在让我们将一个简单的梯形图与它的真实世界外部物理连接的继电器电路进行比较,看看有什么不同。
In the above circuit, the coil will be energized when there is a closed loop between the “+” and “-” terminals of the battery. We can simulate this same circuit with a ladder diagram. A ladder diagram consists of individual rungs just like on a real ladder. Each rung must contain one or more inputs and one or more outputs. The first instruction on a rung must always be an input instruction and the last instruction on a rung should always be an output (or its equivalent).
在上面的电路中,当电池的正极(+)和负极(-)之间有一个闭合回路时,线圈将被通电。我们可以用梯形图来模拟这个电路。梯形图由单独的梯级组成,就像真正的梯子一样,每个横档必须包含一个或多个输入和一个或多个输出。一个横档上的第一个指令必须始终是输入指令,而横档上的最后一条指令必须始终是输出指令(或其等效指令)。
Notice in this simple one rung ladder diagram we have recreated the external circuit above with a ladder diagram. Here we used the Load and Out instructions. Some manufacturers require that every ladder diagram include an END instruction on the last rung. Some PLCs also require an ENDH instruction on the rung after the END rung.
注意,在这个简单的单级梯形图中,我们用梯形图重新创建了上面的外部电路。这里我们使用了LOAD指令和OUT指令。一些制造商要求每一个梯形图最后一个梯级上包括一个END指令,一些PLC还需要在END指令之后的梯级上执行ENDH指令。
Next we'll trace the registers. Registers? Let's see...
接下来我们来追踪寄存器,寄存器?让我们看看…
PLC基本知识 -- 45 One-Shots 上升下降沿 (顺便学英文)
One-shots / 上升沿or下降沿
A one-shot is an interesting and invaluable programming tool. At first glance it might be difficult to figure out why such an instruction is needed. After we understand what this instruction does and how to use it, however, the necessity will become clear.
One-shot是一种有趣的、无价的编程工具。乍一看,很难理解为什么需要这样的指令。然而,在我们理解了这个指令的作用以及如何使用它之后,必要性就变得清楚了。
A one-shot is used to make something happen for ONLY 1 SCAN (you do remember what a scan is, right??) Most manufacturers have one-shots that react to an OFF to ON transition and a different type that reacts to an ON to OFF transition. Some names for the instructions could be difu/difd (differential up/down), sotu/sotd (single output up/down), osr (one-shot rising) and others. They all, however, end up with the same result regardless of the name.
One-shot是用来让某事只在一个扫描周期内发生(你还记得什么是扫描吧?)。大多数品牌的PLC有两种类型的One-shot指令,一种是在由OFF转换成ON时发生,另一种是在由ON转换成OFF时发生。这些指令的名称可以是DIFU/DIFD(differential up/down)、SOTU/SOTD(single output up/down)、或者OSR(one-shot rising)等等。然而,不管名称如何,它们最终得到的结果都是相同的。
One-shot Instruction / One-shot 指令(上升沿指令)
Above is the symbol for a difu (one-shot) instruction. A difd looks the same but inside the symbol it says "difd". Some of the manufacturers have it in the shape of a box but, regardless of the symbol, they all function the same way. For those manufacturers that don't include a differential down instruction, you can get the same effect by putting a NC (normally closed) instruction before it instead of a NO(normally open) instruction. (i.e. reverse the logic before the difu instruction)
上面是DIFU(One-shot)指令的符号,DIFD的符号看起来是和这一样的,但是在符号里面写着“DIFD”。有些品牌的PLC用的是盒子的形状,但不管它的符号是什么形状,它们的功能都是一样的。对于那些不包含DIFD(向下微分)指令的PLC,您可以通过在前面放置NC(常闭)指令而不是NO(常开)指令来获得相同的效果(即在DIFU指令前加反逻辑)。
Let's now setup an application to see how this instruction actually functions in a ladder. This instruction is most often used with some of the advanced instructions where we do some things that MUST happen only once. However, since we haven't gotten that far yet, let's set up a flip-flop circuit. In simple terms, a flip-flop turns something around each time an action happens. Here we'll use a single pushbutton switch. The first time the operator pushes it we want an output to turn on. It will remain "latched" on until the next time the operator pushes the button. When he does, the output turns off.
现在,让我们来设置一个应用程序,看看这个指令实际上是如何在梯形图中工作的。这个指令最常与一些高级指令一起使用,在这些高级指令中,我们用它来做一些必须只发生一次的事情。然而,由于我们还没有学得那么深,我们先设置一个触发器电路,简单地说,每次一个动作发生时,触发器都会发生一个状态变化。这里我们将使用一个单按钮开关,操作员第一次推它时,我们希望打开输出,这个输出将一直“锁定”在打开状态,直到下一次操作员按下那个单按钮开关,输出才会关闭。
Here's the ladder diagram that does just that: / 这是实现上述功能的梯形图
Now this looks confusing! Actually it's not if we take it one step at a time.
现在看起来是不是觉得很混乱!事实上,如果我们一步一步来,就不是这样的。
First Scan / 第一次扫描
Rung 1 - When NO (normally open) input 0000 becomes true DIFU 1000 becomes true.Rung 1 - 常开触点0000变为“真”(True)时,DIFU 1000也变为“真”(True)。
Rung 2 - NO 1000 is true, NO 1001 remains false, NC 1001 remains true, NC 1000 turns false. Since we have a true path, (NO 1000 & NC 1001) OUT 1001 becomes true.Rung 2 – 常开触点1000为“真”(True),常开触点1001为“假”(False),常闭触点1001 为“真”(True),常闭触点1000为“假”(False)。因为Rung 2中有一条路径是“真”(True)【即常开触点1000 & 常闭触点1001】 ,所以输出1001变成了“真”(True)。
Rung 3 - NO 1001 is true therefore OUT 0500 turns true.Rung 3 – 常开触点1001为“真”(True),所以输出0500变为“真”(True)。
Next Scan / 第二次扫描
Rung 1 - NO 0000 remains true. DIFU 1000 now becomes false. This is because the DIFU instruction is only true for one scan. (i.e. the rising edge of the logic before it on the rung)Rung 1 – 常开触点0000仍然是“真”(True),但DIFU 1000现在变成了“假”(False),这是因为DIFU指令的“真”(True)状态只能一个扫描周期有效(即逻辑的上升沿使Rung 1变成“真”)。
Rung 2 - NO 1000 is false, NO 1001 remains true, NC 1001 is false, NC 1000 turns true. Since we STILL have a true path, (NO 1001 & NC 1000) OUT 1001 remains true.Rung 2 – 常开触点1000为“假”(False),常开触点1001为“真”(True),常闭触点1001为“假” (False),常闭触点1000为“真”(True)。因为Rung 2中有一条路径任然为“真”(True)【即常开触点1001 & 常闭触点1000】,所以输出1001仍然是“真”(True)。
Rung 3 - NO 1001 is true therefore OUT 0500 remains true.Rung 3 – 常开触点1001是“真”(True),所以输出0500仍然保持为“真”(True)。
100 Scan / 第100次扫描
(NO 0000 turns off / 常开触点0000变为“假”)
After 100 scans, NO 0000 turns off (becomes false). The logic remains in the same state as "next scan" shown above. (difu doesn't react therefore the logic stays the same on rungs 2 and 3)
假设经过100次扫描后,常开触点0000变为了“假”(False),梯形图的逻辑任然会保持与上面所示的“第二次扫描”相同的状态(由于DIFU没有反应,因此逻辑状态在Rung 2和Rung 3都保持不变)。
101 Scan / 第101次扫描
(NO 0000 turns on again / 常开触点0000点再次变为“真”)
Rung 1 - When NO (normally open) input 0000 becomes true DIFU 1000 becomes true.Rung 1 - 当常开触点0000为“真”(True)时,指令DIFU 1000变为“真”(True)。
Rung 2 - NO 1000 is true, NO 1001 remains true, NC 1001 becomes false, NC 1000 also becomes false. Since we no longer have a true path, OUT 1001 becomes false.Rung 2 – 常开触点1000为“真”(True),常开触点1001为“真”(True),常闭触点1001为“假“(False),常闭触点1000也为“假”(False)。由于在Rung2横档上不再有一条路径是“真”(True),所以输出1001变成了“假”(False)。
Rung 3 - NO 1001 is false therefore OUT 500 becomes false.Rung 3 – 常开触点1001变为“假”(False),因此输出0500变为了“假”(False)。
In the example above, each time the operator pushes button 0000 the DIFU instruction turns on (becomes true) FOR ONE SCAN. Notice that it turns on (becomes true) at the rising edge of input 0000. In other words, when input 0000 initially turns on (becomes true) the DIFU instruction is true.
在上面的例子中,每次操作员按下0000按钮,DIFU1000指令就会变为“真(Ture)”并持续一个扫描周期。注意,DIFU1000是在输入0000的上升沿时处于ON状态(变为True)。换句话说,只是在输入0000打开(变为“真”)的初始阶段,DIFU1000指令变为“真”(True)。
When an input initially becomes true its called the leading or rising edge. When it initially turns off (becomes false) its called the trailing or falling edge.
当一个输入变为“真”(True)时,那个初始阶段我们称它为上升沿;当一个输入变为“假”(False)时,那个初始阶段我们称它为下降沿。
If after viewing the animation you still find it difficult to understand, don't feel bad. You're just an idiot and should give up!!! No not really. Just try to remember how its scanned by the plc. Think it through one instruction at a time from top to bottom, then left to right. (i.e. in this order: NO 0000, DIFU 1000, NO 1000, NO 1001, NC 1001, NC 1000, OUT 1001, NO 1001, OUT 500) While executing each instruction is it true or false?
如果看完上面的动画演示后你仍然觉得难以理解,不要难过。你就是个白痴,应该放弃!!不,不,绝对不是,只要记住这段程序是如何被PLC扫描的,挨个指令地去想,从上到下,从左到右(即按这个顺序:NO 0000,DIFU 1000,NO 1000,NO 1001,NC 1001,NC 1000,OUT 1001,NO 1001,OUT 500),看执行每一指令时它是“真”(True)还是“假”(False)。
Rung 2(it has 5 instructions) is the confusing part for most of us. To make it easier lets break it into sections. NO 1000 and NO 1001 are in parallel. In other words they form an "or" circuit. Call this section 1. If 1000 OR 1001 is true then this mini section is true. Next we have another section in parallel. This section is NC 1001 and NC 1000. Again these 2 are in parallel. Call this section 2. If NC 1001 OR NC 1000 is true then this section is true. Finally, those 2 parallel sections (sections 1 and 2) are in series with each other. This means that if section 1 AND section 2 are BOTH true then the rung is true and output 1001 must be true.
Rung 2(它有5个指令)对我们大多数人来说是令人困惑的部分。为了使它更简单,我们把它拆分成几个部分:常开触点1000和常开触点1001是并行的,换句话说,它们形成一个“或”电路,我们将此部分称为Section 1,如果常开触点1000或常开触点1001其中一个为“真”(True),那么这个Section 1部分就为“真”(True);接下来我们来看另一个平行的部分,这个部分是常闭触点1001和常闭触点1000,这两个也是平行的,我们把这部分称为Section 2部分,如果常闭触点1001或常闭触点1000其中一个为“真”(True),那么这个Section 2部分就为“真”(True)。最后,这两个并行部分(Section 1和Section 2)彼此串联,这就意味着,如果Section 1和Section 2两个部分都为“真”(True),那么Rung 2就为“真”(True),输出1001也必须为“真”(True)。
Now its much easier to understand, isn't it? We also just learned about OR and AND logic, commonly called parallel and series logic.
现在它理解起来更容易了吧,不是吗?在这里我们还顺便学了“或”(OR)和“与”(AND)逻辑,通常我们称之为“并联逻辑”和“串联逻辑”。
Executing the program 1 instruction at a time makes this and any program easy to follow. Actually a larger program that jumps around might be difficult to follow but a pencil drawing of the registers sure does help!
执行程序时一次执行一个指令使程序较容易跟踪。实际上,一个更大的程序要这样跳来跳去的跟踪是很困难的,但一个图形化寄存器视图肯定有帮助的吧!
相关问答
描写春天的好词好句,词20个,句10句._作业帮
[回答]时当三月春寒时节春寒季节春天渐近春天来临春天降临春令已到春回大地春归大地春到人间春满人间大地加春天地加春春回地暖天加地转冰...
历朝历代军队行军作战的军粮都有哪些?
兵马未动粮草先行、皇帝不差饿兵、军无粮则散等,中国历史上有着诸多对于军粮的警句,无论在何时何地,士兵只有吃好睡好了,才有力气战斗。但在古代作战,军粮是...
我国第一个发现和研究甲骨文的学者是谁?-188****3231的回...
王义荣也有人对此提出一些疑问:对于王懿荣真是第一个发现甲骨文的人吗?有的学者根据那个雅趣的故事认定王懿荣就是甲骨文的最早发现者。王守信在1...
【秋天作文】作业帮
[回答]秋天来了,秋叶伴着瑟瑟秋风片片飘落。它们在空中飞旋着,如一只只金黄色的蝴蝶,翩翩起舞,没有一丝感伤与遗憾,每一片落叶的飘落都是用生命谱写的快乐...
苏轼关于酿酒的诗词?
他还专门写了首诗《蜜酒歌》来记录酿酒的过程:真珠为浆玉为醴,六月田夫汗流泚。不如春瓮自生香,蜂为耕耘花作米。一日小沸鱼吐沫,二日眩转清光活。三日开瓮...
一点一滴的积累终成大河?
围绕一个中心不断地去干一件小事,积少成多,你就会取得成功。苏东坡曾写过这样的诗句:“竹中一滴曹溪水,涨起西江十八滩。”一滴一滴的小水滴汇集起来会成为浪...
《归去来兮辞》是陶渊明在归家前还是归家后写的?-阿迪力买...
归家后【归去来兮辞题解】本文是晋安帝义熙元年(405)作者辞去彭泽令回家时所作,e69da5e887aa62616964757a686964616f31333233666137分“序”和“辞...
请你们告诉我古希腊神话中的所有人物的介绍-187****5057的...
地神该亚(Gaea):地神该亚又称大地之母,是希腊神话中最早出现的神,在开天辟地时,由混沌(Chaos)所生。该亚生了天空,天神乌拉诺斯,并与他结合生了六男...
40年后南海龙舟再“上山”,有着怎样的故事?
少华山下的龙潭堡,原先只有十来户人家。村里住着:一家姓刘的父女二人,靠做卖豆腐为生。女儿名珠凤,出落得俏模俊样。有一天珠凤去挑水,钩搭上挂上来一条小...
绵阳都有那些历史名人?
李白[唐]中国古代十大文豪,饮中八仙,唐诗四大家,唐朝诗人,仙宗十友(701~762)诗仙李白(701年2月8日-762年12月),字太白,号青莲居士、谪仙人,别名李...父王彭,...