PLC Workflow
  • 20 Dec 2024
  • 8 Minutes to read
  • Dark
    Light
  • PDF

PLC Workflow

  • Dark
    Light
  • PDF

Article summary

This article applies to these versions of LandingLens:

LandingLensLandingLens on Snowflake

You can use Programmable Logic Controllers (PLCs) to communicate with LandingEdge. For example, you can configure the system so that the PLC tells LandingEdge when to take a photo, and then LandingEdge tells the PLC what the results were.

LandingEdge Workflow with a PLC
Note:
If using an industrial camera, you can configure a PLC to trigger image capture. To learn how to set up industrial cameras in LandingEdge, go to GenICam and GigE Vision Cameras.

Supported Controllers

LandingEdge is compatible with the following PLCs:

  • Rockwell CompactLogix controllers
  • Rockwell ControlLogix controllers
  • Controllers that use the Open Platform Communications Unified Architecture (OPC UA) protocol

Set Up Inspection Points for PLCs

To set up Inspection Points when using a PLC with LandingEdge, follow the instructions below:

  1. Create an Inspection Point.
    Note:
    You can set up multiple configurations for each Inspection Point. For more information, go to Configurations.
  2. Select your Image Source.
    If you want the PLC to trigger the inspection start and you are capturing images with a connected industrial camera, select GigE Vision Camera or GenICam and then select your camera.
    Select Your Image Source
  3. Select your Inspection Start method.
    If using an industrial camera, select PLC. Make sure you configure your PLC to start inspections. This will vary based on your PLC device.
    Select Which Mechanism Should Trigger LandingEdge to Start Inspection
  4. Set up the Cloud Connection and Model settings.
    Connect to a Deployed Model from LandingLens
  5. Complete the following steps in the Communication section.
  6. Select your PLC Type.
    Select Your PLC Type
  7. Enter the IP address of the controller in the Address field.
    • For Rockwell controllers, use this format: [IP Address]/[Slot Number].
      Example: 192.168.1.5/0. (If there's no slot number, omit it.)
    • For OPC UA controllers, use this format: opc.tcp://[IP Address]:4840.
      Example: opc.tcp://192.168.1.10:4840.
      Enter the Address for Your Device
  8. Click Set to set up the Inputs and Outputs, which are the data points that LandingEdge and the PLC can share with each other.
    Start the Signal Setup Process
  9. Click Add New Signal.
    Add a New Signal
  10. Select an option from the Signal drop-down menu. For detailed information about the options, go to Inputs and Outputs.
  11. If you selected Custom, enter the Name and Data Type.
    If you selected an existing signal type, these fields auto-populate and can't be changed.
  12. Enter the PLC Tag or Tag Address in the Tag/Address field for that data point. This field isn't case-sensitive. For information about how to program your PLC, refer to the device manufacturer's documentation.
    For example, the images below show the signals in the PLC application and the matching signals in LandingEdge:
    Tags Set Up in a PLC Application
    Corresponding Signals Set Up in LandingEdge
  13. After you've set up all the signals, click Set Inputs & Outputs.
  14. Confirm that the Communication panel shows the number of signals you've set up.
    Select the Information You Want LandingLens and the PLC to Communicate
  15. (Optional) Set up Image Saving settings.
  16. (Optional) Set up Other Settings settings.
  17. (Optional) Set up Custom Processing.

Inputs

Use the Inputs settings to configure the signals that the PLC sends to LandingEdge.  

The following table describes the configurable inputs.

InputDescriptionPaired OutputData Type
TriggerTakes images immediately when the Trigger goes from Low to High (False to True).Trigger ReadyBool
Results AckConfigure the PLC to set this setting to High (True) to indicate results and errors from LandingEdge have been received. When LandingEdge receives this signal, it resets the result signals and is ready to start the cycle again.Results Ready, ErrorBool
Request Sub-Configuration IndexThe PLC can tell LandingEdge to change to a different Inspection Point configuration. Use the configuration Index, and not the configuration name.

If you're not using multiple configurations for an Inspection Point, leave this blank.

Available in LandingEdge v2.6.45 and later.
Current Sub-Configuration IndexDint
CustomSet up a custom signal that the PLC sends to LandingEdge. For example, this can be the "lot name" for a batch of images.

Available in LandingEdge v2.10.x and later.
N/AMust match the data type set in the PLC application
Note:
Refer here to understand the signals emitted by LandingEdge and the PLC:
  • True/High: Indicates that the value is on.
  • False/Low: Indicates that the value is off.

Outputs

Use the Outputs settings to configure the signals that LandingEdge sends to the PLC.

The following table describes the configurable outputs.

OutputDescriptionPaired InputData Type
Trigger ReadyIndicates LandingEdge is ready to receive the trigger to capture and process an image.TriggerBool
Results ReadyIndicates inference is complete and results are ready on the output signals to be read by the PLC.Results AckBool
Results OKIndicates the image is good. This is the default result if you are running a Classification Model.N/ABool
Results NGIndicates that the image is not good. An Error output will also be present.N/ABool
ClassificationThis option is only for Classification Models. Indicates the predicted Class ID.

If there is no image, the value is -1.
N/ADint
ErrorIndicates an error occurred during acquisition or processing. Check the Error Code for more details. A Results NG output will also be present.

To clear the error, assert the Results Ack input.
Results AckBool
Error CodeIndicates what kind of error occurred in the DINT data type. 
  • All 0 bits: No error
  • A 1 in bit 0: Non-specific error
  • A 1 in bit 1: Timeout during acquisition
  • Bits 2-31: Reserved for future use
N/ADint
Online/ReadyIndicates LandingEdge is running.N/ABool
HeartbeatLandingEdge toggles the value from True to False every 1 second. This allows the PLC to check if LandingEdge is still functioning and that the connection between the PLC and LandingEdge still exists.N/ABool
BusyIndicates LandingEdge is processing.N/ABool
Current Sub-Configuration IndexLandingEdge tells the PLC the Index of the Inspection Point configuration that is currently running.

If you're not using multiple configurations for an Inspection Point, leave this blank.

Available in LandingEdge v2.6.45 and later.
Request Sub-Configuration IndexDint
CustomSet up a custom signal that LandingEdge sends to the PLC. For example, this can be the x and y coordinates of a bounding box.

Available in LandingEdge v2.10.x and later.
N/AMust match the data type set in the PLC application
Note:
Refer here to understand the signals emitted by LandingEdge and the PLC:
  • True/High: Indicates that the value is on.
  • False/Low: Indicates that the value is off.

Test Inputs and Outputs

To test if a signal can be sent between LandingEdge and the PLC, click Test. If the signal works, Success displays. If not, Fail displays. 

If the test fails, check if the Name, Data Type, and Tag/Address in LandingEdge match the information in the PLC application. 

For example, the Custom "lot" signal in the image below failed because its address was incomplete.

The "lot" Signal Test Failed Because the Tag/Address Was Incomplete

Example Setup of LandingEdge and a PLC

The following example workflow shows how setting up the Inputs and Outputs enable LandingEdge and the PLC to work together. 

The example assumes that these Inputs and Outputs are set up:

InputSet Up
Trigger
Results Ack
Request Sub-Configuration Index


OutputSet Up
Trigger Ready
Results Ready
Results OK
Results NG
Classification
(if using a Classification model)
Error
Error Code
Online/Ready
Heartbeat
Busy
Current Sub-Configuration Index

Example Workflow

  1. LandingEdge indicates that it is Online.
  2. LandingEdge is ready and asserts Trigger Ready (True).
  3. The PLC asserts Trigger (True) based on the set configurations. LandingEdge receives this signal and recognizes it is time to take an image.
  4. LandingEdge changes Trigger Ready to False. The PLC receives this signal and recognizes that LandingEdge acknowledged the Trigger.
  5. LandingEdge asserts Busy (True) to indicate that it cannot be triggered again. The PLC can monitor this signal.
  6. After LandingEdge has received and processed an image, Result OK is set to True and Result NG is set to False.
    • If using a Classification model, Classification is set to the predicted Class ID.
    • If an error occurs, Error is set to True.
  7. After the Results are set, LandingEdge asserts Results Ready (True) to indicate that results are available for the PLC to read.
  8. The PLC recognizes that Results Ready or Error is set to True.  It reads the appropriate values—like Results OK, Results NG, and Classification—to determine the final prediction from the model. 
  9. After the PLC reads the results, it asserts Results Ack. LandingEdge receives this signal and recognizes that the PLC has read the results and the cycle is complete.
  10. LandingEdge resets the result signals and is ready to initiate the cycle again (starting from step 2).

Sample Script: Read Inputs and Write Outputs

You can add Results Processing scripts to any LandingEdge inspection point, including inspections with PLCs. When running inference with a PLC, you can use the ReadInput and WriteOutput methods to customize processing based on custom signals defined in the Inputs and Outputs

The scripts in this section show examples of how you can use these methods:

  • ReadInput: Save inferenced images to directories and filenames based on custom signals defined in the Inputs and Outputs.
  • WriteOutput: Send the X and Y coordinates of bounding boxes of predicted objects to the PLC (applicable when using an Object Detection model).

In this example, these custom signals were set up in LandingEdge and the PLC application:

  • lot: This is the lot number for a set of products, and is defined in the PLC.
  • batch: This is the batch number for a set of products, and is defined in the PLC.
  • x: This is the x coordinate of the bounding box for a predicted object of interest.
  • y: This is the y coordinate of the bounding box for a predicted object of interest.

Here is the sample C# script:

public void Run()
{
    // Read inputs for the lot and batch signals from the PLC; the arguments must match the signal names defined in LandingEdge ("lot" & "batch")
    var lotName = ReadInput("lot");
    var batchName = ReadInput("batch");

    // Save images to custom directories & filenames; these override any other settings
    Data.SaveResultsPath = $@"d:\productionImages\{lotName}\{batchName}";
    Data.SaveResultsFilename=$"{lotName}.png";

    // Send the X & Y coordinates to the PLC
    WriteOutput("x", 123.456);
    WriteOutput("y", 789.123);
}

Here is the sample Python script:

def run(self):
    # Read inputs for lot and batch from the PLC; the arguments must match the signal names defined in LandingEdge ("lot" & "batch")
    lot_name = self.ReadInput("lot")
    batch_name = self.ReadInput("batch")

    # Save images to custom directories & filenames; these override any other settings
    self.Data.SaveResultsPath = rf"d:\productionImages\{lot_name}\{batch_name}"
    self.Data.SaveResultsFilename = f"{lot_name}.png"
    
    # Send the X & Y coordinates to the PLC
    self.WriteOutput("x", 123.456)
    self.WriteOutput("y", 789.123)

Results Processing Considerations

If you add a Results Processing script that pulls data from the PLC application (using ReadInput), LandingEdge will use the values the PLC application sent the last time that you acquired an image. If you change a value in the PLC application, you must capture another image to send the updated value to LandingEdge.

For example, let's say you create a lot tag in the PLC application and set its value to 40. You then capture an image. At this point, the lot value in LandingEdge is 40. Let's say that you now change the lot value in the PLC application to 50. If you run the Results Processing script in LandingEdge again without capturing an image, the value will still be 40. Once you capture another image, the value will change to 50.


Was this article helpful?