Share this

Periodic reporting of network communication between C# host computer and motion control card

2026-04-06 01:37:25 · · #1

Today, Zheng Sports Assistant will share with you the periodic reporting of the motion control card. By pre-setting frequently read parameters for proactive periodic reporting, the time spent on PC active polling can be reduced.

This article takes the ECI2A18B motion control card as an example and mainly explains how to use the C# programming language to write periodic reporting functions and develop related features.

ECI2A18B Motion Control Card Introduction

The ECI2A18B is a 10-axis pulse-type, modular network motion control card. Utilizing an optimized network communication protocol, it enables real-time motion control and supports multiple communication protocols, facilitating connection and integration with other industrial control equipment. Installation and configuration are relatively convenient, making it suitable for control systems requiring high modularity and flexibility.

The ECI2A18B motion control card can be expanded to a maximum of 12 pulse axes, supports 8 high-speed inputs and 12 high-speed outputs, and integrates a wealth of motion control functions, including multi-axis point-to-point motion, electronic cams, linear interpolation, circular interpolation, continuous interpolation motion, etc., to meet diverse industrial application needs.

Zhengdong provides its self-developed IDE-RTSys programming software. The ECI2A18B control card supports multiple host computer languages ​​for development, all of which can call the same set of API function libraries, making it easy to integrate with existing industrial control systems. This greatly improves the efficiency of engineers in secondary development and accelerates the deployment and application of equipment.

01-cycle reporting

1. First, understand the potential problems that may arise when the PC actively polls too many times:

(1) Increased system overhead: Polling consumes system resources, whether it is task polling or timer polling. This may lead to a decrease in system performance, especially in multi-user or resource-constrained environments.

(2) Waste of CPU resources: Polling is always in progress regardless of whether the device state changes. In reality, most devices do not change state so frequently, and polling will waste CPU time slices.

(3) Impact on power management: The more times peripheral devices are reported to the PC, the more power is consumed, which may shorten battery life or increase energy consumption.

(4) Reduced response speed: If the polling frequency is too high, it may cause the system to respond to other tasks more slowly, because the CPU needs to frequently check the device status instead of processing other computing or user interaction tasks.

(5) Increased network load: If polling involves network communication, too many polling requests may increase network load, leading to network congestion or increased latency.

(6) Increased server pressure: In a client-server architecture, frequent polling requests may put pressure on the server, especially when server resources are limited, which may lead to a decrease in service quality or request timeout.

2. Having understood that the PC's active polling frequency is too high, let's further examine the differences in the program's runtime usage across various data acquisition methods:

When discussing the impact of single fetch, multiple fetch, and periodic fetch on program execution, we need to consider the characteristics of these operations and their potential impact on the overall program performance.

(1) Single retrieval

Single-item retrieval typically refers to processing only one data item at a time in a program. This approach is simple and straightforward, but it can be inefficient when processing large amounts of data because each operation involves context switching and resource management overhead. In this case, the program's runtime is primarily focused on processing the data itself, rather than additional control logic.

(2) Multiple Acquisitions

Multiple fetching involves processing multiple data items simultaneously. In modern computer systems, this is typically achieved through multithreading or concurrency techniques, which can significantly improve data processing throughput. However, the benefits of multithreading can be offset by issues such as lock contention, memory contention, and context switching. Therefore, while multiple fetching may reduce the relative runtime of processing a single data item, the overall runtime reduction depends on the effectiveness of multithreading optimizations.

(3) Periodic acquisition

Periodic fetching refers to repeatedly performing data fetching operations at regular time intervals. This approach is common in applications that require periodic updates to data status, such as real-time monitoring systems or scheduled tasks. The percentage of runtime allocated to periodic fetching depends on the periodicity of the task and the actual workload performed within each period. If the load on periodic tasks is light, they may not significantly impact the overall runtime of the program.

3. Application scenarios:

In practical applications, the choice of data acquisition strategy depends on the specific application scenario, data characteristics, and performance requirements. For example, if the program needs to respond quickly to a single event, single-data acquisition may be more suitable. If the goal is to maximize data processing speed, multiple data acquisitions may be more beneficial. For applications that need to regularly maintain data freshness, periodic acquisition is necessary.

02. Periodic reporting using C# language

1. In VS2010, go to "File" → "New" → "Project" to start the Project Creation Wizard.

2. Select "Visual C#" as the development language and .NET Framework 4 as the Windows Forms application.

3. Locate the C# function library in the CD-ROM provided by the manufacturer. The path is as follows (taking the 32-bit library as an example).

1) Go to the CD-ROM provided by the manufacturer, find the "04PC Functions" folder, and click to enter.

2) Select the "01PC Function Library V2.1" folder.

3) Select the "Windows Platform" folder.

4) Select the "C#" folder.

5) Select the corresponding function library as needed; here, we choose the 32-bit library.

4. Copy the C# library files and related files provided by the vendor into the newly created project.

1) Copy the zmcaux.cs file into the newly created project.

2) Place the zauxdll.dll and zmotion.dll files into the bin\debug folder.

5. Double-click Form1 in Form1.cs to open the code editing interface. At the beginning of the file, write "using cszmcaux" and declare the controller handle g_handle.

6. At this point, the project is complete and ready for C# project development.

03 Introduction to PC Function

The PC function manual can be obtained from the CD-ROM. The specific path is as follows: "00CD-ROM\03Programming Manual\03ZMotion PC Function Library Programming Manual".

