<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zmotion Controller</title>
    <description>The latest articles on DEV Community by Zmotion Controller (@zmotion).</description>
    <link>https://dev.to/zmotion</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F956955%2F06d40061-5d91-49a7-b9a0-f7dde7c1e91d.png</url>
      <title>DEV Community: Zmotion Controller</title>
      <link>https://dev.to/zmotion</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zmotion"/>
    <language>en</language>
    <item>
      <title>What are Differences Between EtherCAT &amp; Ethernet ? What is Communication Period?</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Mon, 12 Aug 2024 03:48:20 +0000</pubDate>
      <link>https://dev.to/zmotion/what-are-differences-between-ethercat-ethernet-what-is-communication-period-3lmg</link>
      <guid>https://dev.to/zmotion/what-are-differences-between-ethercat-ethernet-what-is-communication-period-3lmg</guid>
      <description>&lt;p&gt;Hello, dear friends, here is Zmotion again.&lt;/p&gt;

&lt;p&gt;Welcome.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.zmotionglobal.com/support_info_87.html" rel="noopener noreferrer"&gt;Last article&lt;/a&gt;, we talked about some properties of &lt;a href="https://en.wikipedia.org/wiki/EtherCAT" rel="noopener noreferrer"&gt;EtherCAT&lt;/a&gt;. And today Zmotion brings more details about how to achieve EtherCAT. In addition, communication period also will be introduced. Specifically, what is communication period, and what are SDO and PDO.&lt;/p&gt;

&lt;p&gt;Firstly, it must be declared, this article is mainly for friends who want to know more information. Namely, you still can use Zmotion motion controller seasily even though you don't get messages from this article. But know more, solve complex problems easily.&lt;/p&gt;

&lt;p&gt;OK, Let's begin!&lt;/p&gt;

&lt;p&gt;As we all know, it needs stable and real-time communication in industrial site, and sensor and IO signals are required to respond at high-speed, motor data are transferred in real-time. What's more, before EtherCAT, CAN bus has already existed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However, fieldbus automation system becomes huge increasingly, which means traditional bus is hard to meet nowadays needs&lt;/strong&gt;, for example, bandwidth is not high enough, transferred data is not enough, and it cannot make full use of IT technology. Therefore, a kind of fieldbus based on Ethernet is born, and EtherCAT is outstanding particularly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm05eoth6kit3ckevgdgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm05eoth6kit3ckevgdgk.png" alt="Image description" width="697" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, someone may feel confused, EtherCAT bases on Ethernet fieldbus, why not use Ethernet directly.&lt;/p&gt;

&lt;p&gt;That's because some fieldbus communication features are totally different from in IT area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. one single system has a lot of node devices.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. usually, these nodes transfer less data, but require high real-time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If each node uses an Ethernet data frame to communicate, the final communication efficiency will be very low. According to an official calculation example, the final bandwidth utilization may be less than 5%, and Ethernet-based communication protocols, such as TCP, it will bring additional bandwidth overhead and delay, then a large amount of bandwidth is occupied by invalid data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa26wquxd82lsmtygsqf4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa26wquxd82lsmtygsqf4.png" alt="Image description" width="640" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For EtherCAT, all nodes use one data frame. After the master station sends the data frame, all slave stations will process the data in flight, read what they need, insert the data they need to return, and then continue to send the data frame until meeting the last node, next use the full-duplex feature of Ethernet to return the data to the master station.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrjava4mpqdicctk6ci4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvrjava4mpqdicctk6ci4.jpg" alt="Image description" width="800" height="324"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Through this transmission method, the maximum effective data rate of data frames can exceed 90%. And the master station is the only device that is allowed to actively send data packets, and other nodes can only transmit packets sequentially, which can avoid Ethernet common conflicts and delays in the network, then ensure EtherCAT data transmission is in real-time.&lt;/p&gt;

&lt;p&gt;Moreover, when the slave station uses a dedicated chip (ESC) to process data packets in flight, it is completely processed by hardware, so that the communication time of the entire EtherCAT network remains stable and predictable, and it has nothing to do with the different deployment of each slave station.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrcjfq9cybbaganybjm9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrcjfq9cybbaganybjm9.png" alt="Image description" width="695" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;--Question:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If there is only one data packet, encountering the problem that maybe in slave station or one certain circuit, how to check?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;--Answer:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Actually EtherCAT has a series of smart designs, specific abnormal node still can be found even when data is transferring precisely. And Zmotion also has configured small tools, they will be mentioned in following articles.&lt;/p&gt;

&lt;p&gt;Periodic data and aperiodic data both can be transmitted in the EtherCAT network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Periodic data is exchanged through PDO (Process Data Object)&lt;/strong&gt;, which is generally used for real-time data exchange, such as the command position and feedback position of the motor, the interaction of IO signals, etc.&lt;/p&gt;

&lt;p&gt;Aperiodic data can be transmitted through the mailbox protocol, the most common is CoE (Canopen Over EtherCAT), which can transmit information through SDO (Service Data Object). SDO is generally used for non-real-time communication, such as the configuration of motor parameters (such as resolution, maximum current, etc.), including the PDO configuration information of the slave station.&lt;/p&gt;

&lt;p&gt;Configuring PDO is like buying a high-speed rail ticket for your data, so that the master station and the slave station already know in advance what data will be on the high-speed rail before the official work, and the ESC chip of each slave station will be automatically removed for corresponding the data position, that is, ESC chip is inserted into the data that needs to be returned. In this way, it can reduce invalid data and speed up processing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywprziga9g0cva91lm3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fywprziga9g0cva91lm3g.png" alt="Image description" width="644" height="630"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some old users may consider, in real operation, they don't think so much when using our motion controller.&lt;/p&gt;

&lt;p&gt;Yeah, there is one parameter developed by R&amp;amp;D to configure PSO list easily, "Drive_Profile". And actually you don't need to configure by yourself, because it is set in script program of commonly used motor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The transmission cycle of PDO information is what we often call the EtherCAT communication period.&lt;/strong&gt; For example, the regular firmware of Zmotion defaults to a cycle of 1ms (1K communication frequency), and some products of Zmotion can set a cycle of 125us (8K communication frequency). Why is the default 1ms instead of a shorter period (higher frequency)? What is the controller doing in this 1ms? What is the slave station doing again?&lt;/p&gt;

&lt;p&gt;This needs to start with the working mode of the CSP and the control loop of the motor, which will be introduced in detail in later chapters. Generally, 1ms is small enough (1K is high enough). Moreover, the synchronization between motors is not based on the arrival time of data frames, but on distributed clocks, which can achieve nanosecond-level synchronization, as introduced in the previous article.&lt;/p&gt;

&lt;p&gt;As mentioned earlier, because of the unique design of the EtherCAT data frame, the effective data rate is very high, so the 100M bandwidth of Ethernet can be fully utilized in the field of industrial automation. In fact, the 100M bandwidth can also enable many motors to achieve a 1ms communication cycle, for example, Zmotion has a 128-axis controller.&lt;/p&gt;

&lt;p&gt;One of the questions left over from last time is, since the EtherCAT 100M bus is so good, why do we need to design Gigabit and 10 Gigabit buses?&lt;/p&gt;

&lt;p&gt;The answer is that with the development of technology, larger and more complex systems have emerged. For example, advanced logistics systems or magnetic levitation systems require a lot of axes (hundreds or even thousands), and precise synchronization between these axes is required, or measurement equipment that collects a large amount of sensor data has higher requirements on the bandwidth of the bus.&lt;/p&gt;

&lt;p&gt;Higher bandwidth can allow fieldbus to enter more application fields, and a stronger bus can also support the design of complex systems that were not available before.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzjrw7rvihvy42064h6ih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzjrw7rvihvy42064h6ih.png" alt="Image description" width="697" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At Last: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmvtp6licfrqlhjg45k6t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmvtp6licfrqlhjg45k6t.jpg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/ppGw5TevLAM" rel="noopener noreferrer"&gt;video description&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ABOUT ZMOTION&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- &lt;a href="https://www.zmotionglobal.com/support_info_90.html" rel="noopener noreferrer"&gt;What are Differences Between EtherCAT &amp;amp; Ethernet ? What is Communication Period?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together.&lt;/p&gt;

&lt;p&gt;Zmotion: Better Motion Control, Smarter Life.&lt;/p&gt;

&lt;p&gt;Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Fast Debug &amp; Diagnose EtherCAT Motion Controller's Pulse "AXIS" Interface</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Mon, 05 Aug 2024 03:51:17 +0000</pubDate>
      <link>https://dev.to/zmotion/how-to-fast-debug-diagnose-ethercat-motion-controllers-pulse-axis-interface-fc4</link>
      <guid>https://dev.to/zmotion/how-to-fast-debug-diagnose-ethercat-motion-controllers-pulse-axis-interface-fc4</guid>
      <description>&lt;p&gt;&lt;a href="https://www.zmotionglobal.com/support_info_88.html" rel="noopener noreferrer"&gt;Debug and diagnose AXIS for EtherCAT motion controller&lt;/a&gt;, &lt;a href="https://www.zmotionglobal.com/pro_info_167.html" rel="noopener noreferrer"&gt;ZDevelop&lt;/a&gt; can be used, and it can rapidly check running situation of pulse-drives, please refer to below "problem checking" processes.&lt;/p&gt;

&lt;p&gt;EtherCAT motion controller supports EtherCAT protocol and there are AXIS pulse interfaces (here, ZMC432 EtherCAT motion control), it supports many communication interfaces, mainly including EtherCAT, EtherNET, RS232, RS485, CAN, U disk, etc. It can be connected to ZDevelop software through EtherNET or RS232 serial port to complete test run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuea7b4oplc2lxa2g530m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuea7b4oplc2lxa2g530m.png" alt="Image description" width="685" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Before testing, please do connection.
&lt;/h2&gt;

&lt;p&gt;There are 2 ways: EtherNET or Serial port.&lt;/p&gt;

&lt;p&gt;--Ethernet--&lt;/p&gt;

&lt;p&gt;select relative IP address, please note 192.168.0.11 is the factory IP, and this IP and PC IP should be in the same network segment.&lt;/p&gt;

&lt;p&gt;--Serial port--&lt;/p&gt;

&lt;p&gt;Use serial port to connect, default parameters are Baud rate 38400, data bit 8, no parity, and it will resume default parameters when power-off.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrgr8fiosdzkp0xaqphv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqrgr8fiosdzkp0xaqphv.png" alt="Image description" width="500" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Next, Do Configuration
&lt;/h2&gt;

&lt;p&gt;After connected to controller, enable the drive firstly. Specifically, send OP (ionum, ON) command to open enable according to enable signal OUT No. described in axis interface of hardware manual. For example, for ZMC432 controller , we need to send OP(12, ON) to enable the driver on AXIS 0.&lt;/p&gt;

&lt;p&gt;Send it directly on "command" or operate it through "View"-"OP". For those stepper drives that can enable directly when power-on, no need to operate this.&lt;/p&gt;

&lt;h4&gt;
  
  
  (1) Basic Parameters
&lt;/h4&gt;

&lt;p&gt;Following parameters can be quickly configured from "View"--"Manual"/"Axis Parameter", or new build the project and write the command into controller.  &lt;/p&gt;

&lt;p&gt;A. BASE&lt;br&gt;
BASE is used to select the axis No.to be connected for pulse axis. Axis No. connected on DB head is AXIS No. marked on controller panel.&lt;/p&gt;

&lt;p&gt;B. ATYPE&lt;br&gt;
ATYPE is used to set axis type. When ATYPE=1/7, it is pulse axis without feedback, when ATYPE=4/5, it is encoder axis with feedback. If encoder is needed to connect independently, set ATYPE=3/6.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiklje2z4e7wco9sb1xzb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiklje2z4e7wco9sb1xzb.png" alt="Image description" width="432" height="801"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;C. UNITS&lt;br&gt;
UNITS is used to set the pulse equivalent, which is configured according to the number of pulses per revolution of the driver. As the basic unit of the controller, it can be set as the number of pulses required for the motor to rotate 1°. If the driver rotates 10000 pulses per revolution, it can be set to UNITS=10000/360.&lt;/p&gt;

&lt;p&gt;Conversion relationship: If UNITS=10000, the linear command MOVE(5) means sending 50000 pulses, the running speed SPEED=10 means sending 100000 pulses per second.&lt;/p&gt;

&lt;p&gt;D. SPEED&lt;br&gt;
SPEED means speed, ACCEL means acceleration and DECEL means deceleration , they are basic speed parameters. In addition, there are others, SRAMP instruction is usued to set S curve, prolonging acceleration time, then speed changes become more gently, and shake can be less, but VP_MODE instruction is used to set SS curve, acceleration transitions will be smooth, and the trajectory is more smooth with less compact.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8vfvypj0lg3vauwsvgx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8vfvypj0lg3vauwsvgx.png" alt="Image description" width="684" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Pulse Modes
&lt;/h4&gt;

&lt;p&gt;The factory default pulse mode of the controller is pulse + direction, the pulse mode needs to be matched to run, so it is necessary to confirm the pulse mode of the driver.&lt;/p&gt;

&lt;p&gt;In fact, there are three pulse modes, pulse + direction, double pulse and quadrature pulse &lt;a href="https://www.zmotionglobal.com/pro_list_62.html" rel="noopener noreferrer"&gt;(valid controllers)&lt;/a&gt;, and positive/negative logic both can be configured.&lt;/p&gt;

&lt;p&gt;If you need to modify the mode, INVERT_STEP instruction can do this. The initial value of INVERT_STEP is 0, which means pulse + direction mode.  &lt;/p&gt;

&lt;p&gt;Then, grammar: INVERT_STEP = mode&lt;/p&gt;

&lt;p&gt;mode: mode selection, default is 0, the mode value represented by the lower 8 bits (bit 0-bit 7) is as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcj1e6o9jmjtuewmzw0c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftcj1e6o9jmjtuewmzw0c.png" alt="Image description" width="434" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The levels corresponding to each mode are as follows.&lt;/p&gt;

&lt;p&gt;If the polarity is reversed, the reference movement direction is opposite to the original one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff74le94pn3e1hq5mgn62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff74le94pn3e1hq5mgn62.png" alt="Image description" width="431" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The upper 8 bits (bit 8-bit 15) indicate the direction change protection time, in microseconds: 0-255&lt;/p&gt;

&lt;p&gt;Setting method: INVERT_STEP (axis No.) = 256*100+6, double pulse mode 6, protection time 100 microseconds.&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Basic Operations
&lt;/h4&gt;

&lt;p&gt;A. Motion&lt;/p&gt;

&lt;p&gt;Use the manual motion window of the view menu or online commands to send the MOVE linear motion command for debugging, and obtain the motion of the axis through the DPOS target position (or MPOS feedback position), etc. You can also use the view window "Scope" of the ZDevelop software to sample motion waveforms in real time.&lt;/p&gt;

&lt;p&gt;The direction of motor movement is related to the motor polarity setting and INVERT_STEP positive/negative logic setting.&lt;/p&gt;

&lt;p&gt;B. Parameters Checking&lt;/p&gt;

&lt;p&gt;After the axis parameters are configured, they can be viewed in the "Axis Parameters" window. And parameters can automatically refresh and display in real time, and they can be modified through double-clicking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p7v5jfntnnito17wdz1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9p7v5jfntnnito17wdz1.png" alt="Image description" width="438" height="637"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (4) Abnormal Alarm
&lt;/h4&gt;

&lt;p&gt;When an abnormal alarm occurs, the "Command and Output" window of the ZDevelop software will print an error message, or generate an AXISSTATUS alarm.&lt;/p&gt;

&lt;p&gt;AXISSTATUS is the axis status parameter, which is used to judge whether the axis is currently abnormal, and the abnormal information will be displayed bit by bit. Multiple abnormal information can be superimposed. Following form can be referred.&lt;/p&gt;

&lt;p&gt;For example, when AXISSTATUS shows 20h, which means it meets negative hard position limit now, then the axis stops immediately. When AXISSTATUS displays 1000h, indicating that the pulse frequency is too fast. Generally, this kind of problem occurs only in high-resolution devices. When this alarm occurs, it only needs to increase MAX_SPEED value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aa52vm6mg3qxvwg84ve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2aa52vm6mg3qxvwg84ve.png" alt="Image description" width="432" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the trial run, make sure that the hardware limit switch is configured successfully, as a safety protection for the machine to prevent overshooting.&lt;/p&gt;

&lt;p&gt;After confirming that the machine can operate, use the DATUM command to configure the zero return mode, and the DATUM_IN command to configure the origin sensor to map to the input port. For the homing instructions, refer to the former technical articles.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy34qi73hh6r3jv6in6y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdy34qi73hh6r3jv6in6y.png" alt="Image description" width="664" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The hard position limit switch is the limit switch that limits the maximum "allowable travel range" of an axis. In addition, it is a physical switch element, which is mapped to the corresponding input switch signal by the instruction. And determine whether to flip the signal according to the switch signal (normally opened or normally closed). After the setting is completed, the hard limit switch is touched, then the corresponding axis stops immediately, and the stop deceleration is FASTDEC.  &lt;/p&gt;

&lt;p&gt;The soft position limit switch will limit the "working range" of the axis, and the limit position is directly set by the command. After the axis reaches the set position, it will immediately stop moving with the deceleration FASTDEC.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzgr3jobuv3s5sqgxno7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnzgr3jobuv3s5sqgxno7.png" alt="Image description" width="719" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (5) Configuration Grammar
&lt;/h4&gt;

&lt;p&gt;FWD_IN = input port No. connected to positive hard limit, -1 cancels mapping.&lt;/p&gt;

&lt;p&gt;REV_IN =  input port No. connected to negative hard limit, -1 cancels mapping.&lt;/p&gt;

&lt;p&gt;FS_LIMIT = forward movement travel limit, cancel setting larger value.&lt;/p&gt;

&lt;p&gt;RS_LIMIT = negative motion travel limit, cancel setting a larger value&lt;/p&gt;

&lt;p&gt;For example, the status bar below the ZDevelop software prompts axis0 alarm to indicate a red alarm error. Check the AXISSTATUS parameter of axis 0 in the axis parameters, and the prompt is 30h. According to the AXISSTATUS command description, it is known that the positive and negative limit alarms occurred. Check the limit configuration. That is, the configuration of IN0 and IN1 corresponding to FWD_IN(0)=0 and REV_IN(0)=1, and whether the related input INVERT_IN reverses the level state.  &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Manual Motion For Quick Debug
&lt;/h2&gt;

