Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

ZMotion Application Development Tutorial -- Motion Control Card & VC6.0

  "  Teach support again ! "
  --Today, ZMotion Technology shares application development of motion control card in VC6.0--


This article is edited by ZMOTION, here, share with you, let's learn together. ZMOTION: DO THE BEST TO USE MOTION CONTROL.

Note: Copyright belongs to ZMotion Technology, if there is reproduction, please indicate article source. Thank you.

ZMOTION Technology    has attracted experienced talents from famous companies or institutions, such as Huawei, ZET, Huazhong University of Science and Technology etc. ZMOTION insists self- innovating and collaborating with comprehensive universities, to research basic knowledge of motion control. Due to its concentration and hard work in motion control technology, ZMOTION already become one of the fastest growing industrial motion control companies in China, and is also the rare company who has managed core technologies of motion control and real time industrial control software completely.            

 

ZMotion Technology provides motion control card, motion controller, vision motion controller, expansion module and HMI. (more keywords for ZMOTION: EtherCAT motion control card, EtherCAT motion controller, motion control system, vision controller, motion control PLC, robot controller, vision positioning...)


  

   I: Motion Control Card VC6.0 Development Process

   1. Open VC++6.0, build one new project. 
 

  image 1.png

  

   2. Select "MFC APPWizard(exe)", and choose the position where the project is saved, set project name, and click "ok" (确认 )

  

  image 2.png

  

   3. For application program type, select "basic dialog" (基本对话框 ) , then finish project new built.  

  image 3.png

  

   4. Copy dynamic link library "zmotion.dll", "zauxdll.dll", "head file" and "zauxdll2.h" of "..\function library\dll and "zauxdll.lib" of lib file into project folder.
       (folder -- E: zlm@zmotion.com.cn)

  

  image 4.png

  

   5. Select "Project" -- "Settings...".

   6. Switch to "Link" page, and enter lib file name "zauxdll.lib" in bar "Object\library modules".

  

  image 5.png

  

   7. Add the declaration of function library head file into application program file, such as, "#include "zauxdll2.h".  

  image 6.png

  

   8. At this time, users can call all functions of function library in VC6.0, and can start to edit application program.  Note: for detailed function usage, please refer to ZMotion PC Function Library Program Manual.

  

    9. According to ZMotion PC Manual -- function description of "Link to Controller". Specifically, add link controller code "ZAux_OpenEth(“192.168.0.11”,&g_handle)" into function "ECIDlg:OnInitDialog()", then controller can be linked.

  

  instruction 7.png

image 7.png

  

   10. Control controller do interpolation motion through MOVE button.

   (1) right click MOVE button, select property and set button ID.

  

  image 8.png

  

   (2) right click MOVE button and select event.

  

  image 9.png

   (3) new build relative event.

  

  image 10.png

  

   (4) add interpolation motion function in event processing function

instruction 27.png


  

  image 11.png

  

   11. Compile and run, then controller can be controlled through PC.

  • If compile reports error "precompiled head file can't be opened" "no exist file or content".

  • Please select "Project" -- "Settings..." -- C/C++, then do below configuration.

  

  image 12.png

  


   I I: VC6.0 Routine

   1. There are many VC6.0 routines, which make motion control easily of ZMotion motion controller, such as, routines of single-axis motion, homing, IO configuration reading, interpolation of linear, circular and continuous, manual motion, bus motion control, customized instruction encapsulation, etc. -- Need? -- E: zlm@zmotion.com.cn

  

   2. single-axis motion routine

   a. link to controller of assigned IP through Ethernet.

   b. set motion axis parameters.

   c. select the object for motion axes

   d. select motion method, achieve continuous motion and inching motion.

 image 13.png 

  

   3. Realization Steps

   (1) search IP, link to controller.

   A. drag relative widgets to UI interface, and set corresponding event processing function.  

  image 14.png

  

   B. drop-down the box of event processing function to realize automatic IP search.

   According to ZMotion PC Manual, add controller IP searching function "ZAux_SearchEthlist()" into event processing function, then resolve got IP character string (exact resolve method, refer to routine).   

 //automatically search IP void CECIDlg::OnDropdownIPList() { /*search IP address automatically*/ char buffer[10240]; int32 iresult; /*search IP address in current net segment. For details: please refer to ZMotion PC Program Manual*/ 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; } /*convert character tring to IP*/ int ipos =0; const char * pstring;

pstring = buffer;


for(int j= 0; j< 20;j++)

