- 20 Dec 2024
- 8 Minutes to read
- Print
- DarkLight
- PDF
PLC Workflow
- Updated on 20 Dec 2024
- 8 Minutes to read
- Print
- DarkLight
- PDF
This article applies to these versions of LandingLens:
LandingLens | LandingLens 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.
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:
- Create an Inspection Point.Note:You can set up multiple configurations for each Inspection Point. For more information, go to Configurations.
- 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 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. - Set up the Cloud Connection and Model settings.
- Complete the following steps in the Communication section.
- Select your PLC Type.
- 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.
- For Rockwell controllers, use this format: [IP Address]/[Slot Number].
- Click Set to set up the Inputs and Outputs, which are the data points that LandingEdge and the PLC can share with each other.
- Click Add New Signal.
- Select an option from the Signal drop-down menu. For detailed information about the options, go to Inputs and Outputs.
- 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. - 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: - After you've set up all the signals, click Set Inputs & Outputs.
- Confirm that the Communication panel shows the number of signals you've set up.
- (Optional) Set up Image Saving settings.
- (Optional) Set up Other Settings settings.
- (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.
Input | Description | Paired Output | Data Type |
---|---|---|---|
Trigger | Takes images immediately when the Trigger goes from Low to High (False to True). | Trigger Ready | Bool |
Results Ack | Configure 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, Error | Bool |
Request Sub-Configuration Index | The 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 Index | Dint |
Custom | Set 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/A | Must match the data type set in the PLC application |
- 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.
Output | Description | Paired Input | Data Type |
---|---|---|---|
Trigger Ready | Indicates LandingEdge is ready to receive the trigger to capture and process an image. | Trigger | Bool |
Results Ready | Indicates inference is complete and results are ready on the output signals to be read by the PLC. | Results Ack | Bool |
Results OK | Indicates the image is good. This is the default result if you are running a Classification Model. | N/A | Bool |
Results NG | Indicates that the image is not good. An Error output will also be present. | N/A | Bool |
Classification | This option is only for Classification Models. Indicates the predicted Class ID. If there is no image, the value is -1. | N/A | Dint |
Error | Indicates 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 Ack | Bool |
Error Code | Indicates what kind of error occurred in the DINT data type.
| N/A | Dint |
Online/Ready | Indicates LandingEdge is running. | N/A | Bool |
Heartbeat | LandingEdge 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/A | Bool |
Busy | Indicates LandingEdge is processing. | N/A | Bool |
Current Sub-Configuration Index | LandingEdge 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 Index | Dint |
Custom | Set 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/A | Must match the data type set in the PLC application |
- 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.
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:
Input | Set Up |
---|---|
Trigger | ✓ |
Results Ack | ✓ |
Request Sub-Configuration Index | ✖ |
Output | Set 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
- LandingEdge indicates that it is Online.
- LandingEdge is ready and asserts Trigger Ready (True).
- The PLC asserts Trigger (True) based on the set configurations. LandingEdge receives this signal and recognizes it is time to take an image.
- LandingEdge changes Trigger Ready to False. The PLC receives this signal and recognizes that LandingEdge acknowledged the Trigger.
- LandingEdge asserts Busy (True) to indicate that it cannot be triggered again. The PLC can monitor this signal.
- 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.
- After the Results are set, LandingEdge asserts Results Ready (True) to indicate that results are available for the PLC to read.
- 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.
- 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.
- 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.