Share this

Leadshine motion control cards are based on Linux systems.

2026-04-06 04:55:05 · · #1

Linux is a completely free and open-source POSIX-based multi-user, multi-tasking operating system that supports multi-threading and multi-CPU, simplifying the development process and making the system highly portable.

Today we'll discuss the development and application tutorial for Leadshine motion control cards on Linux systems. This tutorial uses Ubuntu 18.04, with the DMC-E3032 bus control card as the main controller, and Qt for development. The control card driver supports Linux kernel versions 2.6.0-5.14.11. It is recommended that users use a system version and kernel version that match these versions.

I. Motion Control Card Driver Installation Instructions

01. Compile the driver source code to generate the .ko driver file.

(1) On the Linux computer where you want to run the installation, extract the DMC3K5K.rar compressed file. Navigate to the folder directory and run ./DMC3K5K/dmc3k5k_installation

(2) Enter the command: sudo chmod 777 –R redist to modify the folder permissions.

(3) Enter the command: cd storage path/redist to enter the redist directory.

(4) In this directory, open the terminal and enter the command: sudo ./configure to generate the compilation file.

(5) Enter the command: sudo make to compile the .ko file and the corresponding wdreg file.

(6) Enter the command: sudo make install to install the driver (Note: After the computer restarts, the control card driver will be automatically uninstalled, and you need to proceed to step two).

(7) Command: sudo chmod 777/dev/DMC3K5K Set file permissions.

(8) Place the generated wdreg file and DMC3K5K.ko file (in the newly generated folder) into the redist directory, and the driver compilation is complete.

02. Set up automatic driver installation upon startup.

The driver module is loaded in the startup script /etc/rc.local, and the DMC3K5K driver module is automatically installed every time the system boots. The access permissions of DMC3K5K are also modified to give all users full permissions to DMC3K5K.

(1) Press Ctrl+Alt+T to bring up the terminal.

Download the Vim editor

Command: sudo apt-get install vim

(2) Enter the etc folder

Command: cd /etc

(3) Open rc.local using the vim editor.

Command: sudo vim rc.local

In the pop-up window, select (E)dit anyway

(4) Press the letter 'i' on your keyboard to insert a command. Add the following before the command 'exit 0' in the file /etc/rc.local:

Command: cd storage path /redist (locate to the file directory)

Command: sudo make install (install driver)

Command: sudo chmod 777 /dev/DMC3K5K (set file permissions)

(5) Press the ESC key, type: wq, press Enter to save and exit the file.

(6) Restart your computer. The motion controller driver will be installed automatically upon startup. After successful installation, you can use the ls command to list the detailed information of DMC3K5K in the /dev folder and check the access permissions of DMC3K5K.

Command: sudo ls -l /dev

We can see that there is a device called DMC3K5K, and the permissions for DMC3K5K are crwxrwxrwx

How to add an rc.local file

In newer Linux systems, the rc.local file no longer exists, and the file generated by vim does not automatically start services. You can use the following method to execute and then edit the rc.local file:

(1) Configure rc-local.service

(2) Activate rc-local.service

(3) Add startup service

Manually create or copy an existing `/etc/rc.local` file and grant it execute permissions.

Motion control card driver uninstallation instructions

Delete startup script files

Enter the command: sudo rm /dev/rc.local to delete the startup script file.

Remove the control card driver module

Enter the command: sudu rm /dev/DMCSK5K

II. Project Construction

01. New Project

(1) Open the "Qt" software, click "File"① in the menu; click "New File or Project"②; as shown in the figure below:

(2) A pop-up window for creating a new project will appear. In the "Project" section, select "Application (Qt)"①; select "Qt Widgets Application"②, which supports all graphical users on the desktop platform; and click "choose"③; as shown in the following figure:

(3) In the project configuration window, go to "Location"①; enter the project name "DMC-Demo"② (Note: Qt cannot use any Chinese characters here, otherwise compilation problems may occur); click "Browse" to select the path where the project is created③; click "Next"④; as shown in the figure below:

(4) Enter the “Build System” ①; select the default “qmake” ② (qmake is a tool program that helps simplify the build process for cross-platform project development); click “Next” ③; as shown in the figure below:

(5) Enter “Details” ①; In “Class”, you can use the default name “MainWindow” as the main window name, or you can name it yourself ②; Use “QMainWindow” as the base class ③ (The main window has a main menu bar, toolbar, and status bar, similar to the main window of a general application); Check the “Generate form” checkbox ④ (If this option is checked, Qt Creator will create the user interface (UI) file; otherwise, you need to create the UI manually); Click “Next” ⑤; As shown in the figure below:

Enter "Translation" ①; in "Language", the default language can be used. ②; Click "Next" ③; As shown in the image below:


(6) Enter “Kits”①; select “Desktop Qt 5.12.12 GCC 64bit”②; click “Next”③, as shown in the figure below:

