Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 8, 2022 03:46 am GMT

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.

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

  3. For application program type, select "basic dialog" ( ) , then finish project new built.

Image description

  1. 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: [email protected])

Image description

  1. Select "Project" -- "Settings...".

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

Image description

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

Image description

  1. 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.

  2. 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.

Image description

Image description

  1. Control controller do interpolation motion through MOVE button.

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

Image description

(2) right click MOVE button and select event.

Image description

(3) new build relative event.

Image description

(4) add interpolation motion function in event processing function

Image description

Image description

  1. 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 description

II: 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: [email protected]

  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 description

  1. Realization Steps

(1) search IP, link to controller.

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

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]) && ('' != 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 description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b04p08ts2fuvmfpnj3ax.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 description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crfe84lwcmspd8yd8kew.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 description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uz3s4la0n19fs34tjmen.png)B. select axis through event processing function of X, Y, Z, R 4 radio buttons.![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s3dlx1tsjptcp5fcljlc.png)C. update axis status in real time through timer.![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bg2r70r3o7ghpv1macw5.png)(2)  read the state of in0-in7, out0-out7.![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evkqg3qillmx3kkrglek.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 description

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

Image description

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

Image description

(5) Control controller motion

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

Image description

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 description

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

Image description

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

(6) Compile and run

A. complile and run teaching routine.

Image description

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 description

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

Image description

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 description

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.

Image description

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


Original Link: https://dev.to/zmotion/zmotion-application-development-tutorial-motion-control-card-vc60-oe2

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To