Today, the motion control assistant will share with you how to download and run the ".bas" file of the ECI3808 motion control card.
I. 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) Download the “.bas” file to the controller to run the interface description.
(4) Interface description for pausing and resuming the controller's internal Basic program.
3. Downloading and running the ".bas" motion control file.
(1) The routine interface is as follows.
(2) Access it through "CD-ROM Data" --> "Tools & Software"
A. Open the software tool, click "File" --> "Import". Select the CAD drawing in DXF format that you want to convert and open it.
B. The result after opening is as follows.
C. Click "File" --> "Export" to export the ".bas" file. This file can then be downloaded to the control card for motion control of the above trajectory.
For detailed instructions on using D.CAD mapping software, please refer to the following website.
Link: https://t.1yb.co/EA7G
(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.
// Ethernet connection controller void CTest_BusInitDlg::OnOpenEth() { char buffer[256]; int32 iresult; if(NULL != g_handle) { ZAux_Close(g_handle); g_handle = NULL; } // Get IP address GetDlgItemText(IDC_IPLIST,buffer,255); buffer[255] = '\0'; // Connection controller iresult = ZAux_OpenEth(buffer, &g_handle); if(ERR_SUCCESS != iresult) { g_handle = NULL; MessageBox(_T("Connection failed")); SetWindowText("Not connected"); return; } SetWindowText("Connected"); // Start timer 1 SetTimer( 1, 100, NULL );}
(4) Monitor the axis status of the controller through timer 1.
void CTest_BusInitDlg::OnTimer(UINT_PTR nIDEvent) //Timer refresh { int32 ret = 0; CString tempstr; if(nIDEvent == 1 && g_handle !=0) { //Get axis parameters for axis 0 ZAux_Direct_GetAtype(g_handle, 0, &m_atype); ZAux_Direct_GetUnits(g_handle, 0, &m_units); ZAux_Direct_GetMspeed(g_handle, 0, &m_speed); ZAux_Direct_GetAccel(g_handle, 0, &m_accel); ZAux_Direct_GetDpos(g_handle,0,&m_dpos); ZAux_Direct_GetIfIdle(g_handle,0,&m_idle); //Get axis parameters for axis 1 ZAux_Direct_GetAtype(g_handle, 1, &m_Atype1); ZAux_Direct_GetUnits(g_handle, 1, &m_untis1); ZAux_Direct_GetMspeed(g_handle, 1, &m_speed1); ZAux_Direct_GetAccel(g_handle, 1, &m_accel1); ZAux_Direct_GetDpos(g_handle, 1, &m_dpos1); ZAux_Direct_GetIfIdle(g_handle, 1, &m_idle1); UpdateData(false); } CDialog::OnTimer(nIDEvent);}
(5) Download the .bas file to the controller ROM via the event handler function of the file download button. (Note: The ".bas" file can also be downloaded using our ZDevelop software.)
// Download BAS file to controller ROM void CTest_BusInitDlg::OnDownload() { int32 ret; CString m_strOpenFileName; CFile openfile; if(NULL == g_handle) { MessageBox(_T("Controller not connected")); return; } CFileDialog fileopen(true, ".bas", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Basic Files (*.bas)|*.bas|All Files (*.*)|*.*||", NULL); if (fileopen.DoModal() == IDOK) { // Get the filename and path of the opened file m_strOpenFileName = fileopen.GetPathName(); if (!openfile.Open(fileopen.GetPathName(), openfile.modeRead | openfile.modeNoInherit, NULL)) { this->MessageBox("Open Failed!"); return; } GetDlgItem(IDC_FILENAME)->SetWindowText(m_strOpenFileName); openfile.Close(); // Download BAS program to ROM ret = ZAux_BasDown(g_handle, m_strOpenFileName, 1); if (ret != 0) { this->MessageBox("DownLoad File Failed!"); return; } // String splitting to get filename char* pchar = (LPSTR)(LPCSTR)m_strOpenFileName; CString strTmp = strtok(pchar, "\\"); while(1) { strTmp=strtok(NULL,"\\"); if (strTmp==_T("")) break; strcpy(&FileName, (LPSTR)(LPCSTR)strTmp); } }}
(6) Implement the controller through the event handling functions of the start, stop, pause and continue buttons.
// Run the ZBasic file in the controller void CTest_BusInitDlg::OnBnClickedRun(){ int ret = 0; char Temp[100] = "Run \""; // Create the command string "Run "file2.bas", 0 " strcat(Temp, &FileName); strcat(Temp, "\", 0"); // Stop task 0 ZAux_Execute(g_handle, "STOPTASK 0", NULL, 0); // Start task 0 ZAux_Execute(g_handle, Temp, NULL, 0);}
//Stop the controller running ZBasic tasks void CTest_BusInitDlg::OnBnClickedStop(){ //Stop task 0 ZAux_Execute(g_handle, "STOPTASK 0", NULL, 0); //Stop all axis motions ZAux_Execute(g_handle, "RAPIDSTOP(2)", NULL, 0);}
// Pause void CTest_BusInitDlg::OnBnClickedpause(){ // Pause the BASIC program running inside the controller ZAux_Pause(g_handle); // Pause the spindle motion ZAux_Direct_MovePause(g_handle, 0, 0);}
// Continue running void CTest_BusInitDlg::OnBnClickedResume(){ // Continue running the BASIC program running inside the controller ZAux_Resume(g_handle); // Continue spindle motion ZAux_Direct_MoveResume(g_handle, 0);}
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. By connecting the ZDevelop software to the controller and opening debug mode, you can view the filenames of the ".bas" files inside the controller.
2. Use the oscilloscope function of ZDevelop software to capture the waveform of continuous small line segments. Below is a comparison between the oscilloscope waveform and the CAD drawing.
A. The ECI3808 is running as follows: (The ECI3808's ROM is only 4KB, so the downloaded Basic file cannot exceed 4KB)
B. The ZMC308B controller operates as follows: (The ECI3808's ROM is only 4KB, so the downloaded Basic file cannot exceed 4KB. Therefore, the following trajectory requires the ZMC308B controller to run.)
Figure 1
Figure 2
3. ZDevelop software debugging video.
This concludes our sharing of the six parts of our series on easy-to-use motion control cards for positive motion technology: Basic file download and continuous trajectory processing.
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.