# Sample PLC Logic

The following sample logic is intended for beginners to PLCs and Cognex vision systems and demonstrates how to use the various control and status signals described above in a simple complete PLC program. This logic is controlled by you changing bit states manually. In a real-world scenario these bit states are typically changed by various inputs into the PLC and logic in the PLC driving them to on or off states.

The sample logic is intended to show how PLC logic could be written and includes various functional areas (user data, triggering, results, job change).

You can use the following sample PLC logic to send User Data to the vision system, trigger the vision system, get inspection results as well as change jobs. All the rungs of logic below could be in a routine in the main program and includes some interlocks to prevent the code from executing if another portion is executing or until the you clear certain conditions. The functionality is described below.

Note: Rung descriptions are in yellow background with black characters and describe the rungs up to the next section. The No Operation (NOP) instruction is used for spacing and more visual separation between sections and performs no operation in the logic. They are used in rungs 0, 2, 6 and 12.