(7) Go to “Summary”①; you can view the detailed information of the file to be added, and confirm that the information is correct②; click “Finish”③, as shown in the figure below:

(8) After completing the above steps to create a new project, you will enter the code editing interface. In the project panel on the left, you can see the "DMC-Demo" project folder, which includes 4 subfolders. The following is a brief introduction to these 4 subfolders:

① "DMC-Demo.pro" is the project management file, which includes some settings for the project;

② The "Headers" group contains all header files (.h) within the project.

③ The "Sources" group contains all the C++ source files (.cpp) in the project. In the image below, the project has two C++ source files: "main.cpp" is the main function file and the application's entry point; "mainwindow.cpp" is the implementation file for the main window class, corresponding to the "mainwindow.h" file.

④ The "Forms" group contains all the UI files (.ui) within the project, as shown in the image below:

02. Add header file

(1) Copy the “LTDMC.h” header file to the newly created project folder, as shown in the following figure:

(2) In the Qt program editing interface, right-click on "Headers"① in the "DMC-Demo" project folder; click "Add Existing File"②, as shown in the figure below:

(3) A "Add Existing File" pop-up window will appear. Go to the folder "DMC-Demo"; select the "LTDMC.h" file①; click "Open"②, as shown in the figure below:

(4) After loading is complete, you can see the added "LTDMC.h" header file under "Headers" in the "Project"; double-click to enter and you can see the functions defined by the control card, as shown in the figure below:

03. Add function library

The following section uses adding a 64-bit function library as an example to explain in detail how to add a function library:

(1) To debug, press button ① in the lower left corner of the editing page, as shown in the figure below:

(2) After the debugging is complete, a "MainWindow" pop-up window will appear, as shown in the following figure:

(3) Copy the libLTDMC.h file to the "DMC-Demo" folder, as shown in the following figure:

(4) In the Qt program editing interface, right-click on "DMC-Demo"① under "Project"; click "Add Library"②, as shown in the figure below:

(5) A pop-up "Add Library" window will appear. Go to the "Type" library category ①; check "External Library" ②; click "Next" ③, as shown in the following figure:

(6) In “Details”①, confirm that “Linux(lib*.so lib*.a)” is selected in “Library type”②; click the “Browse” button to the right of “Library Files”③; in the pop-up “Select File” window, go to the folder “DMC-Demo” and select the “libLTDMC.so” file④; click “Open”⑤, as shown in the figure below:

(7) Information for "Library Files" and "Include Paths" will be loaded simultaneously ①; click "Next" ②, as shown in the following figure:

(8) Enter the "Summary" section and confirm that the information is correct ①; click "Finish" ②; finally, click " " to compile the program, as shown in the figure below. The project construction is now complete.

III. Detailed Explanation of Comprehensive Routine Programming

01. Add control card namespace

Open the Qt program, double-click "mainwindow.h" ② under "Headers" ① in the "DMC-Demo" project folder to enter the Qt program editing interface; add the code "#include "LTDMC.h" ③ at the beginning of the code file; as shown in the figure below:

02. Initialization Module

The initialization of the control card and the acquisition of card information are illustrated in the following figure:

03. Fixed-length motion module

Select "Forms" in the "DMC-Demo" project folder, double-click "mainwindow.ui" to enter the UI editing interface; select controls in the left toolbar to edit the UI, as shown in the following figure:

The final result and main code are shown in the following figure:

04. Interpolation Motion Module

This example demonstrates linear interpolation motion along axes 0 and 1. The final result and main code are shown in the following figure:

05. Zero-return motion module

06. Obtain status information

(1) First, a timer needs to be constructed, and the timer's slot function needs to be declared; write "#include Include the header file for QTimer ①; write "QTimer *timer;" ②; write "void slot_TimeEvent();" ③; as shown in the image below:


(2) Double-click "mainwindow.cpp" under "Sources" in the "DMC-Demo" project folder to enter the Qt program editing interface ①; create a timer in the program initialization; set the timer period; when the timeout period is reached, emit a signal and execute the timer slot function; start the timer, triggering the timer every 1ms ②, as shown in the figure below:

(3) Write the timer slot definition function ①; read the information in the timer slot function; as shown in the figure below:

07. Comprehensive Demonstration of Examples

Leadsun DMC-3000/5000 series motion control cards all support Linux system development. Please contact us if you need related information.

-END-

Read next

CATDOLL Amber Hybrid Silicone Head

The hybrid silicone head is crafted using a soft silicone base combined with a reinforced scalp section, allowing durab...

Articles 2026-02-22
CATDOLL 155CM Jo Silicone Doll

CATDOLL 155CM Jo Silicone Doll

Articles
2026-02-22
CATDOLL Mimi Soft Silicone Head

CATDOLL Mimi Soft Silicone Head

Articles
2026-02-22
CATDOLL 123CM Chu TPE

CATDOLL 123CM Chu TPE

Articles
2026-02-22