ZMC408CE Hardware Introduction
The ZMC408CE is a multi-axis, high-performance EtherCAT bus motion controller launched by Zheng Motion. It has communication interfaces such as EtherCAT, EtherNET, RS232, CAN and USB flash drive. The ZMC series motion controllers can be used in various occasions that require offline or online operation.
The ZMC408CE supports 8-axis motion control, expandable to a maximum of 32 axes, and supports linear interpolation, arbitrary circular interpolation, spatial circular interpolation, helical interpolation, electronic cam, electronic gear, synchronous following and other functions.
The ZMC408CE supports three programming methods: PLC, Basic, and HMI configuration. PC-based API programming supports interfaces such as C#, C++, LabVIEW, Matlab, Qt, Linux, VB.Net, and Python.
The ZMC408CE supports 8-axis motion control and can use pulse axes (with encoder feedback) or EtherCAT bus axes. The general-purpose I/O includes 24 input ports and 16 output ports. Some I/O are high-speed I/O, with two analog AD/DA channels and an EtherCAT refresh cycle of up to 125us.
The ZMC408CE supports 8 channels of hardware compare output, hardware timer, precise output during motion, and also supports 8 channels of PWM output, with corresponding output ports OUT0-7, supporting simultaneous triggering of hardware compare output on all 8 channels.
PCIe 464M Hardware Introduction
The PCIE464M is a PCIe-based PCI Express EtherCAT bus motion control card with multiple real-time and high-precision motion control functions.
Users can directly embed the PCIe 464M into a standard PC to achieve high-performance EtherCAT motion control, enabling high-precision multi-axis synchronous control with an EtherCAT control cycle as short as 100µs!
The PCIE464M has built-in multiple high-speed I/O inputs and outputs to meet the diverse high-speed I/O application needs of users, such as: high-speed color mark latching, high-speed PWM, multi-dimensional position comparison output (PSO), vision capture, speed look-ahead, encoder position detection, and other applications.
The PCIE464M motion control card has 16 inputs and 16 outputs, allowing third-party image processing industrial PCs or PCs to realize an IPC-type machine vision motion control all-in-one machine without the need for additional configuration of IO data acquisition cards and PLCs. This simplifies the hardware architecture, saves costs, and integrates hardware and software.
PCIe 464M Video Introduction
For more details about the PCIe 464M, please click on "PCIe 464M - High-speed, high-precision, ultra-high-speed PCIe EthrtCAT real-time motion control card".
I. Python Language Development Process
The Python development environment used in this example is:
Operating system environment: Win10 64-bit
Python version: python-3.10.10-amd64.exe
PyCharm version: pycharm-community-2024.1.3.exe
1. Configure the environment and interpreter before Python development.
1) Install the Chinese language pack: Click file → setting → plugins, and then search for Chinese language pack.
2) Install the Pyside2 package (QT library) for the Python interpreter: File → Settings → Project pythonProject.
3) Configure custom controls: File → Settings → Tools → External Tools, click + to add a custom tool.
The purpose of customizing QtDesigner is to generate .ui files.
Name: QtDesigner
Group: Qt
Program: The path to designer.exe under the PySide2 installation directory.
For example: C:\Python\Python39\Scripts\pyside2-designer.exe
Working directory: $ProjectFileDir$
The purpose of customizing Pyside2-uic is to convert the created .ui file into a .py file.
Name: Pyside2-uic
Group: Qt
Program: Scripts\pyside2-uic.exe in the Python installation directory.
For example: C:\Python\Python39\Scripts\pyside2-uic.exe
Arguments: $FileName$ -o $FileNameWithoutExtension$.py
Working directory: $FileDir$
The purpose of customizing Pyside2-rcc is to convert image files into .py files.
Name: Pyside2-rcc
Group: Qt
Program: Scripts\pyside2-rcc.exe in the Python installation directory.
For example: C:\Python\Python39\Scripts\pyside2-rcc.exe
Arguments: $FileName$ -o $FileNameWithoutExtension$_rc.py
Working directory: $FileDir$
4) After configuring the custom control, you can use it directly in the PyCharm menu.
II. Motion Control Development using Python + Qt
1. New project
2. UI settings interface
1) Access the project UI settings interface: Tools → Qt → QtDesigner.
2) Set the project UI: Set the UI by dragging and dropping controls onto the interface.
3) Save the file after setting up the UI: File → Save.
3. Running the UI with Python
1) Add the Python file to run the UI: Select the project, right-click → New → Python File.
2) Add UI processing classes to the Ui_Weiget file.
·
from PySide2.QtCore import QFile from PySide2.QtUiTools import QUiLoader class UiInterFace: def __init__(self): # Load UI definition from file q_state_file = QFile("mainWeiget.ui") q_state_file.open(QFile.ReadOnly) q_state_file.close() # Dynamically create corresponding window object from UI definition self.ui = QUiLoader().load(q_state_file)
3) Add the main running Python file Main, as in step 1, and add the main entry function.
·
from PySide2.QtWidgets import QApplication from Ui_Weiget import UiInterFace if __name__ == "__main__": app = QApplication([]) # Load all controls ui_interface = UiInterFace() # Create a form object ui_interface.ui.show() # Display all controls of the main window on the interface app.exec_() # Enter the event handling loop of QApplication
4) At this point, clicking the run button in the Main file will run the program and display the UI interface.
4. Add library files and Python files that encapsulate library functions.
1) Locate the Python function library in the CD-ROM provided by the manufacturer. The path is as follows (64-bit library example).
A. Locate the "04PC Functions" folder on the CD provided by the manufacturer and click to enter.
B. Select the "PC Function Library V2.1" folder.
C. Select the "Windows Platform" folder.
D. Select the corresponding function library according to your needs. Here, we choose the 64-bit library.
E. Unzip the Python64 compressed package, which contains the corresponding Python function library and Python files that encapsulate motion functions.
2) Copy the Python library files and related files provided by the manufacturer into the newly created project.
A. Go to the dll folder, select the three files zauxdll.dl, zmotion.dll, and zauxdllPython.py and copy them.
B. Select the newly created project and paste it to paste the corresponding library files and the packaged motion Python files into the project.
3) In the Python file of the UI, import the ZAUXDLL class from the zauxdll Python file at the beginning of the file, and create a ZAUXDLL object in the UI class.
III. Introduction to Relevant PC Functions
1. The PC function manual can be viewed on the CD-ROM. The specific path is as follows.
2. Connect the controller.
3. Check if the current axis is in motion.
4. Set the pulse equivalent.
5. Set the axis movement speed.
6. Single-axis continuous motion.
7. Single-axis absolute motion.
8. Single-axis stop motion.
IV. Example Demonstration
1. Connect the controller.
·
# Connect to the controller. The default IP of the controller is 192.168.0.11. Here, we use the IP entered in the comboBox. def on_btn_open_clicked(self): strtemp = self.ui.comboBox.currentText() print("Current IP is:", strtemp) if self.Zmc.handle.value is not None: self.Zmc.ZAux_Close() self.time1.stop() self.ui.setWindowTitle("Single-axis motion") iresult = self.Zmc.ZAux_OpenEth(strtemp) # Connect to the controller if 0 != iresult: QMessageBox.warning(self.ui, "Prompt", "Connection failed") else: QMessageBox.warning(self.ui, "Prompt", "Connection successful") str_title = self.ui.windowTitle() + strtemp self.ui.setWindowTitle(str_title) self.Up_State() # Refresh function self.time1.start(100) # Start the timer
2. Axial motion.
·
# Axis running function def on_btn_Run_clicked(self): if self.Zmc.handle.value is None: QMessageBox.warning(self.ui, "Warning", "Controller not connected") return # Get axis motion status 0 – in motion, -1 – not in motion isidle=self.Zmc.ZAux_Direct_GetIfIdle(self.axis_Num)[1].value isidle=int(isidle) if self.mode == 1 and not isidle: QMessageBox.warning(self.ui, "Warning", "Not stopped") return # Set pulse equivalent str_tmp = self.ui.edit_Units.text() float_tmp = float(str_tmp) self.Zmc.ZAux_Direct_SetUnits(self.axis_Num, float_tmp) # Set pulse unit # Set motion speed str_tmp = self.ui.edit_Speed.text() float_tmp = float(str_tmp) self.Zmc.ZAux_Direct_SetSpeed(self.axis_Num, float_tmp) # Set motion speed # Set acceleration str_tmp = self.ui.edit_Accel.text() float_tmp = float(str_tmp) self.Zmc.ZAux_Direct_SetAccel(self.axis_Num, float_tmp) # Set acceleration # Set deceleration str_tmp = self.ui.edit_Decel.text() float_tmp = float(str_tmp) self.Zmc.ZAux_Direct_SetDecel(self.axis_Num, float_tmp) # Set deceleration # Set S-curve str_tmp = self.ui.edit_Sramp.text() float_tmp = float(str_tmp) self.Zmc.ZAux_Direct_SetSramp(self.axis_Num, float_tmp) # Set S-curve if 0 == self.mode: # Single-axis continuous motion: `self.Zmc.ZAux_Direct_Single_Vmove(self.axis_Num, self.direction)` elif 1 == self.mode: `str_tmp = self.ui.edit_Distance.text()` `float_tmp = float(str_tmp)` # Single-axis relative motion: `self.Zmc.ZAux_Direct_Single_Move(self.axis_Num, -float_tmp if self.direction == -1 else float_tmp)`
3. Stop the axis movement.
·
#Stop axis movement def on_btn_Stop_clicked(self): if self.Zmc.handle.value is None: QMessageBox.warning(self.ui, "Warning", "Controller not connected") return #Get axis movement status 0 – in motion, -1 – not in motion isidle=self.Zmc.ZAux_Direct_GetIfIdle(self.axis_Num)[1].value if isidle: QMessageBox.warning(self.ui, "Warning", "Stopped") return #Stop single axis movement self.Zmc.ZAux_Direct_Single_Cancel(self.axis_Num, 2)
4. Run the program and observe the results.
Run the Python program and observe its operation using the RTSys software.
Full code download address
▼
This concludes our presentation on the development of the EtherCAT motion controller host computer using Python + Qt (Part 1): Linking and Single-Axis Motion.
For more exciting content, please follow the "Zheng Motion Assistant" WeChat official account. For related development environment and example code, please contact Zheng Motion's technical sales engineer: 400-089-8936.
This article is original content from Zheng Motion Technology. We welcome everyone to reprint it for mutual learning and to jointly improve China's intelligent manufacturing level. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.