Today, the motion control assistant will share the usage of the ECI 0 series IO board and test the read/write speed of multiple IOs. The input/output usage and read/write speeds of other ECI series IO boards are similar, and can be used for reference.
I. Hardware Introduction of ECI0032/ECI0064 IO Cards
ECI0032/ECI0064 and other ECI 0 series motion control cards support Ethernet and RS232 communication interfaces to connect to a computer, receive computer commands to run, support ZCAN expansion, and can be expanded to 128 AD, 64 DA; 272 inputs and 272 outputs.
ECI0032 IO Control Card
ECI0064 IO Control Card
The ECI 0 series motion control cards, such as ECI0032/ECI0064, employ optimized network communication protocols to achieve real-time logic control and I/O status monitoring. Applications for the ECI 0 series I/O cards, such as ECI0032/ECI0064, can be developed using software such as VC, VB, VS, C++, and C#. The program requires the dynamic library zmotion.dll to run. During debugging, the RTSys software can be connected to the controller simultaneously for convenient debugging and observation.
ECI0032 Typical Connection Configuration Diagram:
ECI0064 Typical Connection Configuration Diagram:
II. Introduction to I/O Interfaces
1. I/O power supply precautions
Unlike other control cards, the ECI0032/ECI0064 requires two power supplies to operate normally (internal power supply and I/O power supply). It is important to note that it is recommended to use two independent 24V power supplies for the internal power supply and the I/O power supply to prevent interference from the I/O circuitry from being directly transmitted to the internal circuitry of the control card and affecting its normal operation.
2. Introduction to Input Port Functions
General input port wiring diagram reference
Hardware specifications of general purpose input port
Based on the hardware parameters, we found that the input method of the general-purpose input port is NPN sinking signal. Therefore, when selecting IO sensors, you should pay attention to choosing NPN type sensors. The input of ZMC series and other ECI series products is similar; please refer to the hardware manual of the corresponding product for details.
How can I verify if the hardware functions of the control card's input port are working properly?
Based on the equivalent circuit diagram of the input port above, the input port can capture signals when it is connected to EGND. We can prepare a wire, connecting one end to the ground (EGND) of the IO power supply, and repeatedly touching the other end to the corresponding input port terminal. Simultaneously, after connecting the control card to the RTSys/ZDevelop software and opening the input port monitoring interface, observe whether the status of the corresponding input port changes according to the touching. If the corresponding input port is connected to EGND, the corresponding input port status will display a green light; if the input port is not connected to EGND, the corresponding input port status will display a red light. This indicates that the input port hardware is functioning correctly.
RTSys input port monitoring interface
Input port view with input port 0 (IN0) and EGND connected.
Input port view where input port 0 (IN0) and EGND are not connected.
3. Output Port Function Introduction
General output port wiring diagram reference
Hardware specifications of general purpose output ports
Based on the hardware parameters, we found that the general-purpose output port uses an NPN sinking signal, so the output is a 0V signal, which is connected to EGND. The output of ZMC series and other ECI series products is similar; please refer to the hardware manual of the corresponding product for details.
How can I verify if the control card's output port hardware is functioning correctly?
Based on the equivalent circuit diagram of the output port above: when the output port is outputting, the OUT port is connected to EGND. Although the voltage at the output port is 0V when outputting, when there is no output, the output port is in a high-impedance state. Therefore, it is not recommended to use the voltage range of a multimeter to verify the function of the output port. Instead, use the continuity range of the multimeter to test whether the output port is functioning properly. (When the multimeter is set to the continuity range, if there is continuity between the red and black probes, the multimeter will emit a beeping sound. Different multimeters have different beeps; you can short-circuit the red and black probes after setting the multimeter to the continuity range and listen to the sound to see what your multimeter sounds like.)
Multimeter continuity settings diagram
In this way, we can open the RTSys/ZDevelop software, connect to the controller, and open the output port monitoring interface. In the output port monitoring interface, operate the corresponding output port switch. Simultaneously, set the multimeter to continuity mode, then touch the red probe of the multimeter to the corresponding output port terminal, and the black probe to the IO power ground (EGND). Observe whether the multimeter is conducting when the RTSys software opens the output port (makes a beeping sound), and whether it is de-conducting when the output port is closed (makes a beeping sound). If so, the output port hardware is normal.
RTSys output port monitoring interface
Multimeter continuity test when output port 0 (OP0) is not outputting
Multimeter continuity test results when output port 0 (OP0) is running.
4. Controller Basic Information
III. Development of ECIO Boards using C#
1. In VS2015, 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 (for example, the 64-bit library).
A. Locate the "8.PC Functions" folder in the CD-ROM provided by the manufacturer and click to enter.
B. Select the "Function Library 2.1" folder.
C. Select the "Windows Platform" folder.
D. Select the appropriate function library according to your needs. Here, we choose the 64-bit library.
E. Unzip the C# compressed file, which contains the corresponding C# function library.
F. The specific path to the function library is as follows.
4. Copy the C# library files and related files provided by the vendor into the newly created project.
A. Copy the zmcaux.cs file into the newly created project.
B. Place the zaux.dll and zmotion.dll files into the bin\debug folder.
5. Open the newly created project file in Visual Studio. In the Solution Explorer on the right, click "Show All". Then, right-click the zmcaux.cs file and click "Include in Project".
6. 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.
7. The project is now complete and ready for C# development.
IV. Introduction to PC Functions
1. The PC function manual is also included in the CD-ROM materials; the specific path is as follows.
2. Connect to the controller and obtain the connection handle.
3. Quickly read the current status and interface description of multiple input ports.
4. Quickly read the current status and interface description of multiple output ports.
V. C# Test Routine for Quickly Reading Multiple I/O States
1. The example interface is as follows:
2. In the event handler of the link button, the interface function ZAux_OpenEth() of the link controller is called to link with the controller. After the link is successfully linked, timer 1 is started to monitor the I/O status of the controller.
·
// Link controller private void LinkButton_Click(object sender, EventArgs e){ zmcaux.ZAux_OpenEth(IP_comboBox.Text, out g_handle); if (g_handle != (IntPtr)0) { // MessageBox.Show("Controller connection successful!", "Prompt"); timer1.Enabled = true; LinkButton.BackColor = Color.FromArgb(200, 255, 200); } else { MessageBox.Show("Controller connection failed, please check IP address!", "Warning"); LinkButton.BackColor = Color.FromArgb(255, 200, 200); }}
3. Monitor the controller's I/O status using Timer 1.
·
//Timer updates IO information private void timer1_Tick(object sender, EventArgs e){ int j, k; int TestNum = 50; //Quickly read input port status interface time test byte[] InState = new byte[4]; DateTime beforeDT = System.DateTime.Now; for (int count = 0; count < TestNum; count++) { zmcaux.ZAux_GetModbusIn(g_handle, 0, 32, InState); for (int i = 0; i < 32; i++) { j = i / 8; k = i % 8; if (((InState[j] >> k) & 1) == 1) { InStatus[i].BackColor = Color.FromArgb(200, 255, 200); } else { InStatus[i].BackColor = Color.FromArgb(255, 200, 200); } } } DateTime afterDT = System.DateTime.Now; // Calculate the time difference between beforeDT and afterDT TimeSpan ts = afterDT - beforeDT; InMoitoring.Text = "Input port monitoring_refresh time: " + (ts.TotalMilliseconds * 1000 / TestNum).ToString() + " us "; // Quickly read the output port status interface time test byte[] OutState = new byte[4]; DateTime beforeDTOP = System.DateTime.Now; for (int count = 0; count < TestNum; count++) { zmcaux.ZAux_GetModbusOut(g_handle, 0, 32, OutState); for (int i = 0; i < 32; i++) { j = i / 8; k = i % 8; if (((OutState[j] >> k) & 1) == 1) { OutStatus[i].BackColor = Color.FromArgb(200, 255, 200); } else { OutStatus[i].BackColor = Color.FromArgb(255, 200, 200); } } } DateTime afterDTOP = System.DateTime.Now; // Calculate the time difference between beforeDTOP and afterDTOP ts = afterDTOP - beforeDTOP; OutMoitoring.Text = "Output port monitoring_refresh time: " + (ts.TotalMilliseconds * 1000 / TestNum).ToString() + " us ";}
4. The function for testing the speed of reading the status of multiple input ports is as follows.
·
//Multiple input port status reading interaction speed test private void ReadInTest_Click(object sender, EventArgs e){ int j, k; int testNum = Convert.ToInt32(TestNum.Text.ToString()); int readInNum = Convert.ToInt32(ReadInNum.Text.ToString()); //Quickly read input port status interface time test byte[] InState = new byte[4]; DateTime beforeDT = System.DateTime.Now; for (int count = 0; count < testNum; count++) { zmcaux.ZAux_GetModbusIn(g_handle, 0, readInNum, InState); if (count % 100 == 0) { for (int i = 0; i < 32; i++) { j = i / 8; k = i % 8; if (((InState[j] >> k) & 1) == 1) { InStatus[i].BackColor = Color.FromArgb(200, 255, 200); } else { InStatus[i].BackColor = Color.FromArgb(255, 200, 200); } } } } DateTime afterDT = System.DateTime.Now; // Calculate the time difference between beforeDT and afterDT TimeSpan ts = afterDT - beforeDT; // Total time elapsed in milliseconds ReadInTime.Text = ts.TotalMilliseconds.ToString("0.00"); // Average time elapsed in milliseconds ReadInTime.Text = (ts.TotalMilliseconds * 1000 / testNum).ToString("0.00");}
5. The function for testing the speed of reading the status of multiple output ports is as follows.
·
//Multiple output port status reading interaction speed test private void ReadOutTest_Click(object sender, EventArgs e){ int j, k; int testNum = Convert.ToInt32(TestNum.Text.ToString()); int readOutNum = Convert.ToInt32(ReadOutNum.Text.ToString()); //Quickly read input port status interface time test byte[] OutState = new byte[4]; DateTime beforeDT = System.DateTime.Now; for (int count = 0; count < testNum; count++) { zmcaux.ZAux_GetModbusOut(g_handle, 0, readOutNum, OutState); if (count % 100 == 0) { for (int i = 0; i < 32; i++) { j = i / 8; k = i % 8; if (((OutState[j] >> k) & 1) == 1) { OutStatus[i].BackColor = Color.FromArgb(200, 255, 200); } else { OutStatus[i].BackColor = Color.FromArgb(255, 200, 200); } } } } DateTime afterDT = System.DateTime.Now; // Calculate the time difference between beforeDT and afterDT TimeSpan ts = afterDT - beforeDT; // Total time elapsed in milliseconds ReadOutTime.Text = ts.TotalMilliseconds.ToString("0.00"); // Average time elapsed in milliseconds ReadOutTime.Text = (ts.TotalMilliseconds * 1000 / testNum).ToString("0.00");}
6. The speed test function for setting the status of multiple output ports is as follows.
·
//Multiple output port status settings interaction speed test private void WriteOutTest_Click(object sender, EventArgs e){ int testNum = Convert.ToInt32(TestNum.Text.ToString()); int writeOutNum = Convert.ToInt32(WriteOutNum.Text.ToString()); //Quickly read input port status interface time test byte[] OutState = new byte[4]; DateTime beforeDT = System.DateTime.Now; for (int count = 0; count < testNum; count++) { zmcaux.ZAux_GetModbusOut(g_handle, 0, writeOutNum, OutState); } DateTime afterDT = System.DateTime.Now; //Calculate the time difference between beforeDT and afterDT TimeSpan ts = afterDT - beforeDT; //Total time ms WriteOutTolTime.Text = ts.TotalMilliseconds.ToString("0.00"); //Average time us WriteOutTime.Text = (ts.TotalMilliseconds * 1000 / testNum).ToString("0.00");}
7. The test results of the interaction speed between multiple IO states and the host computer are as follows.
(1) Test results of interaction speed after 1000 read/write operations on 32 input/output ports:
(2) Interaction speed test results after 10,000 read/write operations on 32 input/output ports:
(3) Test results of 100,000 read/write operations on 32 input/output ports, interaction speed:
VI. Analysis and Conclusion
The above tests measured the read speed of 32 input ports, the read speed of 32 output ports, and the write speed of 32 output ports. The data in the above graphs shows that the interaction speed of both input and output ports remained around 200µs, and the performance was very stable. Even when the number of tests increased from 1000 to 10,000, and even 100,000, the average interaction speed per test remained around 200µs.
Full code download address
▼
That concludes our presentation on the C# real-time read/write time test of the Positive Motion Technology Ethernet I/O Control Card.
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.