- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
The example described in this how-to is available in the attached .zip. There you will find a detailed README with everything you need to set up this project by your own. You will also find general indications about how to develop a C++ application for ctrlX CORE, as well as, a simplified tutorial about Snapcraft and how it is applied to this specific project.
1. System overview
The connection topology can be seen in the following picture. The serial port of the ctrlX X3 is connected to the Nanotec adapter with a USB-C->USB-B cable. The motor+driver is then connected to the adapter using the wiring convention for CANopen. Although it is not represented in the picture, the motor+driver is powered at 24V.
Documentation about the adapter and the CANopen protocol (CiA 402) can be found in the folder "documentation/" in the .zip. PD2C_CANopen_Techschisches-Handbuch_v3.3.0 is the documentation related with the motor and ZK-USB-CAN-1_Betriebsanleitung_V1.0.0..pdf is the corresponding with the adapter.
2. Easy Start-up
This example is designed for Ubuntu Jammy Jellyfish 22.04 x86_64 Desktop. The "cmake" process that would be used has been designed for a Linux machine, and moreover Snapcraft is a technology from Canonical (the developers of Ubuntu). If you want to develop apps for the ctrlX ecosystem, you must mandatory work in a Ubuntu 22.04 OS, no matter if it is a virtual machine or a native installation.
2.1 Install the necessary tools in your system
Since you are (most likely) developing in a amd64, but your target device (the ctrlX CORE X3) has architecture arm64, you will need to install the necessary system libraries for cross-compilation. The specific libraries from ctrlX and Nanotec have been included in this project for both architectures.
See more details in the .zip.
2.2 Build the source code
You will find batch files in the .zip that automate this process for you.
2.3 Pack in a snap
You will find a batch file in the .zip that automate this process for you.
Once you have the snap, you can install it on your ctrlX CORE X3.
3. API in the datalayer
If the hardware is available the app should be successfully initialized and a new node called "ctrlx_nanotec" should appear in the data layer.
Inside this node one can find the following:
- cmd/ : this branch includes all the parameters that can be edited by the user
- state/: this branch includes all the parameters that are read only.
Inside cmd/ one can find:
- cmd/mode_id: it controls the operation mode of the motor. "0" means stop mode, "1" means relative positioning mode, "2" means velocity mode. It is initialized with "0". To go from relative positioning mode to velocity mode you must go first to stop mode (1->0->2). Similarly from velocity to positioning mode.
- cmd/position_mode/pos_cmd: when in relative positioning mode (mode_id = 1) angle in degrees that you want to turn the motor. There are to decimal positions in the value, i.e. 135.65º should be entered as 13565.
- cmd/velocity_mode/vel_cmd: when in velocity mode (mode_id = 2) rotation velocity in rpm you want the motor to spin. There are to decimal positions in the value, i.e. 15.35 rpm should be entered as 1535.
Inside state/ one can find:
- state/driver: it contains the status (address 0x6041) and control word (address 0x6040) from the CANopen protocol. They are represented in integers, to better understand them convert it to binary.
- state/current_values/position: it contains the current position of the motor in degrees. There are two decimal positions in the value, i.e. 13565 corresponds to 135.65º.
- state/current_values/velocity: it contains the current position of the motor in rpm.There are two decimal positions in the value, i.e. 1535 corresponds to 15.35 rpm.
- state/target_values/position: it contains the internal target position of the motor in degrees, the one the driver solver computes to follow the defined movement profile. There are two decimal positions in the value, i.e. 13565 corresponds to 135.65º.
- state/target_values/velocity: it contains the target position of the motor in rpm, the one the driver solver computes to follow the defined movement profile. There are to decimal positions in the value, i.e. 1535 corresponds to 15.35 rpm.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.