# Operation

This section describes how certain processes work in theory and in practice.

## Theory of Operation

Changing a job from a PLC consists of setting certain control bits, words and reading status bits. Jobs can be changed using a job slot number (ID) or using a job name. Setting certain values in a word that is sent to the vision system designates if a job change is by ID or by name. The control and status bits again work together to form a 4-way handshake to keep the PLC and vision system in sync while the job change occurs.

1. The Event Execute Command signal is set to 1 and sent from the PLC while the Command Completed signal is low.

2. The Command Completed signal is set in the vision system when the Event Execute Command signal is received and job change logic is processed.

3. The Event Execute Command signal is held high in the PLC until the Command Completed signal is received from the vision system.

4. The Command Completed signal is held high in the vision system until the Event Execute Command signal is cleared in the PLC.

There are a few caveats when changing jobs:

- The vision system must be in an offline state in order to change jobs

- The Execute Command bit must not be set to 0 or cleared while the job change is occurring. If it is set to 0 before the Command Completed bit is set to 1, indeterminate behavior can occur.

- The Command Completed bit is set to 1 even if the job change fails. The Command Failed bit is set to 1 in this case and the Command Result Code, Error and Error ID fields need to be checked to determine the issue.

Note: If either side of the communications channel does not follow the above sequence (steps 1 to 4), indeterminate results can occur.

## Process

1. The vision system is in an online state to start typically. In the PLC, set the Set Offline bit to 1 to change the vision system to an offline state.

2. If changing jobs by name, write the job name into the User Data field.

3. Write the correct value into the Command ID field depending on how the job change is performed:

   - Write 0x4000 (16384 d) into the Command ID if changing job by name.

   - Write 0x0-0x3E7 (0-999 d) into the Command ID if changing job by ID.

4. Set the Execute Command bit to 1.

5. The vision system evaluates Command ID and the User Data (if change by name).

   - If they are valid, the job change begins.

   - If they are invalid, the Command Failed bit is set to 1, the Command Completed is set to 1 and the Error bit and Error ID field is set, and possibly the Command Result Code depending on the issue.

6. When the job information is valid and the vision system begins the job change it sets the Command Completed bit to 0 and the Command Executing bit is set to 1.

7. When the job load completes, the vision system updates the Current Job ID (if changed by ID), sets the Command Completed bit to 1 and clears the Command Executing bit to 0.

8. The PLC reads the new values and sets the Execute Command to 0 when it sees Command Completed set to 1.

9. The vision system receives the Execute Command bit and sees it is 0 and it clears the Command Completed bit to 0.

Steps 4, and 7-9 correlate to the 4 steps above describing the 4-way handshake.