&lt;p&gt;Close all software except ZDevelop, use ZDevelop to connect to the controller at the same time, download the empty program, manually set the axis number to be debugged according to the previous instructions, set the axis type ATYPE, pulse equivalent UNITS, acceleration ACCEL, deceleration DECEL, speed SPEED, and then Open "View" - "Manual", and manually operate the motor for trial run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gw7c1nmq39vuf9ea028.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gw7c1nmq39vuf9ea028.png" alt="Image description" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Press and hold "Left"/"Right", the motor will continue to move, release it to stop. "Command position" shows the current pulse DPOS (unit: UNITS). Fill in the "Distance" parameter, click "Motion", when "Absolute" is checked, the motor moves to the position of the distance parameter, when "Absolute" is not checked, the motor continues to move according to the distance parameter.  &lt;/p&gt;

&lt;p&gt;After setting according to the above steps, if the motor cannot move, please refer below "troubleshoot"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvq9jeed8sqdav70trt69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvq9jeed8sqdav70trt69.png" alt="Image description" width="800" height="706"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Choose Bus Motion Controller in the era of Industrial Ethernet?</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Mon, 29 Jul 2024 03:09:28 +0000</pubDate>
      <link>https://dev.to/zmotion/how-to-choose-bus-motion-controller-in-the-era-of-industrial-ethernet-1kae</link>
      <guid>https://dev.to/zmotion/how-to-choose-bus-motion-controller-in-the-era-of-industrial-ethernet-1kae</guid>
      <description>&lt;p&gt;Question A:&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Pulse_(signal_processing)" rel="noopener noreferrer"&gt;Pulses &lt;/a&gt;belong to parallel communication, but EtherCAT belongs to serial communication, then communication delay may be produced, synchronization of bus is worse than pulses?&lt;/p&gt;

&lt;p&gt;Answer:&lt;br&gt;
Actually it is opposite, EtherCAT doesn't equal to EtherNet, and synchronization between master and slave stations of EtherCAT doesn't coordinate through arrival time of data frame. From order issuance, EtherCAT synchronization is better.&lt;/p&gt;

&lt;p&gt;Question B:&lt;br&gt;
There is 1000M bus, which is 10 times of 100M, therefore, our synchronization also is better than EtherCAT ？&lt;/p&gt;

&lt;p&gt;Answer:&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/EtherCAT" rel="noopener noreferrer"&gt;EtherCAT&lt;/a&gt; is extremely advanced fieldbus, and the distributed clock brought by specialized communication chip (ESC) to achieve synchronization of each slave station tasks, the synchronization error is &amp;lt;&amp;lt;1us (it should be 20ns in theory).&lt;/p&gt;

&lt;p&gt;Next, let's learn deeply.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyzgre638sm6y5k3l54d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyzgre638sm6y5k3l54d.png" alt="Image description" width="698" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EtherCAT is an open and advanced fieldbus developed by the EtherCAT Foundation based on Ethernet. It ensures efficient and reliable data transmission through a series of unique mechanisms.&lt;/p&gt;

&lt;p&gt;And EtherCAT only needs to use a 100M network cable to realize data transmission. The common topology structure is daisy chain, namely, the master station (controller) is connected to the first slave station (motor, IO module, etc.), then the first slave station is connected to the second slave station, connect continuously. In addition, EtherCAT also supports other topologies.&lt;/p&gt;

&lt;p&gt;Although you only see one network cable connected, the 100M network cable actually contains 4 lines, two of which are used to output data (TX), and two are used to return data (RX). Therefore, in fact, one loop is formed internally, as shown in the figure below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx4bi8vtlki4k1911y5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjx4bi8vtlki4k1911y5m.png" alt="Image description" width="685" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The EtherCAT master station needs to use a real-time operating system + standard Ethernet chip + EtherCAT protocol stack, and the slave station needs to use a special communication chip (ESC) to ensure high-speed and stable communication.&lt;/p&gt;

&lt;p&gt;Therefore, although their external interfaces are all network ports "RJ45 interface",  EtherCAT and EtherNET are very different at the hardware level, not just the difference in the data layer.&lt;/p&gt;

&lt;p&gt;During the official work of EtherCAT (PDO communication), only one data frame is transmitted at high speed between the master station and the slave station. When passing through each slave station, each slave station takes down the required data, such as, command position, control word, etc., then it inserts the data that needs reporting (feedback position, motor status, etc.). It is the same principle as one high-speed train has to pick up and drop off passengers at every station.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5kyf6um4ralldvlr7e0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5kyf6um4ralldvlr7e0s.png" alt="Image description" width="695" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But it is faster than high-speed rail, EtherCAT processes data in flight through a dedicated chip (ESC), instead of waiting until the data is completely received before processing and sending. Therefore, high-speed data exchange can be achieved.&lt;/p&gt;

&lt;p&gt;As mentioned before, the EtherCAT slave chip (ESC) has a distributed clock. What exactly is this?&lt;/p&gt;

&lt;p&gt;The field bus is generally serial communication, so there must be a time difference when reaching each slave station. No matter how fast the high-speed rail is, it cannot reach Shanghai and Kunshan at the same time.&lt;/p&gt;

&lt;p&gt;So how does EtherCAT ensure that the slave stations act in unison without falling behind? The answer is the distributed clock.  &lt;/p&gt;

&lt;p&gt;The EtherCAT master station will select the first slave station with clock (DC) function as the clock master station (DC Master), and each slave station will be synchronized according to the time of the clock master station. In this way, if multiple motors do multi-axis interpolation, they can refer to the precise clock signal to sample at a unified time (collect command data), and act at a unified time, like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxdaevot0sih3bc3orot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxdaevot0sih3bc3orot.png" alt="Image description" width="685" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each slave station has its own watch, like those police and gangster movies, the officer said: Now put on the watch, and act together at 8:50 in the evening (the expression must be serious when you say it).&lt;/p&gt;

&lt;p&gt;Of course, the clock (DC) of EtherCAT is not dialed manually, but EtherCAT calculates the clock error between each slave station through a complex mechanism, then corrects it in real time to ensure that the time keeps a very small error between each slave station (much less than 1us, the official test data is about 20ns).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ocxblc9iixk4e2paldr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ocxblc9iixk4e2paldr.png" alt="Image description" width="669" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Going back to the original question, compared with the pulse motor, the pulse drive receives the data at the same time, but there is no way to coordinate the clock signal between the drives, so it is inferior to EtherCAT in theory.&lt;/p&gt;

&lt;p&gt;In fact, most applications are restricted in the performance of motor debugging, so our feelings are not obvious, but EtherCAT has already laid the foundation for precise synchronization at the bottom layer.&lt;/p&gt;

&lt;p&gt;Some friends may say, don't brag, I know that the next generation standard of  EtherCAT is EtherCAT G, which is also the Gigabit bus, which means Gigabit is better. However, the fact is that EtherCAT G is not designed to improve synchronization ( It is already very good), what is its significance, it will be introduced in detail in the next technical support article).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5wpmn6wxygiozoyjh3n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm5wpmn6wxygiozoyjh3n.png" alt="Image description" width="696" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the above advantages, EtherCAT has many other advantages, including simple wiring, convenient interference checking, no trouble of losing pulses, rich transmission data (such as absolute value data, torque status), etc.&lt;/p&gt;

&lt;p&gt;Finally, there is one 8-Axis EtherCAT motion controller, &lt;a href="http://www.zmotionglobal.com/pro_info_268.html" rel="noopener noreferrer"&gt;ZMC408CE&lt;/a&gt;. Currently, it supports the max number of slave stations and it is with the best compatibility. What's more, there is a &lt;a href="https://youtu.be/d8BzwwviSNo" rel="noopener noreferrer"&gt;video introduction&lt;/a&gt; for you, please enjoy it and hope you like it.&lt;/p&gt;

</description>
      <category>ethercat</category>
      <category>ethernet</category>
    </item>
    <item>
      <title>EtherCAT Motion Control Card QT Development Tutorial (1)</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Wed, 08 Nov 2023 09:41:17 +0000</pubDate>
      <link>https://dev.to/zmotion/ethercat-motion-control-card-qt-development-tutorial-1-82j</link>
      <guid>https://dev.to/zmotion/ethercat-motion-control-card-qt-development-tutorial-1-82j</guid>
      <description>&lt;p&gt;Today, Zmotion talks about how to develop EtherCAT motion control card by QT. And there is one complete tutorial series that composed by three aspects.&lt;/p&gt;

&lt;p&gt;Here, &lt;a href="http://www.zmotionglobal.com/support_info_120.html" rel="noopener noreferrer"&gt;the first part&lt;/a&gt;, we will show you how to configure development environment with one simple motion control application example, specifically, the linear interpolation motion control.&lt;/p&gt;

&lt;p&gt;Let's begin.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Hardware Support
&lt;/h2&gt;

&lt;p&gt;Before our development configuration, we need to know which hardware we could use. Here, ECI2828 motion control card is used. &lt;/p&gt;

&lt;p&gt;--Brief Basic Introduction--&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.zmotionglobal.com/pro_info_236.html" rel="noopener noreferrer"&gt;ECI2828&lt;/a&gt; belongs to economical motion control card, and it supports rich motion control functions, such as, up to 16 axes linear interpolation, any circular interpolation, space arc, helical interpolation, electronic cam, synchronous follow, virtual axis, robot instructions, etc. And real-time motion control can be achieved through optimized network communication protocol.&lt;/p&gt;

&lt;p&gt;--Hardware Configuration--&lt;/p&gt;

&lt;p&gt;ECI2828 motion control card is linked with PC through ethernet and RS232, then card can receive the command from PC to run. When there is no enough motion axes, IO or analog resources, expansion modules can be connected through EtherCAT bus and CAN bus.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd32r0oa821beas6r63l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd32r0oa821beas6r63l.png" alt="Image description" width="800" height="445"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Programming Method--&lt;/p&gt;

&lt;p&gt;There are two programming methods, host computer programming languages or ZBasic, ZPLC, ZHMI that are developed by Zmotion. Here, upper computer programming platform QT is used for ECI2828, and VC, VB, VS, C++, C#, and others all can be used. It only needs to call dynamic library "zmotion.dl" when programming is running. While debugging, we could connect ECI2828 to &lt;a href="http://www.zmotionglobal.com/pro_list_75.html" rel="noopener noreferrer"&gt;ZDevelop&lt;/a&gt; that is one free programming software launched by Zmotion itself for debugging and observing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F09a6efkbba4nxodj780t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F09a6efkbba4nxodj780t.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. How to Develop Motion Control by Qt
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) New Build Qt Project
&lt;/h4&gt;

&lt;p&gt;a. build one new Qt project&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1twlsakd1cmuwm4xcal4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1twlsakd1cmuwm4xcal4.png" alt="Image description" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. select project path&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rkosn7g8t50p563r8ow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rkosn7g8t50p563r8ow.png" alt="Image description" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. select Qt compile set (kits)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4thjr6l9kh5ufd0sfc1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4thjr6l9kh5ufd0sfc1.png" alt="Image description" width="800" height="402"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. select basic type&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbn6c6dqgu51dlszpy1ms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbn6c6dqgu51dlszpy1ms.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Copy Files Related to Function Library to New Created Project
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fut4ja5h659qsyi73cyjr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fut4ja5h659qsyi73cyjr.png" alt="Image description" width="593" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Add Static Library (zmotion.lib) of Function Library to New Created Project
&lt;/h4&gt;

&lt;p&gt;a. add function library 1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjx9bbv1ypx2u43gytah.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjx9bbv1ypx2u43gytah.png" alt="Image description" width="464" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. add function library 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hepox8il6cufsiz0fw7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9hepox8il6cufsiz0fw7.png" alt="Image description" width="506" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. add function library 3&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5sma6ulp83rll9jvzhmi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5sma6ulp83rll9jvzhmi.png" alt="Image description" width="506" height="483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. add head file related to function library to project&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3x0cfu2axt7ckuniwwg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb3x0cfu2axt7ckuniwwg.png" alt="Image description" width="456" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;e. state head file and define connection handle&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwuyv5rpd9rfuzdqderk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzwuyv5rpd9rfuzdqderk.png" alt="Image description" width="543" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Software Support
&lt;/h2&gt;

&lt;p&gt;We talked about hardware support above, now let's see what we have and what we need to use in the software level.&lt;/p&gt;

&lt;p&gt;For host computer development, Zmotion provides one uniform PC function library, there are PC programming manual and examples of each platform and each programming language. &lt;/p&gt;

&lt;p&gt;Generally, ethernet is used to connect controller to IPC, the corresponding connection interface is ZAux_OpenEth(), if the connection is successful, the interface will return one link handle, then it can control the controller through this handle.&lt;/p&gt;

&lt;p&gt;Next, let's see some basic operation PC commands.&lt;/p&gt;

&lt;p&gt;(1) how to build the connection&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngft4ts6lb46b7p06wna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngft4ts6lb46b7p06wna.png" alt="Image description" width="639" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2) how to achieve multi-axis interpolation&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fap0rrxedgd609pic44x4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fap0rrxedgd609pic44x4.png" alt="Image description" width="535" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(3) how to get axis position information&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1njar4x2g9xg9qswc56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl1njar4x2g9xg9qswc56.png" alt="Image description" width="535" height="646"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(4) how to get axis speed information&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dzwc1b7vcuq3c47pfad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1dzwc1b7vcuq3c47pfad.png" alt="Image description" width="637" height="484"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. How to Develop Multi-Axis Interpolation Motion by Qt
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Multi-Axis Interpolation Motion in Qt Interface
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5z6qrgqyi431q42tqwl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5z6qrgqyi431q42tqwl.png" alt="Image description" width="458" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Development Steps
&lt;/h4&gt;

