UA OPC Python Interface
This platform provides a versatile and user-friendly interface for controlling laboratory pumps via OPC UA protocol. Pumps are a critical component in fluidic systems, especially in laboratory-scale applications where precise control of fluid flow is essential. This application is specifically tailored for such applications, allowing users to automate and monitor the operation of pumps with ease and accuracy. The user can create and execute a sequence of actions for the pumps in a defined order.
Overview - UA OPC Interface
This application provides a graphical interface to control pumps connected to an OPC UA server. The user can create and execute a sequence of actions for the pumps in a defined order.
Features
- Connect to an OPC UA server.
- Add actions to the program to control the pumps (pump, fill, empty, stop).
- Define time intervals between actions.
- Execute the program and monitor the status and elapsed time.
- Clear the program and start over.
Default OPC UA Configuration
- Client:
opc.tcp://localhost:4840/
- Pump Nodes:
- Pump A:
ns=1;i=1001
- Pump B:
ns=1;i=1002
- Pump A:
- Method Nodes:
- Pump:
ns=2;i=2001
- Stop:
ns=2;i=2002
- Empty:
ns=2;i=2003
- Fill:
ns=2;i=2004
- Pump:
Method Input/Output Format
Pump Method
- Input:
value
(type: UInt16, unit: μL/min) - Output: None
Stop Method
- Input: None
- Output: None
Empty Method
- Input:
value
(type: UInt16, unit: μL/min) - Output: None
Fill Method
- Input:
value
(type: UInt16, unit: μL/min) - Output: None
How the Program Works
Logic Overview
The program allows users to create a sequence of actions for two pumps (Pump A and Pump B) connected to an OPC UA server. These actions can be executed in the order they were added, and the program will handle the execution and timing of each action.
Main Components
- Program Table: Displays the list of actions added by the user. Each action includes the step number, action type, pump (A or B), and value.
- Action Buttons: Allow users to add different actions (Pump, Fill, Empty, Stop) for each pump and a time interval between actions.
- Control Buttons: Include buttons to submit (execute) the program, clear the program, and monitor the execution status and elapsed time.
Adding Actions
- Pump: Prompts the user to enter a value (1-1000 μL/min) and adds a “Pump” action to the program.
- Fill: Prompts the user to enter a value (1-1000 μL/min) and adds a “Fill” action to the program.
- Empty: Prompts the user to enter a value (1-1000 μL/min) and adds an “Empty” action to the program.
- Stop: Adds a “Stop” action to the program.
- Time Interval: Prompts the user to enter a time interval (seconds) and adds a “Sleep” action to the program.
Executing the Program
When the user clicks the “Submit” button, the program starts executing the actions in the order they were added. The status label updates to show the current action being executed, and the timer label displays the elapsed time. The program handles each action as follows:
- Pump, Fill, Empty: Calls the corresponding method on the selected pump node with the specified value.
- Stop: Calls the “Stop” method on the selected pump node.
- Sleep: Pauses execution for the specified time interval (seconds).
Program Execution Flow
- The
execute_program
function starts the execution in a separate thread. - The
run_program
function iterates through the actions in the program. - For each action, the corresponding OPC UA method is called with the appropriate input values.
- If a “Sleep” action is encountered, the program pauses for the specified time interval.
- The status label and timer label are updated to reflect the current state of execution.
- The program continues until all actions are executed or a stop event is triggered.
Example Usage
- Add a “Pump” action for Pump A with a value of 500 μL/min.
- Add a “Fill” action for Pump B with a value of 300 μL/min.
- Add a time interval of 10 seconds.
- Add a “Stop” action for Pump A.
- Click “Submit” to execute the program.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have installed Python 3.6 or later.
- You have access to an OPC UA server.
- You have installed the necessary Python packages listed in
requirements.txt
.
Installation
-
Clone the repository:
git clone https://github.com/lorencig/UA-OPC-Interface.git cd ua-opc-interface
-
Install the required Python packages:
pip install -r requirements.txt
Files
-
main.py
: The main script to run the application. -
requirements.txt
: List of Python packages required to run the application. -
brain.png
: Application icon. -
pump.png
,stop.png
,clean.png
,empty.png
,fill.png
,time.png
,submit.png
: Icons used in the GUI.
Technologies & Tools
- Python
- Tkinter - Standard GUI toolkit for Python.
- ttkbootstrap - A theming extension for Tkinter.
- python-opcua - OPC UA implementation in Python.
License
This project is under Creative Commons Attribution license.
Disclaimer
This software is separated from the author’s research and activity roles at their institutions.
References
2024
- AU OPC InterfaceZenodo, 2024