Share this

Motion control card application development tutorial using VC6.0

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

Today, we will explain the application development tutorial for the positive motion technology motion control card using VC6.0.

Before we begin our formal learning, let's first understand the motion control cards ECI2418 and ECI2618 from Zheng Motion Technology. These two products are 4-axis and 6-axis motion control cards, respectively.

The ECI2418 supports 4-axis pulse input and encoder feedback, with 24 onboard inputs, 16 onboard outputs, 2 AD, 2 DA, and a handwheel interface. Some outputs support high-speed PWM control.

The ECI2618 supports 6-axis pulse input and encoder feedback, with 24 onboard inputs, 16 onboard outputs, 2 AD converters, 2 DA converters, and a handwheel interface. Some outputs support high-speed PWM control.

Both ECI2418 and ECI2618 use the same set of API functions and support development languages ​​such as C, C++, C#, LabVIEW, Python, and Delphi. They also support platforms such as VC6.0, VB6.0, Qt, and .Net, and operating systems such as Windows, Linux, WinCE, and iMac.

I. Motion Control Card VC6.0 Development Process

1. Open VC++ 6.0 and create a new project.

2. Select " MFC APPWizard(exe) ", choose the project save path , set the project name , and select OK .

3. In the Application Type dialog box, select Basic to complete the project creation.

4. Copy the dynamic link libraries " zmotion.dll" and "zauxdll.dll ", the header file " zauxdll2.h ", and the lib file " zauxdll.lib " from the " ..\function library\dll " folder on the product's accompanying CD to the project folder.

5. Select the "Settings…" menu item under the "Project" menu.

6. Switch to the “Link” tab, and enter the lib file name: zauxdll.lib in the “Object\library modules” field.

7. Add the declaration of the function library header file to the application file, such as: #include "zauxdll2.h",

8. At this point, users can call any function in the function library in VC6.0 and start writing applications. For specific usage instructions, please refer to the ZMotion PC Function Library Programming Manual in the CD-ROM .

9. Refer to the function description of the link controller in the ZMotion PC function library programming manual, and add the link controller code ZAux_OpenEth(“192.168.0.11”,&g_handle) ; to the ECIDlg:OnInitDialog() function to link the controller.

10. Use the MOVE button to control the controller to perform interpolation motion.

(1) Right-click the MOVE button, select Properties, and set the button ID.

(2) Right-click the MOVE button and select the event.

(3) Create new related events.

4) Add an interpolation motion function to the event handler function.

11. After compiling and running, you can control the controller via PC.

If the compilation results in the error: "Cannot open precompiled header file: No such file or directory exists."

Please select the "Settings…" menu item under the "Project" menu, and then select C/C++ to make the following settings.

II. VC6.0 Example Program Explanation

1. Our CD-ROM contains many VC6.0 example programs, which can make it easier to get started with our controller.

2. Single-axis motion routines

a. A controller connected to a specified IP address via Ethernet;

b. Set the motion axis parameters;

c. Select the motion axis object;

d. Select the movement mode to achieve continuous movement and inching motion;

3. Implementation steps

(1) Search for IP address and link controller.

A. First, drag the relevant controls onto the UI interface and set the corresponding event handling functions.

B. Drop-down list event handler function to enable automatic IP search.

First, according to the ZMotion PC programming manual, add the controller IP search function "ZAux_SearchEthlist()" to the dropdown event handler function. Then, parse the obtained IP string. Please refer to the example for specific parsing methods.

 //自动搜索IP void CECIDlg::OnDropdownIPList() { /*自动搜索IP地址*/ char buffer[10240]; int32 iresult; /*搜索当前网段下的IP 地址详情请参考:zmotion pc 编程手册*/ iresult = ZAux_SearchEthlist(buffer, 10230, 100); if(ERR_OK != iresult) { return; } CComboBox *m_pEthList; m_pEthList = (CComboBox *)GetDlgItem(IDC_IPList); if(NULL == m_pEthList) { return; } /*从字符串转换成IP*/ int ipos =0; const char * pstring; pstring = buffer; 
for(int j= 0; j< 20;j++) { char buffer2[256]; buffer2[0] = '\0';
/*跳过空格*/ while(' ' == pstring[0]) { pstring++; }
ipos = sscanf(pstring , "%s", &buffer2); if(EOF == ipos) { break; } /*跳过字符*/ while((' ' != pstring[0]) && ('\t' != pstring[0]) && ('\0' != pstring[0])) { pstring++; } if(CB_ERR != m_pEthList->FindString(0, buffer2)) { continue; } if('\0' == buffer2) { return; } /*加入*/ m_pEthList->AddString(buffer2); } return; }