&lt;p&gt;a. call controller link interface "ZAux_OpenEth()" in construct function to build the connection with controller, when connected successfully, open timer to monitor controller axis information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    int rint=0;
    ui-&amp;gt;setupUi(this);
    //system ON, connect to controller automatically
    rint = ZAux_OpenEth("192.168.0.223", &amp;amp;g_handle);
    //if link successfully, open timer
    if(rint==0)
    {
       startTimer(50);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;b. update each axis' position and speed information through the timer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//timer event
void MainWindow::timerEvent(QTimerEvent *event)
{
    QString StrText;
    float AxisDpos[3]={0};
    float AxisMspeed[3]={0};
    if(NULL != g_handle)
    {
        for(int i=0;i&amp;lt;3;i++)
        {
            //obtain axis 0 position
            ZAux_Direct_GetDpos(g_handle,i,&amp;amp;AxisDpos[i]);
            //obtain axis 0 speed
            ZAux_Direct_GetMspeed(g_handle,i,&amp;amp;AxisMspeed[i]);
        }
        StrText = QString("#axis 0 position:（%1） #axis 1 position:（%2） #axis 2 position:（%3）").arg(AxisDpos[0]).arg(AxisDpos[1]).arg(AxisDpos[2]);
        ui-&amp;gt;AxisDpos-&amp;gt;setText(StrText);
        StrText = QString("#axis 0 speed:（%1） # axis 1 speed：（%2） # axis 2 speed：（%3）").arg(AxisMspeed[0]).arg(AxisMspeed[1]).arg(AxisMspeed[2]);
        ui-&amp;gt;AxisMspeed-&amp;gt;setText(StrText);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;c. call multi-axis interpolation command to do multi-axis interpolation motion through open button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//open button slot function: start linear interpolation motion
void MainWindow::on_RunButton_clicked()
{
    QString Text;
    int AxisList[3] = {0,1,2};
    float DisList[3]={0};
    //set axis parameters
    for(int i=0; i&amp;lt;3; i++)
    {
        //set axis type as pulse axis
        ZAux_Direct_SetAtype(g_handle,i,1);
        //set pulse amount, generally it is the number of required pulses for one 1mm
        ZAux_Direct_SetUnits(g_handle,i,1000);
        //set axis motion speed
        ZAux_Direct_SetSpeed(g_handle,i,200);
        //set axis acceleration
        ZAux_Direct_SetAccel(g_handle,i,2000);
        //set axis deceleration
        ZAux_Direct_SetDecel(g_handle,i,2000);
    }
    //update position data of first row
    Text = ui-&amp;gt;DisX1-&amp;gt;toPlainText();
    DisList[0] = Text.toFloat();
    Text = ui-&amp;gt;DisY1-&amp;gt;toPlainText();
    DisList[1] = Text.toFloat();
    Text = ui-&amp;gt;DisZ1-&amp;gt;toPlainText();
    DisList[2] = Text.toFloat();
    ZAux_Direct_MoveAbs(g_handle,3,AxisList,DisList);
    //update position data of second row
    Text = ui-&amp;gt;DisX2-&amp;gt;toPlainText();
    DisList[0] = Text.toFloat();
    Text = ui-&amp;gt;DisY2-&amp;gt;toPlainText();
    DisList[1] = Text.toFloat();
    Text = ui-&amp;gt;DisZ2-&amp;gt;toPlainText();
    DisList[2] = Text.toFloat();
    //update position data of third row
    ZAux_Direct_MoveAbs(g_handle,3,AxisList,DisList);
    Text = ui-&amp;gt;DisX3-&amp;gt;toPlainText();
    DisList[0] = Text.toFloat();
    Text = ui-&amp;gt;DisY3-&amp;gt;toPlainText();
    DisList[1] = Text.toFloat();
    Text = ui-&amp;gt;DisZ3-&amp;gt;toPlainText();
    DisList[2] = Text.toFloat();
    ZAux_Direct_MoveAbs(g_handle,3,AxisList,DisList);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;d. call axis stop command to stop motion through slot function of stop button.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//stop axis motion
void MainWindow::on_StopButton_clicked()
{
    ZAux_Direct_Rapidstop(g_handle,2);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. How to Transplant Routine to Linux Device
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Copy  Corresponding Linux Library to Project Folder
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn80nq7xj47b5m9v9eqd8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn80nq7xj47b5m9v9eqd8.png" alt="Image description" width="634" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Add Function Library's Static Library (libzmotion.so) to New Created Project.
&lt;/h4&gt;

&lt;p&gt;a. add function library 1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa75unqz9r7lvendqjmc8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa75unqz9r7lvendqjmc8.png" alt="Image description" width="427" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b. add function library 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia04aspor4zdrjjl1bo5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fia04aspor4zdrjjl1bo5.png" alt="Image description" width="506" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. add function library 3&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31jcktvj7k2ibgntyoad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31jcktvj7k2ibgntyoad.png" alt="Image description" width="506" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Compile Again, Then Run Directly.
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqvq2dww2j1310kmrrzlt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqvq2dww2j1310kmrrzlt.png" alt="Image description" width="456" height="545"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (4) Debug &amp;amp; Monitor
&lt;/h4&gt;

&lt;p&gt;Compile and run the routine, at the same time connect to ZDevelop software to debug. In this way, axis parameters and motion situation all can be watched in real-time.&lt;/p&gt;

&lt;p&gt;--multi-axis interpolation X-Y position waveform--&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0zx6yvhmiuhby80m57o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0zx6yvhmiuhby80m57o.png" alt="Image description" width="709" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--multi-axis interpolation X-Y position waveform (continuous interpolation is OFF)--&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0d1emi1d8oaa8z8k08n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn0d1emi1d8oaa8z8k08n.png" alt="Image description" width="800" height="595"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ABOUT ZMOTION&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- E&lt;a href="http://www.zmotionglobal.com/support_info_120.html" rel="noopener noreferrer"&gt;therCAT Motion Control Card QT Development Tutorial (1) | Development Environment Configuration &amp;amp; Simple Motion Control Example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together.&lt;/p&gt;

&lt;p&gt;ZMOTION: DO THE BEST TO USE MOTION CONTROL.&lt;/p&gt;

&lt;p&gt;Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

</description>
      <category>ethercat</category>
      <category>qt</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Motion Control PSO Position Synchronous Output (1) Hardware Control &amp; PSO Commands</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Fri, 28 Jul 2023 08:02:27 +0000</pubDate>
      <link>https://dev.to/zmotion/motion-control-pso-position-synchronous-output-1-hardware-control-pso-commands-53di</link>
      <guid>https://dev.to/zmotion/motion-control-pso-position-synchronous-output-1-hardware-control-pso-commands-53di</guid>
      <description>&lt;p&gt;Here, PSO function of motion controller will be introduced. PSO is not "particle swarm optimization" explained by Wikipedia. PSO means Position Synchronous Output function  in motion control, or hardware comparison output. Through this function, it can output signals synchronously at high-speed. Then in real applications, high-speed and high-precision requirements in motion control or automation solutions can be met, which improves the efficiency and quality, and reduces the labor cost, then brings a wonderful development.&lt;/p&gt;

&lt;p&gt;In Zmotion technical support, there are three parts information to be shown in total.&lt;/p&gt;

&lt;p&gt;That is:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.zmotionglobal.com/support_info_104.html" rel="noopener noreferrer"&gt;Motion Control Position Synchronous Output (1) | Hardware Platform &amp;amp; PSO Instructions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Motion Control Position Synchronous Output (2) | PSO Modes&lt;/p&gt;

&lt;p&gt;Motion Control Position Synchronous Output (3) | High-precision 2D/3D PSO&lt;/p&gt;

&lt;p&gt;Now, let's enter our first "motion controller position synchronization output"learning journey.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feogyi3z64rygmvagxoid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feogyi3z64rygmvagxoid.jpg" alt="Image description" width="768" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/S0gUAx2minY" rel="noopener noreferrer"&gt;hardware platform environment building&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  01 Hardware Platform
&lt;/h2&gt;

&lt;p&gt;Position synchronous output PSO function is required, which means hardware should support PSO function. That is, select the motion controller that is with PSO function and with required axes for actual applications.&lt;/p&gt;

&lt;p&gt;In Zmotion, there are several series of motion controllers. Of course, some support position synchronized output function, for example, ZMC406 bus EtherCAT motion controller, ZMC460N dual-bus (EtherCAT &amp;amp; RTEX) bus motion controller, etc., and here, take these two motion controllers as examples to describe the hardware comparison output function.&lt;/p&gt;

&lt;p&gt;PSO hardware comparison output function uses high-speed IO, the respond frequency is 1MHz, and the respond speed can be up to us level.&lt;/p&gt;

&lt;p&gt;More controller specification parameters can be checked through "?*max" in ZDevelop.&lt;/p&gt;

&lt;p&gt;"?*set" can view instruction parameter values.&lt;br&gt;
"?*port" can view communication channels.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0nkt63j3p3j044ofqo5l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0nkt63j3p3j044ofqo5l.png" alt="Image description" width="547" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0rmk9a0eoyt89d76bms.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0rmk9a0eoyt89d76bms.png" alt="Image description" width="547" height="413"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  02 Position Synchronization Output PSO Function
&lt;/h2&gt;

&lt;p&gt;Position synchronized output function is used to compare real-time captured encoder measurement position (pulse position can be used when there is no encoder) and position set by comparison mode, then control OP to output signals synchronously at high-speed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F380ilsch5hc6ruoys6nx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F380ilsch5hc6ruoys6nx.png" alt="Image description" width="540" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generally, PSO function outputs signals synchronously with the laser (or dispensing spraying valve devices) to synchronize phases. In motion trajectory all stages (acceleration, deceleration and constant speed) , trigger output switch in constant space or constant time to achieve that pulse energy are distributed in processed object.&lt;/p&gt;

&lt;p&gt;"Position synchronization output" function ensures high-speed and stable output signals, in whole motion trajectory , trigger output signal with fixed distance, no need to consider the whole speed due to high enough output precision.&lt;/p&gt;

&lt;p&gt;Specifically, in linear part, it is with rapid speed. In fillet deceleration part, it ensures constant space output. Usually, fillet processing part occupies a small part in whole processing process, which means processing effect is ensured and production can be promoted at the same time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4g2qitdmh7zhm7wwy4hj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4g2qitdmh7zhm7wwy4hj.png" alt="Image description" width="756" height="330"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  03 Position Synchronization Output Commands
&lt;/h2&gt;

&lt;p&gt;PSO hardware comparison output function is mainly achieved by "HW_PSWITCH2", "MOVE_HWPSWITCH2" and "HW_TIMER". Former two commands are used to set the distance of triggering comparison output . The last one is used for hardware timer , which can be matched with former to control pulse width precisely.&lt;/p&gt;
&lt;h4&gt;
  
  
  (1) HW_PSWITCH2 -- Hardware Position Comparison Output
&lt;/h4&gt;

&lt;p&gt;Instruction Description:&lt;/p&gt;

&lt;p&gt;Through setting comparison conditions, control OP port to high-speed output signals continuously, and please note controller must be with output port that supports hardware comparison output. For example, ZMC406 can use OUT0/1/2/3, ZMC460N can use OUT0-OUT11.&lt;/p&gt;

&lt;p&gt;It can compare pulse axis position, encoder measurement position and bus axis position. And the comparison position is set by ATYPE. When it compares main axis that is with encoder input, automatically using encoder position to trigger, when no encoder, comparing pulse output.&lt;/p&gt;

&lt;p&gt;If needs to adjust output precise time, "MOVEOP_DELAY" can be used.&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;p&gt;-- for general controllers, each system cycle can only compare once, which can be checked through "SERVO_PERIOD". But when system period is too large, and comparison output pulse width is less than system cycle, it will cause abnormal output. For some controllers, ZMC460N, ZMC504SCAN, multiple comparison can be achieved by one system cycle.&lt;/p&gt;

&lt;p&gt;--"HW_PSWITCH 2" command and "MOVE_OP" precision command use same hardware resources, it is not recommended to use them at the same one channel, but they can be used in different channels synchronously.&lt;/p&gt;

&lt;p&gt;--While calling TABLE position data, don't modify TABLE before completing all comparison points.&lt;/p&gt;

&lt;p&gt;--While using pulse motors, measurement position (MPOS) is compared only when ATYPE is 4. If ATYPE is 1/7 (default), command position (DPOS) is compared.&lt;/p&gt;

&lt;p&gt;Instruction Grammar:&lt;/p&gt;

&lt;p&gt;HW_PSWITCH2(mode, [...])&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybfdatgwrufme9le1fe8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fybfdatgwrufme9le1fe8.png" alt="Image description" width="709" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Different modes need to fill in different parameters, below shows 2 simple examples, for more, please refer to ZBasic manual.&lt;/p&gt;

&lt;p&gt;A. Mode = 1: single-axis comparison&lt;/p&gt;

&lt;p&gt;Mode=1: single axis comparison&lt;br&gt;
HW_PSWITCH2(1,opnum,opstate,tablestart,tableend[,Direction])&lt;br&gt;
mode: 1-open comparer&lt;br&gt;
opnum: relevant outputs&lt;br&gt;
opstate: output status of the first comparison position&lt;br&gt;
tablestart: TABLE No. that saves the first comparison point's absolute coordinate&lt;br&gt;
tablesend: TABLE No. that saves the last comparison point's absolute coordinate&lt;br&gt;
direction: the first coordinate to judge direction, 0-negative, 1-positive, -1-no direction used.&lt;/p&gt;

&lt;p&gt;This mode is very easy. It needs TABLE register to save position coordinates that requires comparison output, then under PSO control, when reaching one comparison point position, it will inverse it, until all coordinates completed. Please refer to below image, it shows 6 comparison points' OP output, P means comparison point.&lt;/p&gt;

&lt;p&gt;For example: mode=1, single-axis mode, compare positions in TABLE&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BASE(0)
ATYPE=0
UNITS=10000/10
SPEED=100
ACCEL=1000
DECEL=1000
SRAMP=100
DPOS=0
MPOS=0
OP(0,OFF)
TABLE(0,50,100,150,200)   'comparison position coordinates configuration
HW_PSWITCH2(2)            'stop and delete comparison that not finished
HW_PSWITCH2(1, 0, 1, 0, 3,1)   'compare 4 positions, operate OUT0
TRIGGER                          'trigger the oscilloscope
MOVE(300)
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;captured oscilloscope waveform: when reached TABLE four coordinates 50, 100, 150, 200, OP reverses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwshgaet3hoazy576u2q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwshgaet3hoazy576u2q.png" alt="Image description" width="528" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;B. Mode=6: vector comparison method, cycle mode, used together with HW_TIMER&lt;br&gt;
HW_PSWITCH2 (mode,opnum,opstate,vectstart,repes,cycledis)&lt;br&gt;
mode: 6-open comparer&lt;br&gt;
opnum: relevant outputs&lt;br&gt;
opstate: output status of the first comparison position&lt;br&gt;
vectstart: comparison point VECTOR_MOVED current motion distance&lt;br&gt;
repes: repeat period, compare once in one cycle&lt;br&gt;
cycledis: period distance, output opstate every time after cycledis&lt;/p&gt;

&lt;p&gt;This mode doesn't need TABLE, it only needs to specify the "VECTOR_MOVED" of the first trigger position, including the times of comparison period, the distance of each output. Then, use "HW_TIMER" to control the pulse width and times of position output when achieves one period each time.&lt;/p&gt;

&lt;p&gt;Below shows parameters configuration, red one is HW_PSWITCH2 instruction, orange one is HW_TIMER instruction.&lt;/p&gt;

&lt;p&gt;And all distance involved in this mode are vector coordinates, which are used for comparison output under single-axis motion or interpolation motion mode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1onhw87xvtdplsuj8ywx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1onhw87xvtdplsuj8ywx.png" alt="Image description" width="530" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example: mode=6, period mode used together with HW_TIMER&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2)
WAIT IDLE(0)
BASE(0)
ATYPE=1
UNITS=10000/10
SPEED=100
ACCEL=1000
DECEL=1000
SRAMP=100
DPOS=0
MPOS=0
OP(0,OFF)
TRIGGER
VECTOR_MOVED=0   'set vector initial position as 0 for viewing
HW_PSWITCH2(2)      'stop and delete comparison that not finished.
HW_PSWITCH2(6,0,1,100,4,50)  'start to compare from position 100, compare 4 times, period distance is 50, output valid time is determined by HW_TIMER
HW_TIMER(2,100000,50000,2,off,0)  'after 50ms, OUT becomes off from on
MOVE(400)
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;captured waveform:&lt;/p&gt;

&lt;p&gt;Output port is OP(0), the first comparison output status is ON , and the vector coordinate of the first OUT is 100, compare 4 times, and trigger once when spans 50.&lt;/p&gt;

&lt;p&gt;When each time triggered, the output time of OP is set by HW_TIMER. Here, each pulse output cycle is 100ms, valid width is 50ms, and trigger twice continuously for each comparison position.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxo3vlnz88c71853ev70.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxo3vlnz88c71853ev70.png" alt="Image description" width="639" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;under YT mode:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtbpfkdhd4oj345teo3m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbtbpfkdhd4oj345teo3m.png" alt="Image description" width="636" height="288"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Change the single axis motion as MOVE(200, 300) two-axis interpolation, others are the same, compare combined vector position of two axes "VECTOR_MOVED".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2)
WAIT IDLE(0)
BASE(0)
ATYPE=1
UNITS=10000/10
SPEED=100
ACCEL=1000
DECEL=1000
SRAMP=100
DPOS=0
MPOS=0
OP(0,OFF)
TRIGGER
VECTOR_MOVED=0   'set vector initial position as 0 for viewing
HW_PSWITCH2(2)      'stop and delete comparison that not finished.
HW_PSWITCH2(6,0,1,100,4,50)  'start to compare from position 100, compare 4 times, period distance is 50, output valid time is determined by HW_TIMER
HW_TIMER(2,100000,50000,2,off,0)  'after 50ms, OUT becomes off from on
MOVE(200,300)  'two-axis linear interpolation
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9huovcz8tq6g3dmwh00d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9huovcz8tq6g3dmwh00d.png" alt="Image description" width="764" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;under XYZ mode:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0ei606lbrhxtbkn9ynz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0ei606lbrhxtbkn9ynz.png" alt="Image description" width="618" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) HW_TIMER -- Hardware Timing
&lt;/h4&gt;

&lt;p&gt;Instruction Description:&lt;/p&gt;

&lt;p&gt;Hardware timer is used to restore electric level after hardware comparison output for a certain time. There is only one "HW_TIMER", and when HW_TIMER is called each time, the former calling will be stopped compulsively.&lt;/p&gt;

&lt;p&gt;And OP and MOVE_OP can close HW_TIMER pulse that is operating, which means HW_TIMER can be used as PWM. OP outputs, pulse output will be on, then next OP outputs, pulse output will be closed. When MOVE_OP precision output is used, infinite pulse function of precision PWM output can be realized.&lt;/p&gt;

&lt;p&gt;Use ?*HW_TIMER to see the number of remaining pulses.&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;p&gt;Each period outputs signal once, and the period time must be larger than system period, otherwise, output will be abnormal. Also, used output ports must support position synchronized output function.&lt;/p&gt;

&lt;p&gt;Instruction Grammar:&lt;/p&gt;

&lt;p&gt;HW_TIMER(mode, cyclonetime, optime, reptimes, opstate, opnum )&lt;br&gt;
mode: 0-stop, 1-run&lt;br&gt;
cyclonetime: cycle time, us is the unit&lt;br&gt;
optime: valid time, us is the unit&lt;br&gt;
reptimes: repeat times, start the mode, when reptimes=0, HW_TIMER will be softly closed, and uncompleted pulses will keep outputting.&lt;br&gt;
opstate: output default status, start to do timing when output port is not current state&lt;br&gt;
opnum: output NO., the port must support hardware comparison output.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi06p29ninu6vcg36gj6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi06p29ninu6vcg36gj6k.png" alt="Image description" width="528" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2)
WAIT IDLE(0)
BASE(0)
ATYPE=1
UNITS=100
SPEED=100
ACCEL=100
DECEL=100
DPOS=0
TRIGGER
DELAY(100)
OP(0, OFF)
HW_TIMER(2, 10000, 5000, 30, OFF, 0)  'after OUT0 is changed to ON, hardware timer is triggered to do timing, the cycle is 10ms, after 5ms, it becomes OFF, until 30 times.
OP(0, ON)         'trigger timing
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please refer to below captured OP(0), the period is 1ms, which means the time unit is 1ms. After delay 100ms, it starts to trigger OP high-speed output, the total time is "10000us*30". The third parameter is used to adjust output pulse's width.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1sd034j1epryxt6iikk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp1sd034j1epryxt6iikk.png" alt="Image description" width="416" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) MOVE_HWPSWITCH2 -- Hardware Comparison Output in Buffer
&lt;/h4&gt;

&lt;p&gt;This command's function and usgae are same as "HW_PSWITCH2", the difference is that this command enters motion buffer, that is, execute comparison in buffer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bri77g9gi4fs9iyz3bc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8bri77g9gi4fs9iyz3bc.jpg" alt="Image description" width="800" height="455"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://youtu.be/sfyQM15E8tw" rel="noopener noreferrer"&gt;Command Video Description, Welcome!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Example: Output Pulses with Equal Space
&lt;/h2&gt;

&lt;p&gt;"HW_PSWITCH2" mode 6 is used, and use with "HW_TIMER" together to control single-axis high-speed equal space output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(3)
WAIT  IDLE(0)
GLOBAL CONST Axis_X = 0       'define physical axis No.
GLOBAL CONST Out_Pso0 = 0  'PSO hardware output No.

BASE(Axis_X)        'initialize axis parameters
UNITS=1000        'pulse amount, the number of pulses corresponding to 1MM
ATYPE=4             'axis type, pulse output + encoder input axis
DPOS=0
MPOS=0
SPEED=100
ACCEL=2000
DECEL=0
MERGE=1
OP(Out_Pso0,OFF)

GLOBAL g_cmd
g_cmd = 0
WHILE 1
   IF g_cmd =  1 THEN
      g_cmd = 0
      TRIGGER
      Function_Test1()  
   ENDIF
WEND
'********************************************************************************************
'generate one PWM pulse under equal-space mode, pulse output time can be adjusted.
'lv_WidthTime  pulse width time us
'lv_Interval       2 pulse spans mm
'lv_StrartPos    trigger initial position mm
'lv_EndPos       end position
'********************************************************************************************
GLOBAL SUB Function_Test1()   'in 20-120, output one continuous 2ms pulses with a spacing of 1ms each time
   LOCAL lv_WidthTime,lv_Interval,lv_StrartPos,lv_EndPos  'define local variables
   lv_WidthTime = 2000    'pulse width 2000us  
   lv_Interval = 1               'pulse space 1mm
   lv_StrartPos = 20           'trigger initial position 20mm
   lv_EndPos = 120            'end position 120mm

   OP(Out_Pso0,OFF)  'close the output port
   BASE(Axis_X)           'select axis X
   ATYPE = 4              'axis type, when the axis is with encoder axis, encoder position is compared by default.
   SPEED = 100          'speed is 100mm/s
   FORCE_SPEED=60  'SP speed is 60mm/s
   MOVEABS(0)          'move to 0
   WAIT IDLE
   VECTOR_MOVED = 0 'clear interpolation vector distance to 0

   LOCAL iTime
   iTime =ABS(lv_EndPos - lv_StrartPos) \ lv_Interval  'calculate comparison times
   TRACE lv_StrartPos,iTime,lv_Interval,lv_WidthTime

   HW_PSWITCH2(2)  'clear HW comparison buffer area
   HW_PSWITCH2(6,Out_Pso0,ON,lv_StrartPos,iTime,lv_Interval)  'start to trigger from lv_StrartPos, the span is lv_Interval, compare iTime times.
   HW_TIMER(2,lv_WidthTime+100,lv_WidthTime,1,OFF,Out_Pso0)  'after Out_Pso is triggered to be ON, and after open lv_Width us, close output

   MOVEABS(50)        'single-axis motion, speed is 100
   MOVEABSSP(100)  'SP single-axis motion, speed is 60
   MOVEABS(150)      'single-axis motion, speed is 100
   WAIT IDLE             'wait for motion to stop
   HW_PSWITCH2(2)  'clear HW comparison buffer area
END SUB
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. PSO Curve in ZDevelop
&lt;/h2&gt;

&lt;p&gt;3 single-axis linear motion, the comparison range is position 20-120, compare once when spans one unit, the total is 100 time. &lt;br&gt;
The middle segment is equal-space comparison, the motion speed is small, so OP reverse speed becomes slower.&lt;br&gt;
OP holding high level time is 2ms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7n8ft5t8wwk4apstkmr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7n8ft5t8wwk4apstkmr.png" alt="Image description" width="689" height="497"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under XY mode, OP changes with motion distance. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nfwapf4hfcrqcwnufmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1nfwapf4hfcrqcwnufmu.png" alt="Image description" width="693" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be seen comparison output is not effected by speed under this equal-space mode, the output is distributed all the time.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>EtherCAT Motion Control Card -- Custom Curve</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Wed, 21 Jun 2023 01:56:11 +0000</pubDate>
      <link>https://dev.to/zmotion/ethercat-motion-control-card-custom-curve-8l1</link>
      <guid>https://dev.to/zmotion/ethercat-motion-control-card-custom-curve-8l1</guid>
      <description>&lt;p&gt;Today, ZMotion shares customized motion curve application of EtherCAT motion control card, exactly, "how to encapsulate Basic instructions that you want to use into upper computer interface through online command" will be introduced.&lt;/p&gt;

&lt;h2&gt;
  
  
  01 Hardware Motion Control Card Introduction
&lt;/h2&gt;

&lt;p&gt;ECI2828 motion control card is one bus type and modular network motion control card. As for programming method, it is developed through VC, VB, VS, C++ and several kinds of advanced languages. And there needs the dynamic library "zmotion.dll" for program running. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3ph42mfjdzzg20d54z6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx3ph42mfjdzzg20d54z6.png" alt="Image description" width="702" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  02 Qt development of motion control card
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Build new Qt project
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ouuumdx0svxs57kl0nw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1ouuumdx0svxs57kl0nw.png" alt="Image description" width="705" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frf4qxmuwgcblf4v6opz6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frf4qxmuwgcblf4v6opz6.png" alt="Image description" width="697" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb1r4ze1wzc5wmae81kf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpb1r4ze1wzc5wmae81kf.png" alt="Image description" width="699" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomfn6k74n51szczsxxh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fomfn6k74n51szczsxxh6.png" alt="Image description" width="698" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Copy files that relate to function library to new built project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0dpqbfy29p8lmxzk9u7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0dpqbfy29p8lmxzk9u7g.png" alt="Image description" width="682" height="357"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Add static library of function library into new built project. (zmotion.lib)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmky880fl1koqgilt2nj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmky880fl1koqgilt2nj6.png" alt="Image description" width="407" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpu4ardzgxedb27n52uez.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpu4ardzgxedb27n52uez.png" alt="Image description" width="509" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdt54eh1limlb927vula0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdt54eh1limlb927vula0.png" alt="Image description" width="530" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Add head files that relate to function library to project (zmcaux.cpp 、 zmcaux.h 、 Zmotion.h)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi6faz0ndicuxf8o4bkn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi6faz0ndicuxf8o4bkn.png" alt="Image description" width="388" height="297"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Declare relevant head files, and define link handle.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjirgnm8avihdvk1nyabz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjirgnm8avihdvk1nyabz.png" alt="Image description" width="706" height="371"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) PC function introduction
&lt;/h4&gt;

&lt;p&gt;--Obtain PC function library manual from "Zmotion/Download" or "Contact us".&lt;/p&gt;

&lt;p&gt;--For PC programming, there needs to build the connection between upper computer and controller. Like motion control card connection, use net port, details as follow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal6d61afwmh5giac1fj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal6d61afwmh5giac1fj6.png" alt="Image description" width="509" height="367"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--If you want to encapsulate Basic instruction as upper computer, the interface that can be directly called must use "online command" interface to do function encapsulation. Below is online command interface description.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktpjg5m0wiftdknq1tum.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktpjg5m0wiftdknq1tum.png" alt="Image description" width="655" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7n02bik5cw53dtllnll9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7n02bik5cw53dtllnll9.png" alt="Image description" width="477" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Encapsulation example: SPEED of Basic instruction.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxo98isay0yo166zt7jf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcxo98isay0yo166zt7jf.png" alt="Image description" width="693" height="553"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Qt does encapsulation of Move_Pt instruction to achieve motion of custom curve
&lt;/h4&gt;

&lt;p&gt;--Qt interface of customized curve as follow:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk5v4s54bd2jafugng8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk5v4s54bd2jafugng8u.png" alt="Image description" width="716" height="930"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--Bind one channel function with Click Event of [connect] connect button through Qt to do controller connection.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//define one timer
QTimer *UpData = new QTimer(this);
connect(UpData,&amp;amp;QTimer::timeout,this,[=](){
   if(g_handle!=0)
   {
      //obtain axis position information
      ZAux_Direct_GetAllAxisPara(g_handle,"DPOS",AxisNum,Dpos);
      ui-&amp;gt;DposX-&amp;gt;setText(QString("%1").arg(Dpos[0]));
      ui-&amp;gt;DposY-&amp;gt;setText(QString("%1").arg(Dpos[1]));
      ui-&amp;gt;DposZ-&amp;gt;setText(QString("%1").arg(Dpos[2]));
      ui-&amp;gt;DposU-&amp;gt;setText(QString("%1").arg(Dpos[3]));
      //obtain axis speed information
      ZAux_Direct_GetAllAxisPara(g_handle,"MSPEED",AxisNum,Mspeed);
      ui-&amp;gt;MspeedX-&amp;gt;setText(QString("%1").arg(Mspeed[0]));
      ui-&amp;gt;MspeedY-&amp;gt;setText(QString("%1").arg(Mspeed[1]));
      ui-&amp;gt;MspeedZ-&amp;gt;setText(QString("%1").arg(Mspeed[2]));
      ui-&amp;gt;MspeedU-&amp;gt;setText(QString("%1").arg(Mspeed[3]));
      //obtain motion situation of each axis
      float idle[4]={0};
      ZAux_Direct_GetAllAxisPara(g_handle,"idle",AxisNum,idle);
      idle[0]=idle[0]+idle[1]+idle[2]+idle[3];
      if(idle[0]&amp;gt;(-4))
      {
         MotionStatus=1;//while moving
      }
      else
      {
         MotionStatus=0;
      }
   }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- Update position and speed message of each axis through timer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//define one timer
QTimer*UpData =newQTimer(this);
connect(UpData,&amp;amp;QTimer::timeout,this,[=](){
    if(g_handle!=0)
    {
        //obtain axis position information
       ZAux_Direct_GetAllAxisPara(g_handle,"DPOS",AxisNum,Dpos);
       ui-&amp;gt;DposX-&amp;gt;setText(QString("%1").arg(Dpos[0]));
       ui-&amp;gt;DposY-&amp;gt;setText(QString("%1").arg(Dpos[1]));
       ui-&amp;gt;DposZ-&amp;gt;setText(QString("%1").arg(Dpos[2]));
       ui-&amp;gt;DposU-&amp;gt;setText(QString("%1").arg(Dpos[3]));
        //obtain axis speed information
       ZAux_Direct_GetAllAxisPara(g_handle,"MSPEED",AxisNum,Mspeed);
       ui-&amp;gt;MspeedX-&amp;gt;setText(QString("%1").arg(Mspeed[0]));
       ui-&amp;gt;MspeedY-&amp;gt;setText(QString("%1").arg(Mspeed[1]));
       ui-&amp;gt;MspeedZ-&amp;gt;setText(QString("%1").arg(Mspeed[2]));
       ui-&amp;gt;MspeedU-&amp;gt;setText(QString("%1").arg(Mspeed[3]));
        //obtain motion situation of each axis
        floatidle[4]={0};
       ZAux_Direct_GetAllAxisPara(g_handle,"idle",AxisNum,idle);
       idle[0]=idle[0]+idle[1]+idle[2]+idle[3];
        if(idle[0]&amp;gt;(-4))
        {
            MotionStatus=1;//while moving
        }
        else
        {
            MotionStatus=0;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;-- Introduction: Basic -- Move_Pt&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum9w5l4ieuag62qv9o4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum9w5l4ieuag62qv9o4t.png" alt="Image description" width="649" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;-- Move_Pt interface encapsulation&lt;/p&gt;

&lt;p&gt;A.Encapsulate interface through "ZAux_DirectCommand()"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*************************************************************
Description:    unit time distance
Input:          card link handle
                motion axes, axis list
                motion time, ticks unit, 1ticks≈1ms
                motion distance, units unit
Output:         No
Return:         error code
*************************************************************/
int32  MyApi::ZAux_Direct_MovePt(ZMC_HANDLE handle, int iAxisNum, int *piAxisList, int iTime, float *pfDisList)
{
    char  cmdbuff[2048],tempbuff[2048];
    char  cmdbuffAck[2048];
    //judge input parameters
    if((0 &amp;gt; iAxisNum || iAxisNum &amp;gt; MAX_AXIS_AUX)) return  ERR_AUX_PARAERR;
    if(NULL == piAxisList)      return  ERR_AUX_PARAERR;
    if(iTime&amp;lt;=0)                return  ERR_AUX_PARAERR;
    if(NULL == pfDisList)       return  ERR_AUX_PARAERR;
    //generate the command to select which axis to move......for example, Basic command, (0,1,2,3) means axis 0, axis 1, axis 2 and axis 3 are selected
    //encapsulate Basic axis-selection command through character string splicing command.
    BASE(piAxisList[0],piAxisList[1],.....piAxisList[i])
    strcpy(cmdbuff, "BASE(");
    for(int i = 0; i&amp;lt; iAxisNum-1; i++)
    {
        sprintf(tempbuff, "%d,",piAxisList[i]);
        strcat(cmdbuff, tempbuff);
    }
    sprintf(tempbuff, "%d)",piAxisList[iAxisNum-1]);
    strcat(cmdbuff, tempbuff);
    //change the line, keep encapsulating Basic command
    strcat(cmdbuff, "\n");
    //generate unit time motion distance command，......Basic command is achieved through Move_PT(ticks, dis1,dis2…)
    sprintf(tempbuff, "Move_PT(%d,",iTime);
    strcat(cmdbuff, tempbuff);
    //encapsulate each axis' motion distance
    for(int i = 0; i&amp;lt; iAxisNum-1; i++)
    {
        sprintf(tempbuff, "%f,",pfDisList[i]);
        strcat(cmdbuff, tempbuff);
    }
    sprintf(tempbuff, "%f)",pfDisList[iAxisNum-1]);
    strcat(cmdbuff, tempbuff);
    //call the command to execute the function
    //printf("%s",cmdbuff);
    return ZAux_DirectCommand(handle, cmdbuff, cmdbuffAck, 2048);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B.Qt routine calls the interface encapsulated just now. -- MyApi::ZAux_Direct_MovePt（）&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmx7nbz8geta3whmqjsm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnmx7nbz8geta3whmqjsm.png" alt="Image description" width="701" height="309"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//open Move_Pt motion
voidWidget::on_PtStartButton_clicked()
{
   if(0== MotionStatus)
   {
      intbuffNum=0;
      //obtain axis 0 remaining buffers, command only can be sent when the number of axes in buffer is enough.
      ZAux_Direct_GetRemain_LineBuffer(g_handle,0,&amp;amp;buffNum);
      if(buffNum&amp;gt;3)
      {
         intAxisList[4]={0,1,2,3};
         floatDisList[3][5];
         for(inti=0;i&amp;lt;3;i++)
         {
            for(intj=0;j&amp;lt;5;j++)
            {
               DisList[i][j]=LineData[i][j]-&amp;gt;text().toFloat();
            }
            //call the function interface encapsulated by onw to move MOVE_PT.
            myapi-&amp;gt;ZAux_Direct_MovePt(g_handle,AxisNum,AxisList,(int)(DisList[i][0]),&amp;amp;DisList[i][1]);
         }
      }
      else
      {
         QMessageBox::warning(this,"warning","insufficient axis in buffer");
      }
    }
    else
    {
       QMessageBox::warning(this,"warning","system is operting......");
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C. Oscilloscope capture&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F383irlk0qw07dlpq3ap8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F383irlk0qw07dlpq3ap8.png" alt="Image description" width="703" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;（6）One API is encapsulated through sending several move_ptabs commands to process.&lt;/p&gt;

&lt;p&gt;A.Send encapsulations of several move_ptabs commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/*************************************************************
Description:    send multiple unit time distance instructions in one time
Input:          card link handle
                the number of motion axes, axis list
                motion time, the unit is ticks, 1ticks≈1ms
                motion distance, the unit is units
Output:         No
Return:         error codes
*************************************************************/
int32  MyApi::ZAux_Direct_MovePtAbsS(ZMC_HANDLE handle, int iAxisNum, int *piAxisList, int ApiNum,int *iTime, float *pfDisList)
{
   char  cmdbuff[2048*128],tempbuff[2048];
   char  cmdbuffAck[2048];
   //input parameters to judge
   if((0 &amp;gt; iAxisNum || iAxisNum &amp;gt; MAX_AXIS_AUX)) return  ERR_AUX_PARAERR;//the number of axes is incorrect
   if(NULL == piAxisList)      return  ERR_AUX_PARAERR;//axis list is blank
   if(iTime== 0)               return  ERR_AUX_PARAERR;//time list is blank
   if(NULL == pfDisList)       return  ERR_AUX_PARAERR;//motion distance list is blank
   if((ApiNum&amp;lt;0)||(ApiNum&amp;gt;50))       return  ERR_AUX_PARAERR;//Api numbers is incorrect
   //generate the command to select which axes to be moved......for example, Basic command, BASE(0,1,2,3) means axis 0, axis 1, axis 2 and axis 3 are selected
   //encapsulate Basic axis selection instruction through character string splicing command
   BASE(piAxisList[0],piAxisList[1],.....piAxisList[i])
   strcpy(cmdbuff, "BASE(");
   for(int i = 0; i&amp;lt; iAxisNum-1; i++)
   {
      sprintf(tempbuff, "%d,",piAxisList[i]);
      strcat(cmdbuff, tempbuff);
   }
   sprintf(tempbuff, "%d)",piAxisList[iAxisNum-1]);
   strcat(cmdbuff, tempbuff);
   //keep encapsulating Basic command in new line
   strcat(cmdbuff, "\n");
   for(int j=0;j&amp;lt;ApiNum;j++)
   {
      if(iTime[j]&amp;gt;0)
      {
         //generate unit time motion distance command, ......Basic command is achieved through Move_PT(ticks, dis1,dis2…)
         sprintf(tempbuff, "Move_PtAbs(%d,",iTime[j]);
         strcat(cmdbuff, tempbuff);
         //encapsulate motion distance of each axis
         for(int i = 0; i&amp;lt; iAxisNum-1; i++)
         {
            sprintf(tempbuff, "%.5f,",pfDisList[i+j*iAxisNum]);
            strcat(cmdbuff, tempbuff);
         }
         sprintf(tempbuff, "%.5f)",pfDisList[iAxisNum-1+j*iAxisNum]);
         strcat(cmdbuff, tempbuff);
         strcat(cmdbuff, "\n");
      }
   }
   //call the command to execute the function
   return ZAux_DirectCommand(handle, cmdbuff, cmdbuffAck, 2048);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;B.Qt routine calls the interface encapsulated just now -- MyApi::ZAux_Direct_MovePtAbsS（）&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//obtain axis motion remaining buffers
ZAux_Direct_GetRemain_LineBuffer(g_handle,0,&amp;amp;buffNum);       
if((buffNum&amp;gt;ApiNum*2)&amp;amp;&amp;amp;(SendNum*1&amp;lt;(4*ui-&amp;gt;HorizoScale-&amp;gt;text().toFloat())))
{
                Num = (float) 4*ui-&amp;gt;HorizoScale-&amp;gt;text().toFloat();
                switch (RunType) {
                //((-sin(PI*2*i/T)/(PI*2))+i/T)*500
                case 0:
                    for(int i=0;i&amp;lt;ApiNum;i++)
                    {                        
DisList[i]=(float) (((-sin(M_PI*2*SendNum/(Num-1))/(M_PI*2))+SendNum/ (Num-1))*500);
                        SendNum=SendNum+1;                    }
                    break;
                default:
                    break;
                }
                if(SendNum&amp;lt;ApiNum+10)
                {
                    //set current point
                    ui-&amp;gt;Canvas-&amp;gt;StartPoint.setX(0);
                    ui-&amp;gt;Canvas-&amp;gt;StartPoint.setY(-DisList[0]*EquivalentY);
                    ui-&amp;gt;Canvas-&amp;gt;StopPoint.setX(0);
                    ui-&amp;gt;Canvas-&amp;gt;StopPoint.setY(-DisList[0]*EquivalentY);
                    TimerWaveform-&amp;gt;start(10);
                    QString Str;
                    char buff[1204];
                    //send the online command to open oscilloscope
                    Str=QString("%1%2%3%4%5").arg("SCOPE(ON,1,").arg(0).arg(",").arg(3500).arg(",DPOS(0))");
                    ZAux_Execute(g_handle,Str.toLatin1().data(),buff,1024);
                    ZAux_Trigger(g_handle);
                    QThread::msleep(1);
                }
                myapi-&amp;gt;ZAux_Direct_MovePtAbsS(g_handle,1, &amp;amp;AxisList,ApiNum, TimeList, DisList);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;C.Qt collects position data of axis motion, and generate position wavaform.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oidDraw::paintEvent(QPaintEvent*event)
{
    if(DrawFlag!=0)
    {
        //example, one painter draws, this means equipment to draw
        QPainterPainter(WaveformFigure);
        Painter.translate(0,(int)(ImgH/2));
        //set the brush
        QPenPen(QColor(255,0,0));
        Pen.setWidth(4);
        Pen.setStyle(Qt::SolidLine);
        Painter.setPen(Pen);
        //send the command about oscilloscope to be triggered to capture data
        if((CurTriggerNum&amp;gt;=SingTriggerNum))
        {
           qDebug()&amp;lt;&amp;lt;"trigger the oscilloscope"&amp;lt;&amp;lt;SingTriggerNum;
           QStringStr;
           charbuff[1204];
           Str=QString("%1%2%3%4%5").arg("SCOPE(ON,1,").arg(StartTableId).arg(",").arg(StartTableId+SingTriggerNum).arg(",DPOS(0))");
           ZAux_Execute(g_handle,Str.toLatin1().data(),buff,1024);
           ZAux_Trigger(g_handle);
        }
        //return the number of points of current SCOPE captured data
        intoldTriggerNum=CurTriggerNum;
        ZAux_Direct_GetUserVar(g_handle,"SCOPE_POS",&amp;amp;CurTriggerNum);
        //obtain current SCOPE captured data
        ZAux_Direct_GetTable(g_handle,StartTableId+oldTriggerNum,CurTriggerNum-oldTriggerNum,Data);
        //Qlist data processing
        QList&amp;lt;float&amp;gt;::iteratoriet;
        for(inti=0;i&amp;lt;CurTriggerNum-oldTriggerNum;i++,PointNum++)
        {
           iet= EquivalentDataY.begin()+PointNum;
           //set starting point
           if(0==i)
           {
              StartPoint.setY(-EquivalentY*(*(iet-1)));
              StartPoint.setX((PointNum-1)*EquivalentX);
           }
           else
           {
               StartPoint=StopPoint;
           }
           //obtain the position of new point
           if(iet&amp;lt;EquivalentDataY.end())
           {
              *iet=Data[i];
           }
           else
           {
               EquivalentDataY.append(Data[i]);
           }
          StopPoint.setY(-EquivalentY*(Data[i]));
          StopPoint.setX((PointNum)*EquivalentX);
           //draw the line
           if((StartPoint!= StopPoint)&amp;amp;&amp;amp; (PointNum&amp;gt;0))
           {
              Painter.drawLine(StartPoint,StopPoint);
           }
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;D.Capture waveform to check effects.&lt;/p&gt;

&lt;p&gt;a.Y=((-sin(PI*2*i/T)/(PI*2))+i/T)*500 speed and position curve&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4oqw7cia1in2ydzrof8a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4oqw7cia1in2ydzrof8a.png" alt="Image description" width="696" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;b.Qt captures Y=((-sin(PI*2*i/T)/(PI*2))+i/T)*position curve of 500&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtlu1kk2458st8oe1c48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqtlu1kk2458st8oe1c48.png" alt="Image description" width="698" height="919"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- EtherCAT motion control card -- Custom Curve.&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together. &lt;/p&gt;

&lt;p&gt;ZMOTION: DO THE BEST TO USE MOTION CONTROL.&lt;/p&gt;

&lt;p&gt;Note: Copyright belongs to ZMotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>api</category>
    </item>
    <item>
      <title>Motion Controller Position Latch Function</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Tue, 20 Jun 2023 08:04:48 +0000</pubDate>
      <link>https://dev.to/zmotion/motion-controller-position-latch-function-jho</link>
      <guid>https://dev.to/zmotion/motion-controller-position-latch-function-jho</guid>
      <description>&lt;p&gt;In motion control solutions, latch function is usually required.&lt;/p&gt;

&lt;p&gt;Today, Zmotion brings &lt;a href="http://www.zmotionglobal.com/support_info_100.html" rel="noopener noreferrer"&gt;“Motion Controller Position Latch”&lt;/a&gt; function for you, there are several latch modes, you can select flexibly according to your specific requirements. In this article, take Zmotion motion controller ZMC408CE (&lt;a href="https://youtu.be/d8BzwwviSNo" rel="noopener noreferrer"&gt;a video description&lt;/a&gt;) as an example to share latch related knowledge with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  01 What is Latch Function?
&lt;/h2&gt;

&lt;p&gt;The function of the &lt;a href="https://en.wikipedia.org/wiki/Latch" rel="noopener noreferrer"&gt;latch&lt;/a&gt; is to respond immediately when the external IO signal is triggered, then lock the current position of the motor/encoder. It is usually used to latch the position of the product when the optical fiber sensor is encountered on the assembly line, and lock the position of the color mark on the packaging material.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c3hlkz7oepyko4wfv2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7c3hlkz7oepyko4wfv2m.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (1) Characteristics of Latch
&lt;/h4&gt;

&lt;p&gt;-- it supports latching encoder axis, bus axis, pulse axis and virtual axis (different types of controllers support different types of axes for latching).&lt;/p&gt;

&lt;p&gt;--there are single latch and high-speed continuous latch modes.&lt;/p&gt;

&lt;p&gt;-- it supports 4-channel simultaneous latching , which are R0, R1, R2, and R3 four latching channels respectively, and up to 8 latch ports can be latched at the same time, latch respond speed is fast.&lt;/p&gt;

&lt;p&gt;-- the value of MPOS is latched when there is encoder feedback, and the value of DPOS is latched when there is no encoder feedback.&lt;/p&gt;

&lt;p&gt;Please note different models controllers support different latching channel numbers, for specific  information, refer to the corresponding hardware manual.&lt;/p&gt;

&lt;p&gt;Here, take motion controller ZMC408CE as the example.&lt;/p&gt;

&lt;p&gt;ZMC408CE motion controller supports 4 latching channels, relevant interfaces are IN0-IN3.&lt;/p&gt;

&lt;p&gt;For communication interfaces, it includes RS232, RS485, EtherNET, CAN bus, EtherCAT bus and U disk interface, and there are 8 differential pulse output interfaces on board (including encoder input), 1 dedicated handwheel interface and AD/DA analog interface.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr8kjahlovlam4rjygek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhr8kjahlovlam4rjygek.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Steps to Latch
&lt;/h4&gt;

&lt;p&gt;--Usage of Latch--&lt;/p&gt;

&lt;p&gt;a. to determine whether the current hardware conditions meet the latching requirements , it is necessary to determine the axis of the latching position, and the IO signal should be connected to the input port IN that supports latching.&lt;/p&gt;

&lt;p&gt;b. set the latch input mapping port REG_INPUT , the function is to map the latched channel R0/R1/R2/R3 to the physical input port IN, and the input port needs to support the latch function.&lt;/p&gt;

&lt;p&gt;c. set the latch mode through REGIST , which needs to be selected according to the type of the latched axis.&lt;/p&gt;

&lt;p&gt;d. wait for the latch to trigger MARK / MARKB / MARKC / MARKD, when the latch is triggered, it becomes true.&lt;/p&gt;

&lt;p&gt;e. after the latch is completed, print the latch position information REG_POS / REG_POSB / REG_POSC / REG_POSD.&lt;/p&gt;

&lt;p&gt;f. the starting and ending coordinates of the latched position can be read , and the latched position can be called by other commands.&lt;/p&gt;

&lt;p&gt;--Latch Related Commands--&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun71np34rmzp9y4cggxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun71np34rmzp9y4cggxp.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;REG_INPUTS -- Map latch input&lt;/p&gt;

&lt;p&gt;REGIST -- Set latch mode&lt;/p&gt;

&lt;p&gt;MARK/MARKB/MARKC/MARKD -- Judge whether latch is triggered&lt;/p&gt;

&lt;p&gt;REG_POS/REG_POSB/REG_POSC/REG_POSD -- store position after latched&lt;/p&gt;

&lt;p&gt;When the latch occurs, the MARK / MARKB / MARKC / MARKD corresponding to the latch channel will be set to ON, and the latched position will be stored in the parameter REG_POS / REG_POSB / REG_POSC / REG_POSD.&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Map Latch Input (REG_INPUTS) Description
&lt;/h4&gt;

&lt;p&gt;REG_INPUTS mapping rules are as follows, the setting of REGIST latch mode needs to be set in conjunction with REG_INPUTS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4xgbayr4dhmrroftdi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4xgbayr4dhmrroftdi2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;REG_INPUTS = $3210, which means R3, R2, R1 and R0 correspond to IN3, IN2, IN1 and IN 0 respectively.&lt;/p&gt;

&lt;p&gt;REG_INPUTS = $1023, which means R3, R2, R1 and R0 correspond to IN1, IN0, IN2 and IN 3 respectively.&lt;/p&gt;

&lt;p&gt;REG_INPUTS = $1000, which means R3, R2, R1 and R0 correspond to IN1, IN0, IN0 and IN 0 respectively.&lt;/p&gt;

&lt;p&gt;In this way, R0, R1, R2 and R3 signals matched by REGIST mode are not physical IO channel, but it can brings flexibility.&lt;/p&gt;

&lt;p&gt;Actually, the output signal R0 can be relative to any one of IN(0)...IN(7) on the device (the optional input channel must be the latch channel specified in the hardware manual), or both R0 and R3 correspond to the same input port.&lt;/p&gt;

&lt;h4&gt;
  
  
  (4) REG_POS Latch Position Description
&lt;/h4&gt;

&lt;p&gt;The local IO used can latch the mapping of the channel through REG_INPUTS. Please note the data storage locations of different latch signal channels are different, as shown in the table below. For details, refer to the description of the REGIST instruction.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsta4hr8xld51lrkmuzv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsta4hr8xld51lrkmuzv.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  02 Latch Mode -- REGIST
&lt;/h2&gt;

&lt;p&gt;As mentioned above, latch mode is set through REGIST, that is, select suitable latch mode according to axis type that is to be latched. There are single-time latch and continuous latch.&lt;/p&gt;

&lt;p&gt;Therefore, different latch methods are with different trigger marks for latch signals, and latched position data are stored into different positions.&lt;/p&gt;

&lt;p&gt;Latch channel supported by different axis types:&lt;/p&gt;

&lt;p&gt;--encoder axis and pulse axis with feedback are latched by R0, R1, and Z pulse.&lt;/p&gt;

&lt;p&gt;--the pulse axis and virtual axis without feedback are latched by R0 and R1.&lt;/p&gt;

&lt;p&gt;--EtherCAT or RTEX bus axis types are latched by R2 and R3.&lt;/p&gt;

&lt;p&gt;In addition, the EtherCAT bus can use the drive's own latch mode. For details, refer to the drive manual.&lt;/p&gt;

&lt;h4&gt;
  
  
  (1) Single-time Latch
&lt;/h4&gt;

&lt;p&gt;REGIST(mode)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndv85bfj6lj95k8l9fja.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndv85bfj6lj95k8l9fja.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: rising edge and falling edge correspond to hardware state of controller inside. For ZMC series motion controller, it is valid when in OFF state, so falling edge is from without signal to with signal. For ECI series motion controller, it is valid when in ON state, rising edge is from without signal to with signal.&lt;/p&gt;

&lt;p&gt;It is recommended to test the regist edge through below simple routine, then apply into project.&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Continuous Latch
&lt;/h4&gt;

&lt;p&gt;Continuous latching is supported by adding 100 to the mode, and the latching result is stored in TABLE.&lt;/p&gt;

&lt;p&gt;REGIST(100+mode, tableindex, numes)&lt;/p&gt;

&lt;p&gt;mode: latch mode.&lt;/p&gt;

&lt;p&gt;tableindex: the table position where the content of the continuous latch is stored. The first table element stores the number of latches, and the coordinates of the latches are stored later. The number of max stored = numes -1, when it exceeds, write in cycle.&lt;/p&gt;

&lt;p&gt;numes: the number of tables occupied.&lt;/p&gt;

&lt;p&gt;The continuous latch mode performs continuous latching on the two channels respectively, which can realize continuous latching of the upper and lower edges.&lt;/p&gt;

&lt;p&gt;(ECI20150829 and above firmware support, 4 series controller 20170523 and above firmware support)&lt;/p&gt;

&lt;p&gt;100+mode: only a single channel mode can be used, adding 100 means using continuous latch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0unu9ndcmcgq5c9y6s1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0unu9ndcmcgq5c9y6s1d.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  03 Latch Routines
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Latch for Pulse-axis (without feedback) / Virtual-axis
&lt;/h4&gt;

&lt;p&gt;It can use R0 or R1 channel, ATYPE=1/7 is set as pulse-axis, ATYPE=0 means virtual axis, then MPOS value is latched (no measurement, MPOS is false, then copy DPOS), when it is with feedback, real MPOS value measured by encoder is latched. If supports Z signal, Z signal mode also can be used.&lt;/p&gt;

&lt;p&gt;Reference configuration:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr97pl7dny7uirkk87sgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr97pl7dny7uirkk87sgi.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Routine:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

BASE(0)
ATYPE=1         'pulse axis
UNITS=100
DPOS=0
SPEED=10
ACCEL=100
DECEL=100
REG_INPUTS=0   'R0-R3 all correspond to IN0, that is, signals connect to IN (0)
REGIST(4)        'select R0 latch mode
TRIGGER         'trigger the oscilloscope
VMOVE(1)        'axis motion
WAIT UNTIL MARK 'wait for latch to be triggered
PRINT REG_POS   'print latch position
END


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It can be seen from the waveform, IN(0) has signal to trigger latch, and REGIST(4) takes effect to latch current DPOS position then store it into REG_POS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc6btwuiee47foa0sxmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgc6btwuiee47foa0sxmm.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Modify the mode as REGIST(3), others are the same.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhd9t5b46choizsxr7fcr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhd9t5b46choizsxr7fcr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Latch for Pulse-axis (with feedback) / Encoder-axis
&lt;/h4&gt;

&lt;p&gt;It can use R0, R1 or Z channels (it is only valid in equipment that is with Z signal), when ATYPE is set to 4 or 5, which means pulse-axis, when it is 3 or 6, which means MPOS value is latched.&lt;/p&gt;

&lt;p&gt;Routine:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

BASE(0) 
ATYPE=4          'pulse axis with encoder feedback
UNITS=100
SPEED=10
ACCEL=100
DECEL=100
DPOS=0
MPOS=0
REG_INPUTS=$0   ' R0-R3 all correspond to IN0, that is, signals connect to IN (0)
REGIST(15)        'select R1 latch mode
TRIGGER
VMOVE(1)         'axis motion
WAIT UNTIL MARKB 'wait for latch to be triggered
PRINT REG_POSB  'print latch position
END


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It can be seen from the waveform, IN(0) has signal to trigger latch, at this time, latch current DPOS position then store it into REG_POS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7dcyk3wbn4e5xm89upc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7dcyk3wbn4e5xm89upc.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Latch Multi-axis Position
&lt;/h4&gt;

&lt;p&gt;When multi-axis position is latched, it needs to set latch for each axis separately. In below interpolation, there are 2 axes' positions are latched.&lt;/p&gt;

&lt;p&gt;Routine:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

BASE(0,1)
ATYPE=1,1             'pulse-axis
UNITS=100,100
DPOS=0,0
SPEED=10,10
ACCEL=100,100
DECEL=100,100
REG_INPUTS=$0       'R0-R3 all correspond to IN0, that is, signals connect to IN (0)
REGIST(4) AXIS(0)      'select R0 latch mode for axis 0
REGIST(4) AXIS(1)      'select R0 latch mode for axis 1
TRIGGER              'trigger the oscilloscope
MOVE(1000,800)       'axis motion
WAIT UNTIL MARK(0) AND MARK(1)    'wait for latch to be triggered
PRINT REG_POS(0), REG_POS(1)       'print axis 0 and axis 1 latch position
END


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhyqr1qilu5pl1bvrdb5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhyqr1qilu5pl1bvrdb5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: when multi-axis use same one latch hardware input port, same latch R channel needs to be used (for example, mode 3 / mode 4). when use different R-channel, it needs to map into different hardware inputs.&lt;/p&gt;

&lt;h4&gt;
  
  
  (4) Continuous Latch Mode
&lt;/h4&gt;

&lt;p&gt;The position after the continuous latch signal is triggered. The above axis types all support the continuous latch mode. It is recommended to open a separate task to execute the continuous latch program without interfering with the operation of other programs. And the latching times and the position data can be read at any time through the TABLE register.&lt;/p&gt;

&lt;p&gt;Routine:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

BASE(0)
ATYPE=1             'pulse-axis
UNITS=100
DPOS=0
SPEED=10
ACCEL=100
DECEL=100
REG_INPUTS=$0      'R0-R3 all correspond to IN0, that is, signals connect to IN (0)
TRIGGER             'trigger the oscilloscope
VMOVE(1)            'axis motion
REGIST(100+4,0,100)  'continuous latch, R0 channel, table(0) saves the latching times, table (1-100) save the data that is latched each time, when it latches over 99 times, table(0) will be cleared to 0, record the data starting from table (1) again.
WAIT UNTIL MARK


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The position data of continuous latch captured by oscilloscope: no need WHILE loop, continuous latch can be achieved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31cyf94otxq7zlbx4e24.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31cyf94otxq7zlbx4e24.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Read latching times and position data through register:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lwc0gr5r1394emsck6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lwc0gr5r1394emsck6k.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (5) Latch Bus Driver
&lt;/h4&gt;

&lt;p&gt;R2 and R3 channels can be used. It supports pulse-axis by setting ATYPE as 4/5, and it supports both EtherCAT and RTEX bus by setting ATYPE as 65/50, then latch MPOS value.&lt;/p&gt;

&lt;p&gt;Using the EtherCAT bus driver, latch mode provided by the controller can be used , and the configuration method is similar to the above. Also, the latch mode that comes with the EtherCAT bus driver can be used (refer to the driver manual to complete the configuration).&lt;/p&gt;

&lt;p&gt;When using the latch mode that comes with the EtherCAT bus driver, select the probe that the driver supports latch, and then access the latch signal.&lt;/p&gt;

&lt;p&gt;Note: the drive PDO needs to contain the 60b8h latched data dictionary, and DRIVE_PROFILE directly selects the mode test with latch.&lt;/p&gt;

&lt;p&gt;The latch mode adopts the mode provided by REGIST (test which modes support is required). After triggering the driver to latch, the driver will automatically transfer the latch position to the corresponding REG_POS / REG_POSB / REG_POSC / REG_POSD, and then the corresponding MARK becomes true, the user does not need to get the information from the driver data dictionary.&lt;/p&gt;

&lt;p&gt;Routine:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

'********************************************************************************************
'bus initialization enable program, when initialization completed, it can run below latch program.
'initialize to configure the data dictionary that needs to be included by driver PDO, DRIVE_PROFILE selects the mode that is with latch to test.
'********************************************************************************************
RAPIDSTOP
WAITIDLE
DIM num,AXIS_Max,TEMP
FOR num=0 TO 7 STEP 1
   BASE(num)
   ATYPE(num)=0
   AXIS_ADDRESS(num)=(-1&amp;lt;&amp;lt;16)+num
   ATYPE(num)=0
NEXT
num=0
SLOT_SCAN(0)
IF RETURN THEN
   ?"bus scanned","the number of connected devices："NODE_COUNT(0)
   'i is the slot No., bit axes
   FOR i=0 to NODE_COUNT(0)-1
      AXIS_Max=NODE_AXIS_COUNT(0,i) 'totals connected by single-device
      ?"AXIS_Max="AXIS_Max
      IF AXIS_Max&amp;lt;&amp;gt;0 THEN
         FOR j=0 TO AXIS_Max-1
            AXIS_ADDRESS(num)=(i&amp;lt;&amp;lt;16)+num+1
            ATYPE(num)=65             'the last step of axis mapping
            'units(num)=2^23/360        'set single-axis pulse amount
            DRIVE_PROFILE(num)=11     'set PDO function
            disable_group(num)          'make a group for each axis independently
            num=num+1                'current device total axes
         NEXT
      ELSE
         ?"no axes for current device"
         END
      ENDIF
   NEXT
   ?"axis mapped! Total axes: "num  
ELSE
   ?"bus scan failed"
   END
ENDIF
DELAY(100)
SLOT_START(0)
IF RETURN THEN
   ?"bus opened"
   DELAY(100)
   DATUM(0)                'clear all axes error states
   DELAY(100)
   ?"start to do axis enable"
   FOR i=0 to num-1
      base(i)
      AXIS_ENABLE=1       'single-axis enable
   NEXT
   WDOG=1                 'axis enable master switch is ON
   ?"axis enabled"
ELSE
   ?"bus open failed"
ENDIF
?"configuration completed"
adasda()                    'call latch function
END
'********************************************************************************************
'Latch function
'select the probe whose driver supports the latch, then connect to latch signal.
Latch mode uses the mode provided by REGIST, after latch is triggered, driver will pass latch position to REG_POS. 
'********************************************************************************************
WHILE 1
   IF OP(0) = ON THEN
      OP(0, OFF)
      temp=-1
   ENDIF
      temp=0
WEND
GLOBAL sub adasda()
   dim num, temp
   num=1
   temp=0
   BASE(0)
   REGIST(100+3,0,100)AXIS(0)    'automatically cycle, no need to write into while loop, table(0) saves the latching times, table (1-100) save the data that is latched each time, when it latches over 99 times, table(0) will be cleared to 0, record the data starting from table (1) again.
   'REGIST(3)
   WHILE 1
      ?"*********************************************************"         
      WA 10
      ?"reg_pos="REG_POS," latch value TABLE="TABLE(num)," occupy TABLE="TABLE(0)       'print
      ?"driver probe mode="NODE_PDOBUFF(0,0,$60B8,0,6)
      ?"driver probe state ="NODE_PDOBUFF(0,0,$60B9,0,6)
      ?"driver latch value ="NODE_PDOBUFF(0,0,$60BA,0,7)
      IF num=100 THEN
         num=1
      ELSE
         num=num+1
      ENDIF
      WA 100     'delay 1ms, anti-shaking
   wend
ENDSUB


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Use the continuous latch mode REGIST(100+3,0,100), and use 100 spaces starting from TABLE(0) to save the latch data, where TABLE(0) saves the number of consecutive latches, TABLE(1)- TABLE(99) save the position of each latch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwdq3wro8udi8xj6rqz5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgwdq3wro8udi8xj6rqz5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foiyot7nw7kjxg6gm0iee.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foiyot7nw7kjxg6gm0iee.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ABOUT ZMOTION&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- &lt;a href="http://www.zmotionglobal.com/support_info_100.html" rel="noopener noreferrer"&gt;Zmotion Motion Controller Position Latch Function&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope to meet you, talk with you and be friends with you.  Welcome!&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together.&lt;/p&gt;

&lt;p&gt;Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

&lt;p&gt;Have a good day, best wishes, see you next time.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Rapidly Achieve Single-Axis / Multi-Axis Synchronous Following Function?</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Thu, 01 Jun 2023 08:16:03 +0000</pubDate>
      <link>https://dev.to/zmotion/how-to-rapidly-achieve-single-axis-multi-axis-synchronous-following-function-34kc</link>
      <guid>https://dev.to/zmotion/how-to-rapidly-achieve-single-axis-multi-axis-synchronous-following-function-34kc</guid>
      <description>&lt;p&gt;From the title, you could get some information, right ?&lt;/p&gt;

&lt;p&gt;Then, in this technical support article, rapidly achieve &lt;a href="http://www.zmotionglobal.com/support_info_95.html" rel="noopener noreferrer"&gt;"single-axis / multi-axis synchronous following" function through MOVESYNC instruction&lt;/a&gt; will be introduced.&lt;/p&gt;

&lt;p&gt;This function is applied in some commonly-used mechanical structures, such as, XYZ(R), SCARA, DELTA, etc., and it is widely used in assemble line dispensing, assemble line production sorting, assemble line carrying, etc.&lt;/p&gt;

&lt;p&gt;After read this article, you will learn more about theory and achievement method of synchronous following, then, work efficiency in your area can be promoted in a way.&lt;/p&gt;

&lt;p&gt;Now, let's begin!&lt;/p&gt;

&lt;h2&gt;
  
  
  01 Synchronous Following Function Introduction
&lt;/h2&gt;

&lt;p&gt;As it is mentioned before, this synchronous following function is achieved mainly by MOVESYNC command. Actually, this instruction is convenient for users to quickly realize the function of single-axis or multi-axis synchronous following through the program, and realizes the grasping and placement of multiple belts. Also, according to its classification, it belongs to a kind of cam instruction.&lt;/p&gt;

&lt;p&gt;We has known the achievement instruction of the synchronous following, but what the function mainly does? This synchronous following function can rapidly control motion institution, achieve product synchronization and following in production line, then can assist other motion commands to realize product line products grasping, sorting, dispensing and other functional requirements.&lt;/p&gt;

&lt;p&gt;Common scenarios: assembly line dispensing, assembly line product sorting, assembly line product handling, etc.&lt;/p&gt;

&lt;p&gt;Common mechanical structures: XYZ (R), SCARA, DELTA, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcxvietzglmpzrzjugsx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvcxvietzglmpzrzjugsx.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  02 MOVESYNC Instruction Description
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Command Introduction
&lt;/h4&gt;

&lt;p&gt;Synchronous following refers to the following of the point, specifically, the following is the position. The operator coordinates the position relationship between the position of the belt and the following axis. What needs to be processed is only the position of the first following moment.&lt;/p&gt;

&lt;p&gt;In the MOVESYNC command, there are important parameters that are mainly to give the position of the belt and the position of the following axis. It is only necessary to statically process the "moment" of the following point, that is, it can be imagined that the belt stops when the object on the belt reaches the position of the sensor "mark".&lt;/p&gt;

&lt;p&gt;At this time, the following axis moves to the product mark point, and two sets of coordinate positions are obtained at this moment:&lt;/p&gt;

&lt;p&gt;Group 1: the syncposition of the belt position.&lt;/p&gt;

&lt;p&gt;Group 2: the position pos1 of the following axis.&lt;/p&gt;

&lt;p&gt;Then, it only needs to fill in these two positions correspondingly into the instruction, and the operator will automatically calculate and plan the positions of the two to ensure that they are relatively stationary.&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Command Function Grammar
&lt;/h4&gt;

&lt;p&gt;MOVESYNC(mode,synctime,syncposition,syncaxis,pos1[,pos2, pos3…])&lt;/p&gt;

&lt;p&gt;It supports single-axis or multi-axis synchronous following.&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) Command General Usage Format
&lt;/h4&gt;

&lt;p&gt;base(0,1,2) //specify the axis No. that participates synchronous following, here, take 0, 1, 2 as the example.&lt;/p&gt;

&lt;p&gt;MOVESYNC (mode,acceleration time,syncposition,syncaxis,pos1,pos2, pos3) //acceleration&lt;/p&gt;

&lt;p&gt;MOVESYNC(mode,synchronous time,syncposition,syncaxis,pos1,pos2, pos3) //synchronization&lt;/p&gt;

&lt;p&gt;MOVESYNC(mode,deceleration time,syncposition,syncaxis,pos1,pos2, pos3) //deceleration (reset)&lt;/p&gt;

&lt;p&gt;It can be seen there are 3 steps for one full following process. Firstly, processing head accelerates to reach the same speed of belt, which means synchronous motion is achieved, in this synchronization, complete processing operation. Then, processing head returns to waiting position, waiting for next to trigger processing. Next, it uses the sensor to detect the materials, recording the material position, filling in MOVESYNC instruction.&lt;/p&gt;

&lt;h4&gt;
  
  
  (4) Command Parameters Description
&lt;/h4&gt;

&lt;p&gt;--mode: mode&lt;/p&gt;

&lt;p&gt;In acceleration and synchronization stages, mode 0 is used usually. And generally, it follows in axis X  direction, and uses mode -2 in deceleration stage (it can finish compulsively the former following motion)&lt;/p&gt;

&lt;p&gt;mode -1: synchronization end mode, it runs to assigned absolute position. If there is other MOVESYNC commands behind this mode, this will be covered, and syncaxis is invalid in this mode.&lt;/p&gt;

&lt;p&gt;mode -2: forced end mode, when it is called, it will stop compulsively the original MOVESYNC, it runs to assigned absolute position. If there is other MOVESYNC commands behind this mode, this will be covered, and syncaxis is invalid in this mode.&lt;/p&gt;

&lt;p&gt;mode 0: the first axis (x) of BASE follows belt axis object.&lt;/p&gt;

&lt;p&gt;mode 10: the second axis (y) of BASE follows belt axis object.&lt;/p&gt;

&lt;p&gt;mode 20: the third axis of BASE follows belt axis object.&lt;/p&gt;

&lt;p&gt;Special note: when there is an angle between the following production line and the machine, use mode 0, and add the radian value of the angle between the machine and the production line to realize tracking deflection compensation, for example:&lt;/p&gt;

&lt;p&gt;mode=0+angle, angle: belt rotation angle, angle = positive rotation angle between the belt and the axis 1/2 of BASE. For example:&lt;/p&gt;

&lt;p&gt;① Mode=PI/4, the belt is in the direction of 45 degrees.&lt;/p&gt;

&lt;p&gt;② Mode=PI/2, the belt is in the y direction.&lt;/p&gt;

&lt;p&gt;③ Mode=PI, the belt is in the negative direction of x.&lt;/p&gt;

&lt;p&gt;④ Mode=(PI*1.75), the belt is in the direction of -45 degrees.&lt;/p&gt;

&lt;p&gt;--synctime: synchronous time, time unit is ms, there are 3 parts for the synchronization.&lt;/p&gt;

&lt;p&gt;Acceleration: how long is the acceleration period means that the machine follows the axis to accelerate to the production line speed and keeps up with the target product. 0 means to estimate the synchronization time according to the speed acceleration of the motion axis, which may not be accurate. Generally, it should be set longer to ensure that synchronization can be achieved.&lt;/p&gt;

&lt;p&gt;Synchronization: the synchronization segment time indicates how long it takes to follow the movement of the product, and during this synchronization, some actions, such as grabbing are completed, and generally the time is set to be relatively long to ensure that the action is completed.&lt;/p&gt;

&lt;p&gt;Deceleration: the deceleration period indicates how long it takes to return to the specified position. Generally, the deceleration period is the same as the acceleration period. It is recommended to use -2 mode.&lt;/p&gt;

&lt;p&gt;--syncposition: the belt axis position when the object on belt axis is detected.&lt;/p&gt;

&lt;p&gt;Special note: this command supports the belt axis coordinate cycle, but when the command is called, make sure that there is no coordinate modification or cycle operation between the parameter position and the current belt axis position, so when this command is called, it should not be near the coordinate cycle point.&lt;/p&gt;

&lt;p&gt;--syncaxis: belt axis No., -1 means there is no belt axis, it can be a motor axis or an encoder&lt;/p&gt;

&lt;p&gt;--pos1: the absolute position of the first axis of BASE (usually the following axis) when the belt axis object is sensed&lt;/p&gt;

&lt;p&gt;--posn: the absolute position of the nth axis of BASE when the belt axis object is sensed&lt;/p&gt;

&lt;h4&gt;
  
  
  (5) Command Usage Diagram (single-axis)
&lt;/h4&gt;

&lt;p&gt;The movesync command only needs to give the position parameters of several axes when the synchronous follow is triggered, as the condition for starting the synchronous following, and then execute the machining after the acceleration reaches the synchronization.&lt;/p&gt;

&lt;p&gt;First conceive and build a following model, as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famd9431q14h7hrjpt8aw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Famd9431q14h7hrjpt8aw.png" alt="Image description" width="800" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assume that following is realized when the product arrives at the sensor position, then the belt position latch is realized by means of the signal of the sensor, that is, when the product reaches the position where the sensor is latched, the belt coordinate (syncposition parameter) is recorded by the latch, and at this time, the following axis X runs to the position of the product latch point, then gets the X-axis position of the following axis as (pos1).&lt;/p&gt;

&lt;p&gt;In this way, the coordinate position in the MOVESYNC command is obtained, that is, the position of the belt at the synchronization moment (syncposition), the position of the following axis (pos1), and then plan the time of the acceleration section, the time of the synchronization section and the time of the deceleration section according to the actual operation situation, the command can be executed to realize a synchronous follow-up process.&lt;/p&gt;

&lt;h2&gt;
  
  
  03 Main Codes
&lt;/h2&gt;

&lt;p&gt;Below take the single-axis following as the example, assist the sensor to record the position.&lt;/p&gt;

&lt;p&gt;When there is no machine, latch signal can be given manually to simulate detecting materials, and record the position information that needs to be filled in synchronous motion command. In HMI interface, click "ON" to start executing synchronization motion. The main function calling relationship of program is shown as below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1qft8mje05x0wl52112.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1qft8mje05x0wl52112.png" alt="Image description" width="800" height="622"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configure HMI interface to operate conveniently, it can modify axis parameters, flexibly adjust each time of synchronous following, then operate following axis through manual motion to wait for the position that triggers synchronous motion and record the current position of following axis. Next open belt axis motion, and give sensor signals during moving, then synchronous motion is triggered, also following axis completes one synchronous following action under MOVESYNC command control.&lt;/p&gt;

&lt;p&gt;This interface shows positions of belt axis and following axis, and it is convenient to configure axis basic parameters, acceleration, synchronization and deceleration time of synchronou motion.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekef2vvm6h5lm5hx1u4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fekef2vvm6h5lm5hx1u4l.png" alt="Image description" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HMI operation steps:&lt;/p&gt;

&lt;p&gt;For the first run, alignment operation is required, confirm the position of the following axis, click "product arrival", the simulated product is placed on the conveyor belt and start to move, stop when it reaches the latch position, and move the following axis to the product position to stop. Record the coordinates of the following axis at this time, which will be used by the MOVESYNC command. &lt;/p&gt;

&lt;p&gt;Configure the axis No. and the motion parameters of the axis, and reasonably set the time of the three-segment motion.&lt;/p&gt;

&lt;p&gt;Click "ON", the conveyor belt runs, the incoming material detection signal is given through the analog signal, the trigger latch to obtain the coordinates of the belt axis, and the trigger synchronization to start.&lt;/p&gt;

&lt;p&gt;Note: because this routine uses the hardware latch function, it needs to run on the controller platform. When there is no sensor, OUT port can be connected to the IN port, and use the OP command to simulate the input of the sensor latch signal. The example connects OUT0 to IN0.&lt;/p&gt;

&lt;p&gt;Latch function: rely on the latch sensor to detect incoming materials, trigger synchronous follow-up movement, when the latch function record starts to follow, latch the position of the belt axis, record the position information of the current synchronous axis, and pass in the parameters of the MOVESYNC command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    REG_INPUTS(belt_axis) = $0000    'map belt latch input

    reg_count = 0
    DMSET mark_flag(0,100,-1)   'clear coordinates before each time starting to avoid wrong judgement

    WHILE 1

        base(belt_axis)
        REGIST(mode)axis(belt_axis)
        wait until mark

        if reg_count &amp;gt;= 100 then     'judge position array loop stored values   
            reg_count = 0
        endif 

        mark_pos(reg_count) = REG_POS
        ?REG_POS
        mark_flag(reg_count) = 1
        reg_count = reg_count + 1
    wend
endsub 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Synchronous following function: rely on the parameters given by the latch function, set following time, execute synchronous following actions, there are acceleration, synchronization and deceleration three stages. Please pay attention to plan each time reasonably, waiting for next trigger to follow after completed one following steps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;global sub run_sync()
    base(sync_axis)
    move_count = 0   'clear motion counts to 0
    TABLE(10) = -1    'table 10 value as the mark of synchronization end    
    WHILE 1
        if move_count &amp;gt;= 100 then    'loop  
            move_count = 0  
        endif 

            if mark_flag(move_count) = 1 then    'judge whether there is product that is triggered
            if abs(sync_star_dis + mark_pos(move_count)) &amp;gt;= abs(mpos(belt_axis)) then     'follow if it is in valid trigger distance

                'start to follow

                'the first section: acceleration (chasing), the following mode is determined by institution, generally, 0 is used when belt encoder direction and following axis motion direction are consistent, if directions are opposite, use 0+pi/2
                MOVESYNC(0, accel_time, mark_pos(move_count), belt_axis, sync_pos)

                'the second section: synchronization, the only difference is the time
                MOVESYNC(0, sync_time, mark_pos(move_count), belt_axis, sync_pos)

                'here, it can open thread to operate other actions
                'use move_task command to operate.

                'use table 10 value to be as the end mark of other motions, here, use move_table for synchronization complete-end, then later it can use MOVE_TABLE in other motion thread when developing
                MOVE_TABLE(10,10)

            elseif abs(sync_star_dis + mark_pos(move_count)) &amp;lt; abs(mpos(belt_axis)) then     'exceed the range, skip directly.

                TABLE(10) = 10
                ?"skip"
                '?abs(sync_star_dis + mark_pos(move_count)) , abs(mpos(belt_axis))
            endif

            'judgement ends
            wait UNTIL table(10) = 10

            'the third section: reset, the current position as the stop position, then the standby position can be set by adding variables
            MOVESYNC(-1, decel_time, mark_pos(move_count),-1, sync_pos)

            move_table(10,-1)   'end mark resets
            mark_flag(move_count) = -1   'synchronization condition mark resets
            move_count = move_count + 1    'count + 1
        endif 
    wend 
endsub

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  04 Running Effects
&lt;/h2&gt;

&lt;p&gt;Following axis (axis 0) follows belt axis (axis 2).&lt;/p&gt;

&lt;p&gt;Speed curve: acceleration, synchronization, deceleration (back to the starting point)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frablus85pjl1wsag7vdd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frablus85pjl1wsag7vdd.png" alt="Image description" width="800" height="397"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following axis (axis 0) follows belt axis (axis 2).&lt;/p&gt;

&lt;p&gt;Position curve:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9idhsg96jo3xrcjjzkej.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9idhsg96jo3xrcjjzkej.png" alt="Image description" width="800" height="482"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;ABOUT ZMOTION&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- &lt;a href="http://www.zmotionglobal.com/support_info_95.html" rel="noopener noreferrer"&gt;How To Rapidly Achieve Single-Axis / Multi-Axis Synchronous Following Function For Zmotion Motion Controller.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope to meet you, talk with you and be friends with you.  &lt;a href="//www.zmotionglobal.com"&gt;Welcome!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together.&lt;/p&gt;

&lt;p&gt;ZMOTION: DO THE BEST TO USE MOTION CONTROL.&lt;/p&gt;

&lt;p&gt;Note: Copyright belongs to Zmotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

&lt;p&gt;Have a good day, best wishes, see you next time.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>High &amp; Soft SS Curve Application on Lithium Battery Welding</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Mon, 08 May 2023 08:56:41 +0000</pubDate>
      <link>https://dev.to/zmotion/high-soft-ss-curve-application-on-lithium-battery-welding-2kmn</link>
      <guid>https://dev.to/zmotion/high-soft-ss-curve-application-on-lithium-battery-welding-2kmn</guid>
      <description>&lt;p&gt;As we all know, since the development of technology, lithium battery is with long service life, strong adaption and high energy. Therefore, the lithium battery is used widely in all kinds of applications, such as electronics, transportation, etc., and derived lithium battery welding and other production industries are also developing rapidly in the market.&lt;/p&gt;

&lt;p&gt;In this way, the market competition environment is very fierce, then for lithium battery, it requires higher and higher precision. Now, let's see how high and soft SS curve is achieved in lithium battery welding application.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Introduction
&lt;/h2&gt;

&lt;p&gt;Through commands, HW_PSWITCH2, MOVE_HWPSWITCH, HW_TIMER and others all are used to realize hardware comparison output PSO.&lt;/p&gt;

&lt;p&gt;For example, when doing the fillet processing of lithium battery welding, the output spacing can be kept constant while decelerating, and the SS curve processing technology is combined to increase the process flexibility. It not only ensures the processing effect, reduces mechanical vibration, but also maximizes production capacity.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3rku2wdgprttojg4tqq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz3rku2wdgprttojg4tqq.png" alt="Image description" width="704" height="320"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Axis Speed Curve
&lt;/h2&gt;

&lt;p&gt;Common motion curves are ladder (T) speed curve and S speed curve. Actually, Zmotion developed one another speed curve based these two, SS Speed Curve.&lt;/p&gt;

&lt;p&gt;Next, show one by one for you.&lt;/p&gt;

&lt;h4&gt;
  
  
  (1) Ladder speed curve
&lt;/h4&gt;

&lt;p&gt;This kind of curve also can be called T curve, which is used to express the relationship between the speed and the time. As shown below, there are 3 stages for standard ladder speed curve, constant acceleration, constant and constant deceleration stages.&lt;/p&gt;

&lt;p&gt;Therefore, in interpolation motion, use Basic instructions directly to set speed parameters (SPEED, ACCEL, DECEL) when axis parameters are initializing.&lt;/p&gt;

&lt;p&gt;This kind of curve is applied extremely widely because of fastest planning and simple usage in motion control.&lt;/p&gt;

&lt;p&gt;Simple and fast correspond to not so smooth, and the corner acceleration is not consecutive, then easily cause machine shake in actual interpolation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvn7b4jeg30yxu1xhcbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgvn7b4jeg30yxu1xhcbg.png" alt="Image description" width="635" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) S speed curve
&lt;/h4&gt;

&lt;p&gt;Also, S speed curve is used to show speed and time relationship. The difference is this will process smooth in acceleration and deceleration stage, then the curve shape looks like "S", please refer to below graphic.  &lt;/p&gt;

&lt;p&gt;In actual motion application, there is one specified instruction "SRAMP" provided by Zmotion Basic language, using it to set corresponding value for reducing shakes in control process, then the speed curve in motion will be smoother.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjembgsz0dql7pftz75tx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjembgsz0dql7pftz75tx.png" alt="Image description" width="697" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The grammar of SRAMP: VAR1 = SRAMP, SRAMP = smoothms.&lt;/p&gt;

&lt;p&gt;smoothms: millisecond unit, the acceleration and deceleration process will extend the corresponding time after setting, the length of time that can be set and the actual extension time of acceleration and deceleration are related to distance, speed, and accel.&lt;/p&gt;

&lt;h4&gt;
  
  
  (3) SS speed curve
&lt;/h4&gt;

&lt;p&gt;SS speed curve is also named as jerk curve. Similarly, it displays the speed and the time.&lt;/p&gt;

&lt;p&gt;But what is it exactly ?&lt;/p&gt;

&lt;p&gt;In fact, it is the physical quantity that describes acceleration changes, namely, change ratio of acceleration.&lt;/p&gt;

&lt;p&gt;It is developed by Zmotion, including the Basic commands, "VP_MODE", it can be used to achieve SS curve through mode 6 and mode 7.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03wtlqwelfaj05sispg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03wtlqwelfaj05sispg9.png" alt="Image description" width="698" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the jerk is smoothed, in some high-precision motion industrial applications, the phenomenon of excessive shock and vibration caused by the rapid acceleration rate of the mechanism can be reduced.&lt;/p&gt;

&lt;p&gt;For example, in the common lithium battery welding processing industry, when performing track welding on the top cover of the power battery, applying SS curves to it in each corner chamfering motion can effectively increase the flexibility, and reduce machine vibration and impact, making the welding process more stable and continuous.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Speed Curve Theoretical Analysis
&lt;/h2&gt;

&lt;p&gt;As mentioned above, the trapezoidal velocity curve has only three stages, uniform acceleration, uniform velocity and uniform deceleration.The S-shaped curve can be divided into 7 stages because the acceleration and deceleration stages are smoothed, as shown in the figure below, the range of action of the S-curve is T1, T3, T5, and T7, the range of action of the SS curve is also the same, the difference is that the SS curve acceleration changes more smoothly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbds0cyy267cdwg3yys8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbds0cyy267cdwg3yys8.png" alt="Image description" width="691" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, how jerk come out?&lt;/p&gt;

&lt;p&gt;In acceleration and deceleration process, acceleration is changeable, one new variable is needed, "J" -- jerk.&lt;/p&gt;

&lt;p&gt;J=da/dt&lt;/p&gt;

&lt;p&gt;In the acceleration changes, the maximum acceleration is defined as a max, the minimal is -a max, in this way, the relationship between acceleration and jerk in each stage is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmcmpwr2ggr9996uoye18.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmcmpwr2ggr9996uoye18.png" alt="Image description" width="505" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Generally, 3 basic system parameters are required to determine the whole running process.&lt;/p&gt;

&lt;h4&gt;
  
  
  (1) acceleration and time relation
&lt;/h4&gt;

&lt;p&gt;According to the acceleration change curve in the above figure, it can be seen that T1-T3 is the constant acceleration stage, T4 is the constant acceleration stage, and T5-T6 is the constant deceleration stage , and there is another variable μ:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofua61pkrc6z8mtrh4q8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofua61pkrc6z8mtrh4q8.png" alt="Image description" width="311" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Depend on above two formulas, functional relationship between acceleration and speed should be:  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18qkxampkp7oy60d1sg2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F18qkxampkp7oy60d1sg2.png" alt="Image description" width="464" height="184"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) speed and time relation
&lt;/h4&gt;

&lt;p&gt;The functional relationship between speed and acceleration is: v=at, then the relationship between jerk and speed satisfies:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6bir20cw15w9nt4tg76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6bir20cw15w9nt4tg76.png" alt="Image description" width="151" height="71"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Combined with the acceleration time relationship and the above acceleration and time relationship function, the following relationship can be obtained:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal5hvtckzi2t0rpp0kme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fal5hvtckzi2t0rpp0kme.png" alt="Image description" width="556" height="249"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After simplification, we get:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3uy3o1f2hziymax8rcex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3uy3o1f2hziymax8rcex.png" alt="Image description" width="371" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all for the functional relationship among the curve changes among speed, acceleration and jerk.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. VP_MODE
&lt;/h2&gt;

&lt;h4&gt;
  
  
  (1) Introduction
&lt;/h4&gt;

&lt;p&gt;The acceleration and deceleration curve type can be set through the VP_MODE command. And there are multiple modes to choose, S-curve and SS curve can be set to make the trapezoidal curve smoother. This instruction is generally used in the axis parameter initialization program and can be used together with the SRAMP instruction. When VP_MODE is mode 0, the value set by SRAMP takes effect.&lt;/p&gt;

&lt;p&gt;Syntax: VAR1 = VP_MODE or VP_MODE(axis)=mode&lt;/p&gt;

&lt;p&gt;mode: mode selection&lt;/p&gt;

&lt;p&gt;The VP_MODE mode is as follows.&lt;/p&gt;

&lt;p&gt;--Mode 0--&lt;/p&gt;

&lt;p&gt;By default, use SRAMP to set the S-curve.&lt;/p&gt;

&lt;p&gt;--Mode 4--&lt;/p&gt;

&lt;p&gt;The maximum acceleration is at the start, and the acceleration gradually becomes 0 when the maximum speed is reached. The S and SS curves are shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y7skf804xqmvfeoljz7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y7skf804xqmvfeoljz7.png" alt="Image description" width="596" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This mode is suitable for high-speed start-stop processing occasions that do not require impact.&lt;/p&gt;

&lt;p&gt;--Mode 6--&lt;/p&gt;

&lt;p&gt;A new type of SS curve, a curve type with continuous jerk, SS mode will increase the deceleration time by 87% compared with T-shaped deceleration. This mode only takes effect in the deceleration phase, and the acceleration phase takes effect in mode 0, which is convenient for continuous small line segment interpolation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw47n26ysh1nibomsqw0v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw47n26ysh1nibomsqw0v.png" alt="Image description" width="604" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This mode is suitable for processing occasions where the machine starts at high speed and stops smoothly.&lt;/p&gt;

&lt;p&gt;--Mode 7--&lt;/p&gt;

&lt;p&gt;New type SS curve, curve type with continuous jerk. Dynamically modifying the axis parameters or continuous interpolation may cause the jerk to be uncontinuous. At this time, it will switch to mode 0, so it is recommended that SRAMP also set an appropriate value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwum2ll02c96nd9aah7lu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwum2ll02c96nd9aah7lu.png" alt="Image description" width="607" height="392"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This mode is suitable for shock-free processing occasions with high precision and stable start-stop speed.&lt;/p&gt;

&lt;h4&gt;
  
  
  (2) Examples &amp;amp; Routines
&lt;/h4&gt;

&lt;p&gt;Following all routines can be achieved through ZMC432 controller.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwiwij9umdvvi28vsjml.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwiwij9umdvvi28vsjml.png" alt="Image description" width="688" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--set VP_MODE as mode 0, take the single-axis motion as the example--&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2) 'stop all former axes
WAIT IDLE(0) 'wait for axis 0 to stop
BASE(0) 'set axis
ATYPE=1 'set axis type as pulse
UNITS=1000 'set pulse amount
DPOS=0 
MPOS=0
SPEED=100 'set the speed as 100
ACCEL=1000 'set acceleration as 1000
DECEL=1000 'set deceleration as 1000
SRAMP=50 'set S curve time as 50ms
VP_MODE=0 'set mode 0 for axis 0
TRIGGER
MOVE(25) 'single-axis motion 25
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When SRAMP=50, the speed and acceleration curves are shown in the figure below, which are smoothed in the acceleration and deceleration phases respectively, and the movement time will be extended accordingly. It can be compared with the graph when SRAMP=0.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faiezhhm663we21u6jwcq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faiezhhm663we21u6jwcq.png" alt="Image description" width="437" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When SRAMP=0:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zw9shhgbcbvteifkl8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7zw9shhgbcbvteifkl8h.png" alt="Image description" width="440" height="241"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--set VP_MODE as mode 4, take multi-axis linear interpolation as the example--&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2) 'stop all former axes
WAIT UNTIL IDLE(0) AND IDLE(1) 'wait for axis 0 and axis 1 to stop
BASE(0,1) 'set axis, axis 0 is the master axis
ATYPE=1,1
UNITS=1000,1000
DPOS=0,0
MPOS=0,0
SPEED=100,100 'set axis 0 and axis 1 speed as 100
ACCEL=1000,1000
DECEL=1000,1000
MERGE=ON 'open continuous interpolation
SRAMP=0,0 'don't set S curve
VP_MODE=4,0 'set mode 4 for axis 0, and set mode 0 for axis 1
TRIGGER
MOVE(25,25) 'interpolation motion
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the above configuration, axis 0 adopts VP_MODE mode 4, starts to move with the highest acceleration and decreases to 0. This mode is suitable for occasions requiring quick start and stop.&lt;/p&gt;

&lt;p&gt;Note: since this movement is an interpolation movement, axis 0 is the main axis, so the speed and acceleration curves can be based on the main axis. The VP_ACCEL data source needs to be manually input to collect changes in acceleration values under the S-curve and SS-curve.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosskp1y5yt46hr2q9u0e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fosskp1y5yt46hr2q9u0e.png" alt="Image description" width="440" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--set VP_MODE as mode 6, take multi-axis linear interpolation as the example--&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2) 'stop all former axes
WAIT UNTIL IDLE(0) AND IDLE(1) 'wait for axis 0 and axis 1 to stop
BASE(0,1) 'set axis, axis 0 is the master axis
ATYPE=1,1
UNITS=1000,1000
DPOS=0,0
MPOS=0,0
SPEED=100,100 'set axis 0 and axis 1 speed as 100
ACCEL=1000,1000
DECEL=1000,1000
MERGE=ON 'open continuous interpolation
SRAMP=0,0 'don't set S curve
VP_MODE=6,0 'set mode 6 for axis 0, and set mode 0 for axis 1
TRIGGER
MOVE(25,25) 'interpolation motion
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When VP_MODE is set to mode 6, only the deceleration phase is smoothed. When the S or SS curve is not set during the acceleration phase, the acceleration will reach the maximum value at the moment of power-on, and it will move with the set acceleration. When the SS curve is set in the deceleration phase, it can be seen from the figure below that the acceleration curve is decelerated smoothly, making the motion transition more natural and smooth during the deceleration phase.&lt;/p&gt;

&lt;p&gt;This mode is suitable for continuous interpolation occasions to improve efficiency while ensuring smooth motion.&lt;/p&gt;

&lt;p&gt;Note: since this movement is an interpolation movement, axis 0 is the main axis, so the speed and acceleration curves can be based on the main axis.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf93kmim3kg2hr34hvd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf93kmim3kg2hr34hvd1.png" alt="Image description" width="440" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--set VP_MODE as mode 7, take track processing in lithium battery industry as the example--&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RAPIDSTOP(2) 'stop all former axes
WAIT UNTIL IDLE(0) AND IDLE(1) 'wait for axis 0 and axis 1 to stop
BASE(0,1) 'set axis 0 and axis 1
ATYPE=1,1
UNITS=1000,1000
DPOS=0,0
MPOS=0,0
SPEED=100,100 'set axis 0 and axis 1 speed as 100
ACCEL=1000,1000 'set axis 0 and axis 1 acceleration as 1000
DECEL=1000,1000
MERGE=ON
SRAMP=100,100 'set S curve time as 100
VP_MODE=7,7 'set mode 7 for axis 0, namely, set SS curve
TRIGGER
MOVE(10,0) 'axis 0 moves 10 forward 
MOVECIRC(2.5,2.5,0,2.5,0) 'move circular motion, the radius is 2.5
MOVE(0,10) 'axis 1 moves 10 forward 
MOVECIRC(-2.5,2.5,-2.5,0,0)
MOVE(-20,0) 'axis 0 moves 20 reversely 
MOVECIRC(-2.5,-2.5,0,-2.5,0)
MOVE(0,-10) 'axis 1 moves 10 reversely 
MOVECIRC(2.5,-2.5,2.5,0,0)
MOVE(10,0) 'axis 0 moves 10 forward 
END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VP_MODE is set to mode 7, and the image after smoothing the SS curve is as follows, which can be compared with the VP_ACCEL acceleration curve (light blue line) in the figure below. It is suitable for occasions with large motion jitter.&lt;/p&gt;

&lt;p&gt;Note: since this movement is an interpolation movement, axis 0 is the main axis, so the speed and acceleration curves can be based on the main axis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1v03zdwoas8169nu42mk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1v03zdwoas8169nu42mk.png" alt="Image description" width="454" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Interpolation trajectory of axis 0 and axis1 under XY mode:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jvfittq6z7dg0q2gytr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jvfittq6z7dg0q2gytr.png" alt="Image description" width="457" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;--SS curve is not set--&lt;/p&gt;

&lt;p&gt;SRAMP=100,100 'set S curve time as 100&lt;/p&gt;

&lt;p&gt;VP_MODE=0,0    'cancel SS curve&lt;/p&gt;

&lt;p&gt;It can be seen from the sampled waveform, it moves according to current S curve.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05mze6ivawynzrwavdxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F05mze6ivawynzrwavdxg.png" alt="Image description" width="457" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From this, it can be compared that VP_MODE=7, the speed curve of SS acceleration and deceleration of axis 0 and axis 1 is softer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhhdj0t6zca2yvf1aeuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhhdj0t6zca2yvf1aeuh.png" alt="Image description" width="456" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- &lt;a href="http://www.zmotionglobal.com/support_info_92.html" rel="noopener noreferrer"&gt;Zmotion Motion Control Lithium Welding Application: High &amp;amp; Soft SS Curve&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have a good day, best wishes, see you next time.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to Choose the Bus Motion Controller in the era of industrial Ethernet?</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Mon, 24 Apr 2023 06:37:14 +0000</pubDate>
      <link>https://dev.to/zmotion/how-to-choose-the-bus-motion-controller-in-the-era-of-industrial-ethernet-47hn</link>
      <guid>https://dev.to/zmotion/how-to-choose-the-bus-motion-controller-in-the-era-of-industrial-ethernet-47hn</guid>
      <description>&lt;p&gt;Question from A:&lt;br&gt;
A (one controller supplier)&lt;br&gt;
Q&lt;br&gt;
Pulses belong to parallel communication, but EtherCAT belongs to serial communication, then communication delay may be produced, synchronization of bus is worse than pulses?&lt;/p&gt;

&lt;p&gt;Answer:&lt;br&gt;
Actually it is opposite, EtherCAT doesn't equal to EtherNet, and synchronization between master and slave stations of EtherCAT doesn't coordinate through arrival time of data frame. From order issuance, EtherCAT synchronization is better.&lt;/p&gt;

&lt;p&gt;Question from B:&lt;br&gt;
B (one controller supplier)&lt;br&gt;
There is 1000M bus, which is 10 times of 100M, therefore, our synchronization also is better than EtherCAT ？&lt;/p&gt;

&lt;p&gt;Answer:&lt;br&gt;
EtherCAT is extremely advanced fieldbus, and the distributed clock brought by specialized communication chip (ESC) to achieve synchronization of each slave station tasks, the synchronization error is &amp;lt;&amp;lt;1us (it should be 20ns in theory).&lt;/p&gt;

&lt;p&gt;Next, let's learn deeply.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbjjmvxkallqqn9u3gyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzbjjmvxkallqqn9u3gyq.png" alt="Image description" width="698" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EtherCAT is an open and advanced fieldbus developed by the EtherCAT Foundation based on Ethernet. It ensures efficient and reliable data transmission through a series of unique mechanisms.&lt;/p&gt;

&lt;p&gt;And EtherCAT only needs to use a 100M network cable to realize data transmission. The common topology structure is daisy chain, namely, the master station (controller) is connected to the first slave station (motor, IO module, etc.), then the first slave station is connected to the second slave station, connect continuously. In addition, EtherCAT also supports other topologies.&lt;/p&gt;

&lt;p&gt;Although you only see one network cable connected, the 100M network cable actually contains 4 lines, two of which are used to output data (TX), and two are used to return data (RX). Therefore, in fact, one loop is formed internally, as shown in the figure below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsnndt2hxiew65hu1m7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbsnndt2hxiew65hu1m7g.png" alt="Image description" width="685" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The EtherCAT master station needs to use a real-time operating system + standard Ethernet chip + EtherCAT protocol stack, and the slave station needs to use a special communication chip (ESC) to ensure high-speed and stable communication.&lt;/p&gt;

&lt;p&gt;Therefore, although their external interfaces are all network ports "RJ45 interface",  EtherCAT and EtherNET are very different at the hardware level, not just the difference in the data layer.&lt;/p&gt;

&lt;p&gt;During the official work of EtherCAT (PDO communication), only one data frame is transmitted at high speed between the master station and the slave station. When passing through each slave station, each slave station takes down the required data, such as, command position, control word, etc., then it inserts the data that needs reporting (feedback position, motor status, etc.). It is the same principle as one high-speed train has to pick up and drop off passengers at every station.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3guc6t333yexcwminby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3guc6t333yexcwminby.png" alt="Image description" width="695" height="343"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But it is faster than high-speed rail, EtherCAT processes data in flight through a dedicated chip (ESC), instead of waiting until the data is completely received before processing and sending. Therefore, high-speed data exchange can be achieved.&lt;/p&gt;

&lt;p&gt;As mentioned before, the EtherCAT slave chip (ESC) has a distributed clock. What exactly is this?&lt;/p&gt;

&lt;p&gt;The field bus is generally serial communication, so there must be a time difference when reaching each slave station. No matter how fast the high-speed rail is, it cannot reach Shanghai and Kunshan at the same time.&lt;/p&gt;

&lt;p&gt;So how does EtherCAT ensure that the slave stations act in unison without falling behind? The answer is the distributed clock.  &lt;/p&gt;

&lt;p&gt;The EtherCAT master station will select the first slave station with clock (DC) function as the clock master station (DC Master), and each slave station will be synchronized according to the time of the clock master station. In this way, if multiple motors do multi-axis interpolation, they can refer to the precise clock signal to sample at a unified time (collect command data), and act at a unified time, like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xf0humogi21e0ij2ea9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xf0humogi21e0ij2ea9.png" alt="Image description" width="685" height="388"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each slave station has its own watch, like those police and gangster movies, the officer said: Now put on the watch, and act together at 8:50 in the evening (the expression must be serious when you say it).&lt;/p&gt;

&lt;p&gt;Of course, the clock (DC) of EtherCAT is not dialed manually, but EtherCAT calculates the clock error between each slave station through a complex mechanism, then corrects it in real time to ensure that the time keeps a very small error between each slave station (much less than 1us, the official test data is about 20ns).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5i9wysqg923zbysnjkv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5i9wysqg923zbysnjkv.png" alt="Image description" width="669" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Going back to the original question, compared with the pulse motor, the pulse drive receives the data at the same time, but there is no way to coordinate the clock signal between the drives, so it is inferior to EtherCAT in theory.&lt;/p&gt;

&lt;p&gt;In fact, most applications are restricted in the performance of motor debugging, so our feelings are not obvious, but EtherCAT has already laid the foundation for precise synchronization at the bottom layer.&lt;/p&gt;

&lt;p&gt;Some friends may say, don't brag, I know that the next generation standard of  EtherCAT is EtherCAT G, which is also the Gigabit bus, which means Gigabit is better. However, the fact is that EtherCAT G is not designed to improve synchronization ( It is already very good), what is its significance, it will be introduced in detail in the next technical support article).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnl0uxnj3e09h9qn6h9qo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnl0uxnj3e09h9qn6h9qo.png" alt="Image description" width="696" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to the above advantages, EtherCAT has many other advantages, including simple wiring, convenient interference checking, no trouble of losing pulses, rich transmission data (such as absolute value data, torque status), etc.&lt;/p&gt;

</description>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Achieve Multi-axis Linear Interpolation &amp; Electronic Cam By PLC For EtherCAT Motion Controller?</title>
      <dc:creator>Zmotion Controller</dc:creator>
      <pubDate>Wed, 16 Nov 2022 11:51:02 +0000</pubDate>
      <link>https://dev.to/zmotion/economical-ethercat-motion-controller-3-multi-axis-linear-interpolation-electronic-cam-achievement-through-plc-45je</link>
      <guid>https://dev.to/zmotion/economical-ethercat-motion-controller-3-multi-axis-linear-interpolation-electronic-cam-achievement-through-plc-45je</guid>
      <description>&lt;h2&gt;
  
  
  01 Preparations
&lt;/h2&gt;

&lt;p&gt;Firstly, download the latest programming software "ZDevelop".&lt;/p&gt;

&lt;p&gt;Then, prepare one XPLC series EtherCAT bus motion controller, and do wiring between EtherCAT motion controller and ZDevelop.&lt;/p&gt;

&lt;p&gt;[ Note: if there is no controller, ZBasic development also can be done through simulation -- download the program into simulator. The simulator has been built in ZDevelop]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaolydhz30lwwa9mbbq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjaolydhz30lwwa9mbbq4.png" alt="Image description" width="704" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  02 Download PLC into Controller
&lt;/h2&gt;

&lt;p&gt;(1) New build project item, and download program files into controller for motion. Please refer to below process showing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4qgs409y5jemetak1wcn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4qgs409y5jemetak1wcn.png" alt="Image description" width="385" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2) Open ".zpj" file -- connect to controller -- download the program -- program can run.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x4z9q3mnc1w9dlx372p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3x4z9q3mnc1w9dlx372p.png" alt="Image description" width="687" height="527"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is recommended to set only one main file for PLC automatic operation, so that the PLC has only one main loop, and other modules are called in the main loop.&lt;/p&gt;

&lt;p&gt;PLC commands are not case-sensitive. There is one uniform API function, for PLC commands' details, Please refer to the "ZMotion PLC Programming Manual" &lt;/p&gt;

&lt;h2&gt;
  
  
  03 PLC Ladder of Diagram Program
&lt;/h2&gt;

&lt;p&gt;The ladder diagram programming method is to draw the sequential control ladder diagram on the programming interface by using sequence symbols and soft element numbers. Since the sequential control loop is represented by contact symbols and coil symbols, which means the display is more intuitive and the program content is easier to understand.&lt;/p&gt;

&lt;p&gt;What's more, it is more convenient to monitor and debug the program in the ladder diagram display state. The ladder diagram display example is shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcnsoptaarlp5yql0mbpk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcnsoptaarlp5yql0mbpk.png" alt="Image description" width="685" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please attention, END program end command must be included in program ending. Otherwise, it will report errors, and it can't be downloaded into controller for execution.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ho4bo3zlyknvioi04vu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ho4bo3zlyknvioi04vu.png" alt="Image description" width="701" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(1) For PLC instructions, there are several types according to instruction usages.&lt;/p&gt;

&lt;p&gt;A. commonly used instructions: fetching contacts, output coils, timers, counters, etc.&lt;/p&gt;

&lt;p&gt;B. contact comparison instructions: compare the values of two registers, and if the condition is met, the contact will be conducted.&lt;/p&gt;

&lt;p&gt;C. transfer and comparison instructions: compare and transfer data between registers according to the rules.&lt;/p&gt;

&lt;p&gt;D. loop and jump instructions: including conditional loop instruction and jump to subroutine execution instructions.&lt;/p&gt;

&lt;p&gt;E. operation instructions: including four arithmetic operations and logical operation instructions.&lt;/p&gt;

&lt;p&gt;F. shift instruction: move the data of the source operand bit by bit.&lt;/p&gt;

&lt;p&gt;G. data processing instructions: perform other operations, such as encoding, decoding, etc.&lt;/p&gt;

&lt;p&gt;H. floating-point arithmetic instructions: operations on 32-bit floating-point numbers.&lt;/p&gt;

&lt;p&gt;I. other instructions: parameters related to axis motion.&lt;/p&gt;

&lt;p&gt;(2) There are 16-bit PLC instructions and 32-bit PLC instructions according to operands bit.&lt;/p&gt;

&lt;p&gt;16-bit data and 32-bit data are processed using different instructions. Except for the data length, the two are the same in other respects, and the processing data types both are with signed numbers.&lt;/p&gt;

&lt;p&gt;→ 16-bit instruction -- the value range transmitted: -32768 -+32767.&lt;/p&gt;

&lt;p&gt;→ 32-bit instruction -- the value range transmitted: -2147483648 - +2147483647.&lt;/p&gt;

&lt;p&gt;(32-bit instructions generally occupy two consecutive 16-bit spaces)&lt;/p&gt;

&lt;p&gt;(3) There are consecutive execution type and pulse execution type according to execution methods.&lt;/p&gt;

&lt;p&gt;→ consecutive execution: each scan period executes once when conditions are met.&lt;/p&gt;

&lt;p&gt;→ pulse execution: only execute once when conditions are met.&lt;/p&gt;

&lt;p&gt;(Note: consecutive execution instruction + symbol P = pulse execution instruction)&lt;/p&gt;

&lt;p&gt;(4) PLC soft-element form&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffyo8dge4w80sywcxl1go.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffyo8dge4w80sywcxl1go.png" alt="Image description" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The data type of counter C and timer T is related to the instruction used when accessing. When accessing through 16-bit instruction, the lower 16 bits are automatically used, and when accessing through 32-bit instruction, 32 bits are used.&lt;/p&gt;

&lt;p&gt;(5) Corresponding relation between PLC and related register of Basic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8nx6ko4nuyl1zsaoaxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8nx6ko4nuyl1zsaoaxo.png" alt="Image description" width="800" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  04 PLC Calls Basic Instructions
&lt;/h2&gt;

&lt;p&gt;PLC can call Basic standard instructions through EXE instructions or EXEP instructions.&lt;/p&gt;

&lt;p&gt;EXEP instructions are pulse format of EXE instructions, which can be used to call Basic standard instruction only when drive output is from OFF to ON.&lt;/p&gt;

&lt;p&gt;Grammar Format:  "EXE   &lt;a class="mentioned-user" href="https://dev.to/basic"&gt;@basic&lt;/a&gt; instruction" is equal to "BASIC instruction".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32xsvw1jnh8obmes3tpn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32xsvw1jnh8obmes3tpn.png" alt="Image description" width="681" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: When using the EXE instruction to call the register, refer to the syntax of Basic after @, and "EXE @DT0=10" cannot appear, the correct writing should be "EXE @TABLE(0)=10".&lt;/p&gt;

&lt;p&gt;Call the Basic linear interpolation syntax in the PLC as shown in the above figure, the linear interpolation PLC syntax "MOVE D0 D2", the operand should be in the format supported by the PLC operand, and the interpolation data is transmitted by the register, which means it cannot be given directly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms2ihjf1lqzxeaxado4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms2ihjf1lqzxeaxado4w.png" alt="Image description" width="682" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  05 PLC Linear Interpolation Routine
&lt;/h2&gt;

&lt;p&gt;Control pulse axis 0 and axis 1 do linear interpolation motion, then axis parameters and motion instructions call Basic instruction through EXE, and download edited program into XPLC006E for debugging and running.&lt;/p&gt;

&lt;p&gt;(1) PLC control program.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zm3yhd386cx0j054as1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zm3yhd386cx0j054as1.png" alt="Image description" width="683" height="804"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2) Program description&lt;/p&gt;

&lt;p&gt;When the program is powered on and initialized, various parameters of the axis are initialized.&lt;/p&gt;

&lt;p&gt;And when the rising edge of X0 is triggered, assign values to the registers D0 and D2 that store the moving distance of the two axes. When triggered by the rising edge of X1, the oscilloscope sampling is started, the MOVE linear interpolation movement is enabled and M0 is self-locking. The moving distance of axis 0 is 300, and motion distance of axis 1 is 400.&lt;/p&gt;

&lt;p&gt;M8100 is the IDLE mark of axis 0. When the motion is completed, axis 0 stops, M8100 turns to ON, M1 is set for one cycle, the normally closed contact of M1 is disconnected for one cycle, and M0 self-locking is canceled.&lt;/p&gt;

&lt;p&gt;Press X1 again, MOVE executes the linear interpolation motion of axis 0 and axis 1.&lt;/p&gt;

&lt;p&gt;X2 is the emergency stop button, if the axis presses X2 during motion, it will stop quickly according to the value set by FASTDEC fast deceleration.&lt;/p&gt;

&lt;p&gt;(3) Positions and speed curv of axis 0 and axis 1 captured by oscilloscope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7u0dqdhrh7257vp1erb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz7u0dqdhrh7257vp1erb.png" alt="Image description" width="684" height="422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(4) Achieved program of above PLC program in Basic.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FOR i=0 TO 10         'MODBUS_BIT register is cleared

   MODBUS_BIT(i)=0

NEXT

BASE(0,1)                 'axis 0 and axis 1 parameters are initialized

UNITS = 100,100

ATYPE =1,1

SPEED = 200,200

ACCEL = 1000,1000

DECEL = 1000,1000

SRAMP = 200,200

DPOS = 0,0

MPOS = 0,0

FASTDEC = 20000,20000

WHILE 1                                 'loop detection input

   IF IN_SCAN(0,2) THEN         'scan electric level changes of IN0-2

   IF IN_EVENT(1)&amp;gt; 0 THEN     'open

       TRIGGER

       MOVE(300,400)

   ELSEIF IN_EVENT(2)&amp;gt; 0 THEN      'stop

       RAPIDSTOP(2)

   ENDIF

 ENDIF

WEND

END
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  06 PLC Shear-Cutting (Electronic Cam) Routine.
&lt;/h2&gt;

&lt;p&gt;The PLC completes the shearing process by calling the MOVESLINK automatic cam command of Basic. The slave axis of the MOVESLINK automatic cam automatically plans the speed to follow the main axis movement. For the instruction usage, please refer to ZBasic Program Manual. And the main components of the PLC program are as follows:&lt;/p&gt;

&lt;p&gt;(1) initialization part:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dzhyqbilk8mlskudqnq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3dzhyqbilk8mlskudqnq.png" alt="Image description" width="682" height="274"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(2) select shearing axis No.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl0wt9ru40to6nce38u7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpl0wt9ru40to6nce38u7.png" alt="Image description" width="681" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(3) axis parameters initialization:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi47d0l50tts5lqoax9g1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi47d0l50tts5lqoax9g1.png" alt="Image description" width="770" height="651"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(4) shearing parameters initialization:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5l78tezw0jkz7ipwye6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5l78tezw0jkz7ipwye6.png" alt="Image description" width="599" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(5) shearing motion&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmn3jlxv510gloig21ob8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmn3jlxv510gloig21ob8.png" alt="Image description" width="597" height="718"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HMI interface: it can set shear processing parameters and control shearing motion. Also, it can show current axis position information at the same time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5orq8ycwj8ehu2e5n9r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe5orq8ycwj8ehu2e5n9r.png" alt="Image description" width="799" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The chasing shear waveform is as follows. The main axis is a conveyor belt moving at a constant speed. In the first stage, the slave axis (axis 1) follows the main axis (axis 2) from the initial position to accelerate. Then, the second stage, speeds of master axis and slave axis are the same, which means they achieve synchronization. Then, it is ready to return to the initial position after cutting downwards. In the third stage, the slave axis follows the main axis and decelerates to 0. In the fourth stage, the slave axis returns to the initial position in reverse to prepare for the next round of chasing shear.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjf2jor494z5w4r6vdse.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxjf2jor494z5w4r6vdse.png" alt="Image description" width="499" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's all, thank you for your reading -- Economical EtherCAT Motion Controller (3) --  &lt;a href="http://www.zmotionglobal.com/support_info_46.html" rel="noopener noreferrer"&gt;Multi-axis Linear Interpolation &amp;amp; Electronic Cam Achievement Through PLC.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is edited by ZMOTION, here, share with you, let's learn together. ZMOTION: DO THE BEST TO USE MOTION CONTROL.&lt;br&gt;
Note: Copyright belongs to ZMotion Technology, if there is reproduction, please indicate article source. Thank you.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>plc</category>
    </item>
  </channel>
</rss>
