关于PLC指令的一个问题
当指令序列仍在处理时,输入 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
许多(但不是全部)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.
为了补充 Jim C 的答案,还值得注意的是,许多(大多数?)PLC 将允许您使用特殊的“立即”类型指令,该指令直接读取触点/继电器/输入/等的状态(与当 CPU 扫描到达该特定梯级时,从 IO 映像中读取数据。这通常不会更新 IO 映像,这意味着在 CPU 扫描的剩余时间内对该触点的所有其他正常读取都将读取寄存器中的旧值,除非它们也属于“立即”类型。
示例:
然后,在下一次 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 :
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).
一种常见的技术是将 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.
是的,当然可以 - 在这个时间间隔内发生变化的可能性会非常低,因此,如果您遇到一个错误,您假设这两个值永远不会不同,那么它可能会暂时不会显示。
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.