Share this

Easy-to-use motion control card (Part 7): Loading multiple consecutive small line segment data at once

2026-04-06 05:59:16 · · #1

Today, Zheng Motion Assistant will share with you how to load multiple consecutive small line segment data at once when dealing with a large amount of small line segment data using the ECI3808 motion control card.

ECI3808 Hardware Introduction

1. Function Introduction

The ECI3808 series control cards support up to 12 axes of linear interpolation, arbitrary circular interpolation, spatial circular interpolation, helical interpolation, electronic cams, electronic gears, synchronous following, virtual axes, and robot commands; they also employ optimized network communication protocols to achieve real-time motion control.

The ECI3808 series motion control card supports Ethernet and RS232 communication interfaces to connect to a computer, receive commands from the computer, and can connect to various expansion modules via CAN bus to expand the number of input/output points or motion axes.

Applications for the ECI3808 series motion control card 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 ZDevelop software can be connected to the controller simultaneously for convenient debugging and observation.

2. Hardware Interface

General purpose input circuit

General purpose output port circuit

AD/DA Interface Description

Local Pulse Axis Description

3. Controller Basic Information

II. Motion Control Development using C++

1. Create a new MFC project and add function libraries.

(1) In the VS2015 menu, go to "File" → "New" → "Project" to start the Project Creation Wizard.

(2) Select “Visual C++” as the development language and “MFC Application” as the program type.

(3) Click Next.

(4) Select "Dialog-based" as the type, then click Next or Finish.

(5) Locate the CD-ROM data provided by the manufacturer. The path is as follows (64-bit library as an example).

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 as needed; 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.

(6) Copy the C++ library files and related header files provided by the vendor into the newly created project.

(7) Add static libraries and related header files to the project.

A. First, right-click the project file, then select: "Add" → "Existing Item".

B. In the pop-up window, add the static library and related header files in sequence.

(8) Declare the header files used and define the controller connection handle.

The project is now complete and ready for MFC project development.

2. Review the PC function manual and familiarize yourself with the relevant function interfaces.

(1) The PC function manual is also included in the CD-ROM materials. The specific path is as follows: "CD-ROM materials\8.PC functions\Function library 2.1\ZMotion function library programming manual V2.1.pdf"

(2) Link controller, obtain link handle.

ZAux_OpenEth() Interface Description:

(3) Implement the function by sending the basic command directly.

The ZAux_DirectCommand function directly issues commands to execute basic function blocks. The instructions run quickly, but instructions that require loading buffers may not execute successfully. It is recommended to use this function for instructions that can be executed successfully to improve efficiency.

The ZAux_Execute function directly issues commands to execute basic function blocks. The execution speed will be slower due to blocking, but all executable string commands can be executed successfully.

3. MFC development of controller hardware peripheral read/write routines.

(1) The routine interface is as follows.

(2) The routine interface consists of three parts.

A. The first part is the connection part, which is used to connect to the current controller and obtain the controller handle for subsequent operations.

B. The second part is the status detection section, which can display the current controller's axis coordinates, axis status, motion status, and remaining buffer size.

C. Thirdly, the parameter setting section is used to set the controller's motion parameters, acceleration, deceleration, and speed, etc.

(3) In the event handling function 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 status of the controller.

// Network port connection controller void CSingle_move_Dlg::OnOpen(){ char buffer[256]; int32 iresult; // If already connected, disconnect first if(NULL != g_handle) { ZAux_Close(g_handle); g_handle = NULL; } // Select and get the IP address from the IP drop-down box GetDlgItemText(IDC_IPLIST,buffer,255); buffer[255] = '\0'; // Start the connection controller iresult = ZAux_OpenEth(buffer, &g_handle); if(ERR_SUCCESS != iresult) { g_handle = NULL; MessageBox(_T("Connection failed")); SetWindowText("Not connected"); return; } // Start timer 1 if connection is successful SetWindowText("Connected"); SetTimer( 1, 100, NULL ); }

(4) Monitor the controller status through timers. Timer 1 reads the current status of each axis, and Timer 2 loads the current motion data and performs the corresponding motion. Each motion loads 1000 small line segment data.

