关于PLC指令的一个问题

发布于 2024-09-06 09:56:47 字数 172 浏览 8 评论 0原文

当指令序列仍在处理时,输入 X1 是否可以改变?

例如

LD X1
AND X2
OUT Y1

LD X1 // Can X1 loaded here differ from the previous one?
AND X3
OUT Y1

谢谢

Can an input X1 change while instruction sequence is still being processed?

e.g.

LD X1
AND X2
OUT Y1

LD X1 // Can X1 loaded here differ from the previous one?
AND X3
OUT Y1

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

小巷里的女流氓 2024-09-13 09:56:47

许多(但不是全部)PLC 使用 IO 映像。输入被读取并存储在寄存器中。在处理过程中,您正在处理 IO 映像。图像在周期结束时更新。这样,输入在处理期间不能改变,而只能在周期之间改变。

Many, but not all, PLCs work with an IO image. The inputs are read and stored in registers. During processing you are working with the IO image. The image is updated at the end of the cycle. This way the inputs cannot change during processing, but only between cycles.

铁憨憨 2024-09-13 09:56:47

为了补充 Jim C 的答案,还值得注意的是,许多(大多数?)PLC 将允许您使用特殊的“立即”类型指令,该指令直接读取触点/继电器/输入/等的状态(与当 CPU 扫描到达该特定梯级时,从 IO 映像中读取数据。这通常不会更新 IO 映像,这意味着在 CPU 扫描的剩余时间内对该触点的所有其他正常读取都将读取寄存器中的旧值,除非它们也属于“立即”类型。

示例:

//Start of Program
// Here the CPU scan starts with X1 closed, X2 closed in the IO image    

LD X1  //(X1 = closed)
AND X2 //(X2 = closed)
OUT Y1  //(Y1 will be set high/closed)

//  **suddenly X1 opens**
//(using LDI here to denote "immediate")

LDI X1 //(open - reading true status)
AND X2 //(closed)
OUT Y1  //(Y1 will now open)

LD X1 //(reading from image = closed, still)
AND X2 //(closed)
OUT Y1 //(Y1 will close again)

END of Program

然后,在下一次 CPU 扫描时,映像将使用新值 (X1=open) 进行更新,并且所有三个梯级将返回 Y1 open。

当然,立即指令通常会带来时间损失,因为 PLC 必须花费额外的时间来查找触点的当前值,而不是从图像中读取。但是,它们可能很有用,具体取决于您希望程序如何运行。然而,这些指令必须明确使用,并且正常操作只是从 IO 映像中读取,正如 Jim 指出的那样。

ps:我这里用“LDI”来表示立即指令,但是所有的PLC都会使用不同的语法。例如,Koyos 使用 STR(存储)而不是 LD 和 STRI(立即存储)。

To add to Jim C's answer, it is worth noting, also, that many (most?) PLCs will allow you to use a special "immediate" type instruction which reads the status of the contact/relay/input/etc directly (as opposed to reading from the IO image) when the CPU scan reaches that particular rung. This typically does not update the IO image, meaning that all other normal reads of that contact for the remainder of the CPU scan will read the old value in the register unless they too are of the "immediate" type.

Example :

//Start of Program
// Here the CPU scan starts with X1 closed, X2 closed in the IO image    

LD X1  //(X1 = closed)
AND X2 //(X2 = closed)
OUT Y1  //(Y1 will be set high/closed)

//  **suddenly X1 opens**
//(using LDI here to denote "immediate")

LDI X1 //(open - reading true status)
AND X2 //(closed)
OUT Y1  //(Y1 will now open)

LD X1 //(reading from image = closed, still)
AND X2 //(closed)
OUT Y1 //(Y1 will close again)

END of Program

Then, on the next CPU scan the image will update with the new value (X1=open) and all three rungs will return Y1 open.

Immediate instructions usually come with a time penalty, of course, because the PLC must take extra time to seek the current value of the contact rather than read from the image. They can, however, be useful depending on how you want your program to operate. These instructions MUST be used explicitly, however, and the normal operation is simply to read from the IO image, as Jim noted.

ps: I used "LDI" here to denote the immediate instruction, but all PLCs will use different syntax. Koyos, for example, use STR (store) instead of LD and STRI (store immediate).

音盲 2024-09-13 09:56:47

一种常见的技术是将 IO 寄存器复制到内部存储器地址,这样程序员就可以确保他的 IO 在指令之间不会发生变化。在扫描开始时复制输入,并在扫描结束时复制到输出。

A common technique is to make a copy of the IO registers to an internal memory address so the programmer can be assured that his IO doesn't change between instructions. Make the inputs copy at the beginning of the scan and copy to your outputs at the end of the scan.

深海里的那抹蓝 2024-09-13 09:56:47

是的,当然可以 - 在这个时间间隔内发生变化的可能性会非常低,因此,如果您遇到一个错误,您假设这两个值永远不会不同,那么它可能会暂时不会显示。

Yes, of course it can - the probably of it changing in this interval will be very low, so if you have a bug where you have assumed that these two values will never differ then it may not show up for a while.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文