I/O and process image management
First of all we would like to emphasise the conditions already mentioned in other sections of this manual in relation to I/O management.The I/O management of the HW devices configured, whether installed on local bus or acquired through a fieldbus, is activated after running the INIT task when starting the user application program.The availability of the I/O of the HW devices configured, whether they are installed on local bus or acquired via a fieldbus, is not guaranteed the first time the above-listed tasks are run. The user program has to check through the interfaces prepared that this condition occurs according to the needs of the application (launch with partial availability of the I/O).In the PLC, the task that performs the I/O run time update, or the exchange between the logic image (I/O variables in 1131) and the physical image (the terminals of the devices connected on local bus or remotely via fieldbus) is the FAST task.The FAST task usually runs the following sequence of operations:Read inputFAST 1131 codeWrite outputThis sequence is not always suited to the needs imposed by particular applications; while guaranteeing the fastest possible update of the output following the decisions made by code 1131 of FAST, it also determines a jitter of the write output instant insofar as it depends on the run time of the FAST code 1131.In some cases a different sequence is preferable, putting the Write output operation before the others for example. In this case, the output update is delayed constantly to the start of the next period of the FAST task but it is made independent from the FAST run time (attention: it is obviously necessary for the FAST run time never to exceed the period configured…).The sequence is configurable in GF Project VX under “Hardware”, “Options”. Select “Expert mode”:
Then go to “PLC options”, “Execution order for ReadIO-Plc-WriteIO”.
The 1131 FAST code always works on the “global” logical image of the I/O: as its running is synchronous with the read and write operations run by FAST, the input value remains unchanged during the running of code 1131, while the output value transferred to physical is only the last decided within each FAST cycle.For NORMAL and SLOW tasks, things are different.As these are lower priorities than FAST, it is possible for their running to be suspended by a new running of FAST if their duration cannot be completed within the same FAST period that determined activation.To prevent this from changing the value of the inputs during the processing of code 1131 hosted by NORMAL or SLOW, these tasks work on the copies memorised at the start of running.This mode is called process image.
As indicated for the FAST task, the NORMAL and SLOW tasks also usually run the following procedure of operations:Latch input1131 codeUpdate outputwhere latch input means the copy on the “private” variables of the task in question of the I/O to which the task refers in its 1131 code, and update output means the copy from the “private” variables to the originals of the output controlled by code 1131 of the same task.In this case too, the sequence might not always be ideal: in some cases it might even be preferable not to use process image but to allow code 1131 to work directly on the original I/O.The sequence is configurable separately for NORMAL and SLOW tasks, in GF Project VX under “Hardware”, “Options”. Select “Expert mode”: then go to “PLC options”, “Process image I/O – task NORMAL” and SLOW.Below is an example of the time diagram for operation of the I/O for FAST, NORMAL and SLOW tasks. Operation has been represented by placing the input acquisition at the beginning of each task, with the output update at the end. Remember that the operations performed by FAST are between physical I/O and “global” image I/O 1131, while those performed by the NORMAL and SLOW tasks are between local copy and “global” image 1131.The solid arrows indicate the input flow: they start from the FAST cycle which has acquired them from the physical input and end in the point where they are transferred to the copy image of the task that processes them. The dashes indicate the output flow: they start in the point where they are transferred from the copy image of the task that processes them to “global” image 1131 and end on the FAST cycle that records then on the physical output.Note that, in the first cycle on the left, the NORMAL and SLOW tasks process their inputs acquired in the same cycle as the FAST TASK while the outputs corresponding to the same tasks are managed by FAST in subsequent cycles due to the processing times of the tasks involved.
It’s strongly advise against access the same output variable reference in more than one task ! As access you must consider not only writing operations but also reading and testing !If you need you should realize a specific management in the application program based on generic variables (not output) to prepare the value that must be copied in an output variable from one task only and following application specific rules.Process image management makes very critical the access to same output variables from more than one task. Because: physical output value is fixed from the last value assignment (in FAST task) or value copy (from tasks NORMAL and SLOW process image management) executed in chronological order; local copies management (read-from and write-to global output variables) for tasks NORMAL and SLOW is not related to the access type performed : both operations are executed also for read only access; local copies management (read-from and write-to global output variables) for tasks NORMAL and SLOW is not related to real execution of the access instructions in the current task cycle: this means that the local copy value of an output variable will overwrite the global value also when no change happen, coming back to the initial variable value present when task cycle started performing the read-from copy; local copies management (read-from and write-to global output variables) for tasks NORMAL and SLOW is cyclically executed : so the local copy value is continuosly overwriting the global output value; this can erase changes coming from FAST task, specially if FAST task changes the value only one shot;