Marcio Cunha

Industrial Computer Vision Systems Integration with Programmable Logic Controllers via OPC UA

Discover how to connect industrial computer vision systems to Programmable Logic Controllers using the OPC UA protocol to ensure deterministic, standardized, and secure shop floor communication.

Marcio Cunha4 min
Also available in:PortuguêsEspañol
Summary
  • OPC UA communication eliminates proprietary barriers and simplifies structured data exchange between smart cameras and PLCs.
  • Standardized data models drastically reduce commissioning time and the need for custom ladder logic.
  • Choosing between synchronous and asynchronous architectures directly depends on the production process cycle time requirements.
  • Integrated cybersecurity mechanisms protect against unauthorized access and ensure the integrity of inspection commands.
  • Real-time visibility of inspection status optimizes predictive maintenance and reduces unplanned downtime on the line.

The Industrial Automation Scenario and the Computer Vision Challenge

Modern factories rely heavily on automation to ensure quality and speed. In this ecosystem, Programmable Logic Controllers, known as PLCs, function as the brain controlling motors, conveyors, and valves. Simultaneously, computer vision systems act as the eyes of the line, inspecting defects, measuring parts, and reading codes within milliseconds. However, connecting these two worlds historically required dedicated cables, proprietary protocols, and complex conversions of basic electrical signals that limited the amount of data transmitted.

In practice, this means that in the past, an inspection camera could only send a simple binary signal indicating a 'good' or 'bad' part, without detailing the reason for failure. If the line needed to know the exact coordinate of a millimeter deviation or the exact code of a read batch, engineering had to build communication workarounds using serial ports or legacy fieldbuses. This limitation created slow development, high maintenance costs, and difficulty in scaling the intelligence of the production process.

The Role of the OPC UA Protocol in Modern Industry

To solve this communication bottleneck, the industrial ecosystem widely adopted the OPC UA standard, which stands for Open Platform Communications Unified Architecture. It is a universal and open communication protocol that allows different machines and software to talk to each other in the same language, regardless of the manufacturer. In practice, OPC UA acts as a high-level universal translator that runs both on a robust industrial computer and directly on the chip of a modern PLC.

Beyond translating data, OPC UA brings vital features for today's shop floor in its DNA, such as end-to-end encryption, rigorous authentication, and object-oriented modeling. This means that instead of sending only raw numbers, the camera can expose complex data structures containing variable names, units of measure, and standardized timestamps. For the automation engineer, configuring this bridge means abandoning restrictive protocols and focusing on business logic and continuous product quality improvement.

Communication Architecture Between Cameras and Controllers

Developing efficient integration requires designing the network topology considering the flow of information between the vision system and the PLC. Generally, the vision computer runs the artificial intelligence or image processing algorithm, while the PLC waits for the command to release the next machine cycle. When OPC UA enters the scene, this relationship stops being merely a physical trigger and becomes a structured exchange of tags or data nodes across the industrial Ethernet network.

In this architecture, the OPC UA server usually resides on the vision system itself or an intermediate gateway, while the PLC acts as the client that consumes and writes to these variables. In practice, the workstation sends commands to start capture, and the PLC reads inspection results as soon as processing finishes. This client-server approach ensures flexibility, but requires rigorous attention to network bandwidth to avoid delays that compromise the production line cycle time.

Practical Implementation and Structured Data Exchange

Below we present a conceptual example in Python using an OPC UA client library to illustrate how a PLC can monitor visual inspection results in real time. The script demonstrates connection to the camera server, reading structured variables, and writing a reset command to the PLC.

import time
from opcua import Client

# Connects to the OPC UA server running on the vision system
client = Client('opc.tcp://192.168.1.50:4840/freeopcua/server/')

try:
    client.connect()
    print('Connected to the industrial vision system.')
    
    # Maps the camera data nodes
    node_status = client.get_node('ns=2;i=2')
    node_result = client.get_node('ns=2;i=3')
    
    while True:
        status = node_status.get_value()
        result = node_result.get_value()
        
        print(f'Camera status: {status} | Part result: {result}')
        
        if not status:
            print('Waiting for new part on conveyor...')
            
        time.sleep(0.5)
        
finally:
    client.disconnect()
    print('Connection closed safely.')

This code snippet illustrates the basic reading cycle where the client application continuously monitors inspection state. In a real shop floor scenario, this logic runs in supervisory systems or directly in the PLC firmware, ensuring that any quality deviation is handled instantly with the mechanical blocking of the corresponding actuator.

Performance Challenges and Temporal Determinism

Although OPC UA offers unmatched robustness and security, designing high-speed systems requires extra care regarding temporal determinism. In ultra-fast assembly lines, where parts pass per second, every millisecond counts and any network oscillation can cause false rejects or synchronization failures. Therefore, real-time extensions known as OPC UA TSN, which stands for Time-Sensitive Networking, have become fundamental to ensure critical packets have absolute priority in the network infrastructure.

In practice, using conventional networks without prioritization can cause packet queues and unwanted delays when multiple devices try to communicate at the same time. By implementing OPC UA over TSN, engineering ensures that camera trigger data and PLC response travel within strictly guaranteed time windows. This eliminates the need for traditional analog cables without sacrificing the extreme speed demanded by modern industrial processes.

Final Considerations on Technological Convergence

The union between computer vision and industrial controllers through OPC UA represents a milestone in the evolution of smart factories. By standardizing data exchange and eliminating information silos, industries gain flexibility to quickly reconfigure production lines and extract valuable insights directly from the production process. Mastering this technology is no longer a differentiator restricted to large corporations, but a practical requirement for any operation seeking competitiveness, traceability, and sustainable operational efficiency in the current market.