C. Click the link button to link the controller.

According to the ZMotion PC programming manual, you can achieve the function of connecting to the controller by adding the network port connection controller function "ZAux_OpenEth()" to the event handler function of the link button.

D. Click the disconnect button to disconnect the controller.

According to the ZMotion PC programming manual, you can achieve the function of disconnecting the controller by adding the disconnect button click event handler function "ZAux_Close()".

(2) Select the axis and monitor the selected dpos, current speed, and motion status.

A. First, drag the relevant controls onto the UI interface and set the corresponding event handling functions.

B. The axis selection is achieved through the event handling functions of the four radio buttons X, Y, Z, and R.

C. Real-time updates of axis status are achieved through a timer.

(3) Implement reading of in0-in7 and out0-out7 states.

The I/O state is retrieved using the interfaces ZAux_GetModbusIn() and ZAux_GetModbusOut(). This is then encapsulated into a sub-function and added to the timer timeout handler for updating the I/O state.

//IO monitoring

void CECIDlg::IOGet()

{

uint8 in, out, i=0,j=0,k=0;

char buff[128]={0};

/* Get input port status */

ZAux_GetModbusIn (g_handle, 0, 7, &in); // Get the states in0-in7

/* Decimal to binary conversion */

itoa(in, buff, 2);

j=0;

for( i=0; i<8; i++)

{

if((48 == buff[i])||(49 == buff[i]))

{

j++;

}

}

for(i=0 ; i<(8-j); i++)

{

for(k=7; k>0; k--)

{

buff[k] = buff[k-1];

}

buff[0]=48;

}

sprintf(buff, "Input port IN0-7 status:%c %c %c %c %c %c %c %c", buff[7], buff[6],buff[5],buff[4],buff[3],buff[2],buff[1],buff[0]);

GetDlgItem( IDC_IN )->SetWindowText( buff );

/* Get output port status */

ZAux_GetModbusOut(g_handle, 0, 7, &out); // Get the status of out0-out7

/* Decimal to binary conversion */

itoa(out, buff, 2);

j=0;

for( i=0; i<8; i++)

{

if((48 == buff[i])||(49 == buff[i]))

{

j++;

}

}

for(i=0 ; i<(8-j); i++)

{

for(k=7; k>0; k--)

{

buff[k] = buff[k-1];

}

buff[0]=48;

}

sprintf(buff, "Output port OUT0-7 status:%c %c %c %c %c %c %c %c",buff[7], buff[6],buff[5],buff[4],buff[3],buff[2],buff[1],buff[0]);

GetDlgItem( IDC_OUT )->SetWindowText( buff );

}

(4) Set the controller parameters.

A. First, drag the relevant controls onto the UI interface and set the event handler function for the parameter activation button.

B. To set member variables for each edit box, first right-click the edit box and select "Create Class Guide," then select "Member Variables" to set them.

C. Then, add the relevant function interface for parameter setting in the event handler function of the parameter activation button to set the controller parameters.

(5) Control the movement of the controller.

A. Add two more radio buttons, a distance editing box, and two buttons to the UI interface.

B. Two sets of radio buttons are used to set the direction and mode of motion. Their event handlers are used to set the flag variables m_moveatype and m_movedir.

C. Start the controller to move by using the event handler function of the start button.

D. Stop the controller's movement by using the event handler function of the stop button.

(6) Compile and run the demonstration.

A. Compile and run the teaching examples

B. Simultaneously, connect to the same controller via ZDevelop software to observe the motion control effect.

The following is a display of the axis parameters, IN/OP, and DPOS MSPEED on the oscilloscope.

Today, we've shared our tutorial on motion control card application development using VC6.0. For more great content, please follow our official WeChat account. This article was originally written by Zheng Motion Assistant; we welcome everyone to share it for mutual learning and to improve China's intelligent manufacturing capabilities. Copyright belongs to Zheng Motion Technology; please indicate the source if you reprint it.


Read next

CATDOLL Laura Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22
CATDOLL Ava Hard Silicone Head

CATDOLL Ava Hard Silicone Head

Articles
2026-02-22
CATDOLL 42CM TPE Baby Doll

CATDOLL 42CM TPE Baby Doll

Articles
2026-02-22