1. Connect to the controller and obtain the connection handle.

2. The controller automatically reports relevant instructions.

3. Note the usage of the periodic reporting instruction.

04 C# Network Communication Periodic Reporting

1. The host computer software interface is shown below. First, connect to the controller, set the periodic reporting parameters and the parameters to be reported, and finally check the "Start Forced Reporting" option.

2. Example explanation.

(1) Connect to the controller to obtain a handle. The host computer operates the controller by obtaining the handle.

// Connect to the controller, the default IP of the controller is 192.168.0.11 ZauxErr = zmcaux.ZAux_OpenEth("192.168.0.11", out g_Handle); if (0 != ZauxErr){ AlmInifFile.Write(DateTime.Now.ToString("F"), "ZAux_OpenEth execution error, error code:" + ZauxErr.ToString(), "error code information");}

(2) Start reporting. When the status of the checkbox changes during the start of periodic reporting, the CheckChange function is notified. First, it is determined whether the checkbox is unchecked or checked. If it is checked, ZAux_CycleUpEnable enables periodic reporting and starts a timer to periodically report data packets for reading and refreshing.

private void checkBox1_CheckedChanged(object sender, EventArgs e){ // Get the reported parameters StringBuilder psetesname = GetCycleStr(); // Check to start reporting if (!StartUp && checkBox1.Checked == true) { try { // Enable periodic reporting controlReturn = zmcaux.ZAux_CycleUpEnable(g_handle, Convert.ToUInt32(textBox1.Text), Convert.ToSingle(textBox2.Text), psetesname.ToString()); } catch (FormatException fe) { checkBox1.Checked = false; MessageBox.Show(string.Format("{0}: {1}", fe.GetType().Name, fe.Message)); return; } if (controlReturn != 0) { checkBox1.Checked = false; return; } textBox9.Text = "0"; AppendTextOut(string.Format("Periodic reporting started\r\n Command: {0}\r\n", psetesname.ToString())); start = DateTime.Now; // timer1.Enabled = true; StartUp = true; }else if(StartUp && checkBox1.Checked == false){ //Uncheck periodic reporting controlReturn = zmcaux.ZAux_CycleUpDisable(g_handle, Convert.ToUInt32(textBox1.Text)); DateTime end = DateTime.Now; if (controlReturn != 0) { AppendTextOut(string.Format("Periodic reporting failed to close error code: {0:D} \r\n",controlReturn)); return; } timer1.Enabled = false; StartUp = false; TimeSpan abs = end - start; AppendTextOut(string.Format("{0:N3}ms, {2:N3} \r\n", abs.TotalMilliseconds, Convert.ToDouble(textBox9.Text), abs.TotalMilliseconds / Convert.ToDouble(textBox9.Text))); }}//Read the reporting parameters private void timer1_Tick(object sender, EventArgs e){ int received; try { //Get the number of data packets received in the periodic report received = zmcaux.ZAux_CycleUpGetRecvTimes(g_handle,Convert.ToUInt32(textBox1.Text)); } catch (FormatException fe) { timer1.Enabled = false; MessageBox.Show(string.Format("{0}: {1}", fe.GetType().Name, fe.Message)); return; } if (received != Convert.ToUInt32(textBox9.Text)) { //Print when a new data packet is received//Print function GetCycleInfo(); textBox9.Text = string.Format("{0:D}", received); }}

(3) Print data. Read the periodic reported data through ZAux_CycleUpReadBuffInt, parse it, and then display it through AppendTextOut.

// Print the received data packet private void GetCycleInfo() { StringBuilder showString = new StringBuilder(); int ival = 0; for (int num = 0; num < 3; num++) { if (checkbox[num].Checked){ showString.Append(combobox[num].SelectedItem.ToString()); for (uint i = (uint)data[num].CycleParaStart; i < data[num].CycleParaNum; i++) { // Read the content from the periodic report controlReturn = zmcaux.ZAux_CycleUpReadBuffInt(g_handle, Convert.ToUInt32(textBox1.Text), combobox[num].SelectedItem.ToString(),i, ref ival); showString.AppendFormat(" {0:D}",ival); } showString.Append("\n"); } } AppendTextOut(showString.ToString());}

05. Using RTSys

1. Open the 【RTSys】 software, click 【Connect】 and enter the controller's IP address (default IP: 192.168.0.11).

2. The positive motion RTSys software allows for convenient and intuitive observation of the periodic reporting parameter values.

3. The host computer reads the value reported periodically and outputs it in the text box.

4. Click the drop-down menu to select other parameters or change the starting address and quantity to read data from different regions.

Full code download address

That concludes our sharing of the periodic reporting of network communication between the C# host computer and the motion control card in ZhengMotion Technology.

For more exciting content, please follow the "Zheng Motion Assistant" WeChat official account. For related development environment and example code, please contact Zheng Motion's technical sales engineer: 400-089-8936.

This article is original content from Zheng Motion Technology. We welcome everyone to reprint it for mutual learning and to jointly improve China's intelligent manufacturing level. Copyright belongs to Zheng Motion Technology. Please indicate the source if you reprint this article.

Read next

CATDOLL 138CM Airi(TPE Body with Hard Silicone Head)

Height: 138cm Weight: 26kg Shoulder Width: 30cm Bust/Waist/Hip: 65/61/76cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22