UAMotionLinkLib is a library that provides an external motion control interface for OMRON's NX/NJ controllers. It makes motion function blocks (motion FBs) available via a wrapper on the controller's or simulator's OPC UA server, allowing motion control through an OPC UA client. UAMotionLinkLib exposes motion FB operations as a pseudo-UA method, as demonstrated in PseudoUAMethodExample. It also includes a reference client (SingleMCController) and tests that use PwshOpcUaClient.
Currently, the exposed motion FBs are limited to basic positioning operations.
Operations such as servo power control (MC_Power), controlled stop (MC_Stop), and immediate stop (MC_ImmediateStop) are not provided.
Continuous, synchronized, or multi-axis coordinated motion is also not included.
Users can easily extend the functionality.
If any functions are missing, users can extend them at their own discretion.
UAMotionLink offers the following operations:
- MoveAbsolute
Performs absolute positioning for the target axis. Parameters are the same asMC_MoveAbsolute. - MoveRelative
Performs relative positioning for the target axis. Parameters are the same asMC_MoveRelative. - MoveZeroPosition
Returns the target axis to its home position. Parameters are the same asMC_MoveZeroPosition. - Home
Defines the home position for the target axis. Parameters are the same asMC_Home. - SetPosition
Changes the current command position and feedback position of the target axis to an arbitrary value. Parameters are the same asMC_SetPosition. - ResetAxisError
Resets an error on the target axis. This is a wrapper forMC_Reset. - SetAxisIndex
Specifies the target axis by its index. - AxisIndex
Retrieves the index of the currently targeted axis. - Axis
Retrieves the_sAXIS_REFstructure of the target axis.
The reference client provides the functionality to perform the operations listed above. While humans can use it without issue, it was developed with the primary purpose of being used by AI shells, chat AI, or AI agents, so it may be verbose. There are currently no plans to create an MCP server.
The following are required to use the UAMotionLinkLib library:
| Item | Requirement |
|---|---|
| Controller | NX1 (Ver. 1.64 or later), NX5 (Ver. 1.64 or later), NX7 (Ver. 1.35 or later), NJ5 (Ver. 1.63 or later) |
| Sysmac Studio | Ver. 1.62 or later |
The following is required to use the SingleMCController reference client:
| Item | Requirement |
|---|---|
| PowerShell | 7.5 or later |
UAMotionLinkLib and SingleMCController were built in the following environment:
| Item | Version |
|---|---|
| Controller | NX102-9000 Ver. 1.64 HW Rev.A |
| Sysmac Studio | Ver. 1.63 |
| PowerShell | 7.5.2 |
| Pester | 5.7.1 |
UAMotionLinkLib consists of the following:
-
UAMotionLinkLib.slr
A library for Sysmac projects. It is used by referencing it in a project. -
UAMotionLinkLib.smc2
A Sysmac project for UAMotionLinkLib development. It includes test programs for the reference client.
Follow these steps to use the library:
-
Reference UAMotionLinkLib.slr in your project.
-
Build the project and confirm there are no errors.
This verifies that there are no identifier conflicts within the project. -
Execute the BasicMCControllerModel FB (model FB) in an appropriate program POU.
Because it contains motion FBs, the program POU must be executed in the primary task. -
Expose the model FB in the OPC UA settings.
Refer to the manufacturer's manual for instructions on exposing FB instances. Assign appropriate user roles to each method.
The main components of the reference client are:
-
BasicMCController.ps1
The reference client itself. -
BasicMCController.Tests.ps1
Tests for the reference client and model usingPesterandUAMotionLinkLib.smc2. -
ModelTestController.ps1
Operates the test program running inUAMotionLinkLib.smc2. -
SingleMCController.ps1
Defines a derived class of BasicMCController, intended for use by an AI agent. -
SingleMCController.psm1
The module for the reference client. This file must be imported to use the reference client. -
PwshOpcUaClient/
This is the PwshOpcUaClient. For usage, refer to PwshOpcUaClient.
The reference client is used for testing and demonstration. The general steps are:
-
Import SingleMCController.psm1.
-
Execute the code that uses the reference client.
Upon the first connection to an OPC UA server with security enabled, the connection may fail. This is because the OPC UA server rejects the client certificate from PwshOpcUaClient. If this occurs, you can allow the client certificate on the OPC UA server to prevent it from being rejected in the future.
Examples are located in the examples\ directory. For details, refer to each directory.
-
ControlWithAIShell
Uses AI Shell as an intermediary to control servos via a chat AI or to collaborate with one. You can control a servo via AI Shell as shown below.
Code using PwshOpcUaClient is licensed under GPLv2. All other code is licensed under the MIT License.