{ char buffer2[256]; buffer2[0] = '\0'; /*jump over blank space*/ while(' ' == pstring[0]) { pstring++; } ipos = sscanf(pstring , "%s", &buffer2); if(EOF == ipos) { break; } /*jump over character string*/ while((' ' != pstring[0]) && ('\t' != pstring[0]) && ('\0' != pstring[0])) { pstring++; } if(CB_ERR != m_pEthList->FindString(0, buffer2)) { continue; } if('\0' == buffer2) { return; } /*join in*/ m_pEthList->AddString(buffer2); } return; }

  

   C. click "link" button to connect to controller.

   According to ZMotion PC Manual, add the function "ZAux_OpenEth()" for connecting with controller through net port into event processing function when pressing "link" button, then linking controller function can be achieved.   

image 15.png

  

   D. click "disconnect" button to break controller connection.

   According to ZMotion PC Manual, add the function "ZAux_Close()" for disconnecting with controller into event processing function when pressing "disconnect" button, then controller disconnection function can be achieved.  

  image 16.png


  

   (2) select axis, and watch selected DPOS, current speed and motion status.

   A. drag relative widgets to UI interface, and set corresponding event processing function.  

  image 17.png

  

   B. select axis through event processing function of X, Y, Z, R 4 radio buttons.

  image 18.png

  

   C. update axis status in real time through timer.

  image 19.png

  

   (2)  read the state of in0-in7, out0-out7. 

  image 20.png

  

   Get IO status by using ZAux_GetModbusIn() and ZAux_GetModbusOut() interfaces. And encapsulate as one subprogram, then add that function into timeout processing function of timer for upgrading IO status.  

  

        //IO watch

        void CECIDlg::IOGet()

        {

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

          char  buff[128]={0};

          /*read input status*/

          ZAux_GetModbusIn (g_handle, 0, 7, &in);  //read the status of in0-in7

          /*from decimalism to binary system*/

          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, "status of IN0-7 :%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 outputs status*/

          ZAux_GetModbusOut (g_handle, 0, 7, &out);//get status of out0-7

          /* from decimalism to binary system*/

          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, "status of OUT0-7:%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 controller parameters

   A. drag relative widgets to UI interface, and set event processing function of parameter validity button.  

  image 21.png

  

   B. set member variables of each edit box, right click edit box first to select "establish class orientation" (建立类导向 )

  image 22.png

  

   C. add function interface that relates to parameters configuration into event processing function of parameter validity button. 

  image 23.png

  

   (5)   Control controller motion

   A. add two groups of radio buttons, inching distance edit box and 2 buttons into UI interface. 

  image 24.png

  

   B. Two radio buttons are used for setting motion direction and motion method, and for setting mark bit variable m_moveatype and m_movedir through their event processing function.  

  image 25.png

  

   C. open controller to move through event processing function of "open" button.  

  image 26.png

  

   D. stop controller motion through event processing function of "close" button.  

  iamge 27.png

  

   (6)   Compile and run

   A. complile and run teaching routine.  

  image 28.png

  

   B. connect to the same one controller through ZDevelop, and observe motion control effect.

   Below shows axis parameters and IN/OP, and in oscilloscope, DPOS, MPSEED are displayed.  

  

image 29.png

  image 30.png



"At last, one specail thing you should know"
There are two kinds of motion control cards, ECI2418 and ECI2618, are developed by ZMOTION.

image ECI2418.png

ECI2418 supports 4 axes pulse inputs and encoder feedback, and there are 24 inputs, 16 outputs, 2ADs and 2DAs on board. In addition, handwheel interface also is valid. Some specail outputs support high-speed PWM control.

image ECI2618.png

ECI2618 supports 6 axes pulse inputs and encoder feedback, and there are 24 inputs, 16 outputs, 2ADs and 2DAs on board. In addition, handwheel interface also is valid. Some specail outputs support high-speed PWM control.

ECI2618 ying.png

ECI2418 and ECI2618 both use the same set of API function, and support C, C++, C#, LabView, Python, Delphi and other development languages. And several platforms are valid, such as, VC6.0, VB6.0, Qt, .Net, etc., including Windows, Linux, WinCE, iMac and all kinds of operation systems.


That's all, thank you for your reading -- Application Development Tutorial -- Motion Control Card & CV6.0

Copyright © 2013-2024 Shenzhen Zmotion Technology Co.,Ltd Design by Zmotion    粤ICP备13037187号 Motion Controller-Motion Control Card

Contact Us-Youtube