Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

EtherCAT Edge Programmable Industrial Motion Controller (5): Python + QT Single-Axis Homing Motion Control

For Zmotion EtherCAT motion edge controller ZMC432H, we had learnt its hardware information, API function encapsulation principle, RTSys (ZDevelop) development, debug, and diagnosis, and C++ motion control. Today, let's see other languages, " Python + QT ".

EtherCAT motion control edge controller ZMC432H supports self-researched and self-controlled software and hardware. And this EtherCAT edge controller is an independent multi-axis motion controller that is compatible with EtherCAT bus and pulse.

32 axes motion control can be achieved. At the same time, Zmotion remote HMI function is valid, which means network configuration display is provided to watch and adjust parameters in real-time.

1.png

ZMC432H has rich hardware interfaces and control functional modules, then effective and stable motion control and real-time data acquisition can be achieved to meet application requirements of both industrial control and industrial internet.

What's more, Linux system is built in ZMC432H. That is, it can be connected through local LOCAL interface, then, instruction interaction speed can be faster. The one interaction time of one single instruction and multiple instructions is about 40us.

2.png

ZMC432H hardware video description


1. Python + QT Motion Control Development

01

Configure Python + QT Development Environment & Install Required Tools

a. download python interpreter

b. install pyside 2 or pyside 6

This depends on python interpreter version, for interpreter with higher version, pyside should be used. There are 2 methods to install pyside2.

  • method 1: use win+r to open running interface, then input cmd (when installing python interpreter, configure environment variables well according to installment guidance, otherwise following commands can't be executed successfully), pip  install pyside2 -i  https://pypi.douban.com/simple/.

  • method 2: install in pycharm

c. install PyCharm Community Edition

And then in below interface, click "+" to add required tool, for example, pyside2.

3.png

d. In Pycharm, configure customized tools (used for QT interface editing)--

--open "Tool" editing as below steps--

4.png

--self-define Pyside2-uic--

Program filling & editing: Python install - \Scripts\pyside2-uic.exe

Arguments filling & editing: $FileName$ -o $FileNameWithoutExtension$.py

Working directory filling & editing: $FileDir$

5.png

--self-define QtDesigner--

Program filling & editing: Python install - \Scripts\pyside2-designer.exe

Working directory filling & editing: $ProjectFileDir$

6.png

--after configured custom tools, it can be used directly in "PyCharm" menu--

click "Tool -- Qt -- Qtdesigner" to enter UI design interface.

7.png

right click "ui" file, then click "Qt -- Pyside2 -- uic" to generate py file of ui file.

8.png


02

New Build Python Project and Add Function Library

a. use PyCharm Community Edition 2022 to open one new folder, or new build one directory after entering PyCharm Community Edition 2022, then add Python file in directory.

9.png

b. obtain Zmotion PYTHON function library and corresponding routines, you can download them from here or contact us. For Windows system, add zauxdll.dll, zmotion.dll and zauxdllPython.Py into new created folder.

10.png


03

Check PC Function Manual

The PC programming function library manual can be obtained from "download/software manual", or please contact us.

Then there are many commands:

a. connect to controller, then get link handle.

11.png

b. configure IO signals.

12.png

c. interfaces of homing motion, and homing mode details.

13.png

13-2.png

"+ 10" means it reverses after meeting position limit, that is, it will not stop when met position limit. For example, 13 = mode 3 + 10 (inverse finding), which is used when origin is in the middle.


04

One Single-Axis Homing Routine Developed by Python + QT

a. routine interface:

14.png

b. program example:

--load QT's UI file in Python--

from PySide2.QtWidgets import QMessageBox

from PySide2.QtCore import QFile, QTimer

from PySide2.QtUiTools import QUiLoader

q_state_file = QFile("mainweiget.ui")

q_state_file.open(QFile.ReadOnly)

self.ui = QUiLoader().load(q_state_file)

q_state_file.close()  

Note: at this time, self.ui means ui in qt.

--in event processing function of link button, call controller connection interface function "ZAux_OpenEth()" to connect to controller, then open timer 1 to watch controller status after linked--

15.png

--watch controller state through timer--

16.png

--use event processing function of homing button to initialize parameters before homing and to call corresponding homing mode for homing operation--

17.png

--stop current motion through event processing function of stop button--

18.png

--clear coordinates of current axis through event processing function of coordinates clearing button--

19.png



2. Debug & Watch

compile and run the routine, at the same time, connect to controller through RTSys (ZDevelop), then watch controller state in ZDevelop.

20.png

21.png

22.png


Python + QT single-axis homing routine description

image 23

video description



ABOUT ZMOTION

That's all, thank you for your reading -- EtherCAT Edge Programmable Industrial Motion Controller (5): Python + QT Single-Axis Homing Motion Control

For more information, please pay close attention to "Support"  and   "Download" , and there are other platforms about Zmotion - Youtube   &   LinkedIn   &   Twitter    &   Tiktok    &   Facebook including technical information (development environment, routine code), product showing, company development, etc.

Hope to meet you, talk with you and be friends with you.  Welcome!

This article is edited by ZMOTION, here, share with you, let's learn together.

ZMOTION: DO THE BEST TO USE MOTION CONTROL.

Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.

Zmotion Technology focuses on development of motion control technology and general motion control products, it is a national high and new technology enterprise. Due to its concentration and hard work in motion control technology, ZMOTION already become one of the fastest growing industrial motion control companies in China, and is also the rare company who has managed core technologies of motion control and real time industrial control software completely. Here, Zmotion provides motion controller, motion control card, vision motion controller, expansion module and HMI. In addition, there is one program software developed by Zmotion -- ZDevelop. It is a good choice for you to program and compile. And program through upper computer, there is PC manual.

Zmotion Technology  provides motion control card, motion controller, vision motion controller, expansion module and HMI. ( more keywords   for Zmotion: EtherCAT motion control card, EtherCAT motion controller, motion control system, vision controller, motion control PLC, robot controller, vision positioning...)

Have a good day, best wishes, see you next time.


2013-2023 版权所有 Zmotion Corp. Copyright Reserved 粤ICP备13037187号-1