Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Question About PLC Instructions

Tags:

plc

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

like image 321
Betamoo Avatar asked Jun 21 '10 11:06

Betamoo


2 Answers

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.

like image 132
Jim C Avatar answered Oct 31 '22 18:10

Jim C


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).

like image 22
J... Avatar answered Oct 31 '22 19:10

J...