void CTest_multiMoveDlg::OnTimer(UINT_PTR nIDEvent){ if(NULL == g_handle) { MessageBox(_T("Connection Disconnected")); return ; } uint32 iret = 0 ; if(1 == nIDEvent) { CString AxisPos; CString AxisStatus; CString AxisIdle; CString AxisBuffer; float showpos[4] ={0}; float showstatus[4] ={0}; float showidle[4] ={0}; int showbuff[4] ={0}; iret = ZAux_Direct_GetAllAxisPara( g_handle,"DPOS",4,showpos); //Get the current axis position iret = ZAux_Direct_GetAllAxisPara( g_handle,"AXISSTATUS",4,showstatus); //Get the current axis position iret = ZAux_Direct_GetAllAxisPara( g_handle,"IDLE",4,showidle); //Get the current axis position iret = ZAux_Direct_GetRemain_LineBuffer(g_handle,0,&showbuff[0]); iret = ZAux_Direct_GetRemain_LineBuffer(g_handle,1,&showbuff[1]); iret = ZAux_Direct_GetRemain_LineBuffer(g_handle,2,&showbuff[2]); iret = ZAux_Direct_GetRemain_LineBuffer(g_handle,3,&showbuff[3]); AxisPos.Format("Axis coordinates X: %.2f Y: %.2f Z: %.2f U: %.2f",showpos[0],showpos[1],showpos[2],showpos[3]); AxisStatus.Format("Axis status X: %.0f Y: %.0f Z: %.0f U: %.0f",showstatus[0],showstatus[1],showstatus[2],showstatus[3]); AxisIdle.Format("Motion status X: %s Y: %s Z: %s U: %s",showidle[0]?"Stop":"Moving",showidle[1]?"Stop":"Moving",showidle[2]?"Stop":"Moving",showidle[3]?"Stop":"Moving"); AxisBuffer.Format("Remaining line buffer X: %d Y: %d Z: %d U: %.d",showbuff[0],showbuff[1],showbuff[2],showbuff[3]); GetDlgItem( IDC_AXISPOS )->SetWindowText( AxisPos ); GetDlgItem( IDC_AXISSTATUS )->SetWindowText( AxisStatus ); GetDlgItem( IDC_AXISIDLE )->SetWindowText( AxisIdle ); GetDlgItem( IDC_REMAINBUFF )->SetWindowText( AxisBuffer ); } if(2 == nIDEvent) { int axislist[4] = {0,1,2,3}; // Motion BASE axis list int iresult = 0; int iLen = 10; // Single transmission length if (LEGS_MAX < g_curseges) // Exceeds the length range { iLen = g_curseges - LEGS_MAX; } iresult = ZAux_Direct_MultiMoveAbs(g_handle, iLen, 4, axislist, destdis[g_curseges]); //iresult = ZAux_Direct_MultiMove(g_handle,iLen, 4,axislist, destdis[g_curseges]); relative if (ERR_OK != iresult) { // Motion transmission failed, CString str; str.Format("%d", iresult); } else { g_curseges += iLen; if (g_curseges > LEGS_MAX) //Whether it is completed { KillTimer(2); return; } } } CDialog::OnTimer(nIDEvent); }

(5) Load multiple small line segments at once and move them after loading is complete.

/****************************************************************Description: //Multiple relative multi-axis linear interpolation Input: //Card link handle iMoveLen The length of motion imaxaxises Total number of axes involved in the motion piAxislist Axis number list pfDisancelist Distance list Output: //Return: //Error code *************************************************************/int32 __stdcall ZAux_Direct_MultiMoveAbs(ZMC_HANDLE handle,int iMoveLen, int imaxaxises, int *piAxislist, float *pfDisancelist){ int i,j; int32 iresult; char cmdbuff[2048]; char tempbuff[2048]; char cmdbuffAck[2048]; if(0 > imaxaxises || imaxaxises > MAX_AXIS_AUX) { return ERR_AUX_PARAERR; } // First read the remaining line buffer int iBuffLen = 0; iresult = ZAux_Direct_GetRemain_LineBuffer(handle,piAxislist[0],&iBuffLen); if(iBuffLen <= iMoveLen) { return 1002; // Insufficient buffer } // Generate command BASE command strcpy(cmdbuff, "BASE("); for(i = 0; i< imaxaxises-1; i++) { sprintf(tempbuff, "%d,",piAxislist[i]); strcat(cmdbuff, tempbuff); } sprintf(tempbuff, "%d)",piAxislist[imaxaxises-1]); strcat(cmdbuff, tempbuff); // Newline strcat(cmdbuff, "\n"); // Generate motion command for(j=0;j<imovelen;j++) if(ilen="" Get command length="" ilen="strlen(cmdbuff);" int="" }="" tempbuff);="" strcat(cmdbuff,="" j*imaxaxises]);="" +="" ?%f)\n?,pfdisancelist[i="" sprintf(tempbuff,="" +j*imaxaxises]);="" ?%f,?,pfdisancelist[i="" {="" i++)="" imaxaxises-1;="" i<="" i="0;">1000) { return 20002; } // Call the command execution function return ZAux_DirectCommand(handle, cmdbuff, cmdbuffAck, 2048);}

Note: As described in the code above, this function requires the number of small line segments and their corresponding data content. It uses the obtained data content to form multiple small line segment movement commands and sends them directly, without reprocessing each command to send the movement, in order to improve efficiency.

To prevent the speed of the host computer issuing commands from being insufficient, causing the execution speed to drop to 0 midway through the process, the system will check whether the number of characters sent exceeds the maximum number of characters that can be sent. If it does, the system will return the corresponding error code.

(6) Disconnect from the control card by using the event handler function of the disconnect button.

void CSingle_move_Dlg::OnClose() // Disconnect { // TODO: Add your control notification handler code here if(NULL != g_handle) { KillTimer(1); // Turn off the timer KillTimer(2); ZAux_Close(g_handle); g_handle = NULL; SetWindowText("Not connected"); }}

(7) Set parameters through the event handling function of the start button and start timer 2 to send motion commands.

void CTest_multiMoveDlg::OnStart() //Start { if(NULL == g_handle) { MessageBox(_T("Connection Disconnected")); return ; } UpdateData(true);//Refresh parameters int corner_mode = 0; int axislist[4] = {0,1,2,3}; //Motion BASE axis list//Select the axes involved in the motion, the first axis is the master axis, all interpolation parameters use the master axis parameters ZAux_Direct_SetUnits(g_handle, axislist[0], m_units); //Pulse equivalent ZAux_Direct_SetSpeed(g_handle,axislist[0],m_speed); //Speed ​​UNITS / S ZAux_Direct_SetAccel(g_handle,axislist[0],m_accel); //Acceleration ZAux_Direct_SetDecel(g_handle,axislist[0],m_decel); // Deceleration UpdateData(true); // Refresh parameters ZAux_Direct_SetMerge(g_handle,axislist[0],1); // Continuous interpolation switch ZAux_Direct_SetLspeed(g_handle,axislist[0],0); // Starting speed, corner deceleration is linearly decelerated from the starting speed ZAux_Direct_SetCornerMode(g_handle,axislist[0],0); // Corner mode 0-on ZAux_Direct_SetDecelAngle(g_handle,axislist[0],60*3.14/180); // Start deceleration angle, converted to radians ZAux_Direct_SetStopAngle(g_handle,axislist[0],120*3.14/180); ZAux_Direct_SetFullSpRadius(g_handle,axislist[0],5); ZAux_Direct_SetZsmooth(g_handle,axislist[0],5); // Call the motion to determine whether to launch the motion by checking if there is any remaining buffer g_curseges = 0; SetTimer(2, 50, NULL); // Create a new timer to launch the motion}

Full code download address

III. Debugging and Monitoring

Compile and run the routines, and simultaneously monitor the controller status by connecting to the controller through the ZDevelop software.

1. The axis parameters in ZDevelop software can be compared with those in the current demo, including axis coordinates and axis status.

2. Use the oscilloscope in ZDevelop software to capture multiple small line segment data, package them, and send out the motion trajectory and corresponding velocity curve.

A. Trajectory of the small line segment:

B. The planned speed of sending small line segments to the main spindle can always be maintained, and there will be no situation where the intermediate speed is 0 due to the insufficient sending speed of the host computer:

3. ZDevelop software debugging video.

This concludes our sharing of the seven-part series on easy-to-use motion control cards for positive motion technology: loading multiple continuous small line segment data at once.

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 136CM Tami (Customer Photos)

Height: 136cm Weight: 23.3kg Shoulder Width: 31cm Bust/Waist/Hip: 60/54/68cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22