Bring Values and Sucesses To Our Customers

Home / Support and services / Technical Support

Technical support

Technical Support

How to Do CAD Mapping (DXF) on PCIE EtherCAT Motion Control Card

Two Functions in Motion Control for PCIe EtherCAT Real-Time Motion Control Card

How to Do CAD Mapping for DXF Graphics?

How to Do Rapid Processing among Multi-Command?

Specifically, Zmotion will share with you, how to use C# to do CAD mapping and develop multiple tasks by RTBasic. And here, for the hardware board, we take PCIe EtherCAT motion control card PCIE464 as the example.

--Hardware PCIE464--

A. What is PCIE464

PCIE464 is a kind of EtherCAT + Pulse motion control card that is with PCIE interface. Motion control can be 6-64 axes. And there are multiple high-speed digital inputs and outputs, which means "multi-axis synchronous control" and "high-speed data transfer" can be realized easily.

1.png


B. How PCIE464 can Do

*Functions: 

multi-axis point to point, interpolation motion, trajectory planning, handwheel control, encoder position measurement, IO control, position latch, etc.

*Applications: 

mainly for high-speed & high-precision, like, 3C electronics processing, detection equipment, semiconductor equipment, SMT processing, laser processing, optical communication equipment, lithium battery and photovoltaic equipment, and non-standard automated equipment.

2.png


C. How to Develop PCIE464

PCIE4XX control card can use VC, VB, VS, C++, C# software, but while running, it needs dynamical library "zmotion.dll". At the same time, controller / card can connect to RTSys (ZDevelop) software for watching and debugging.

3.png


D. PCIE464 Video Introduction

4.jpg

What is PCIE464 -- Video

1. Wiring Reference

(1) Digital Input IN

Digital inputs are distributed in J400 (IN0-IN7) and X400 (IN8-IN39) signals.

5.png

6.png


(2) Digital Output OUT

Digital outputs are distributed in J400 (OUT0-7) and X400 (OUT8-OUT39) signals.

7.png

8.png




2. Develop by C#

A. Do Project Development by C#

(1) In VS2010 menu, build one new project through clicking "File" -- "New" -- "Project" in order.

9.png

(2) Select "Visual C#" development language, then select ".NET Framework", and click "Windows Application Program".

10.png

(3) Obtain Zmotion "motion control library" and "CAD mapping library" (take 32-bit as the example), contact us directly.

11.png

(4) Copy Zmotion C# library file and corresponding file into new built project, at the same time, put Zmotion C# relative library file into folder "bin\debug".

12.png

(5) Use "vs" to open new built project file, in "solution resource manager", select "show all", and right click "zmcaux.cs" file, then click "include in project". Use same methods, add "zmclaser" and "zmotioncad.cs" files to the project.

13.png

14.png

(6) Double click Form1 that is in Form1.cs, corresponding coding interface appears, then write "using cszmcaux" and "using ZmotionCadDll" at the beginning, and state controlller handle "g_cardhandle" and cad library function handle "g_cadhandle".

15.png

(7) Now, project is new built, it's time to do C# project development.


B. Do CAD Mapping by C#

In real running, if the graphic motion trajectory coordinates are calculated by labor, obviously, it is time-consuming and laborious. Therefore, in this kind of situation, we can use the computer to calculate the motion trajectory. Let's how to use C# to do CAD mapping.

(1) Steps

Firstly, build a new WinForm project and add function library. Then use the ZMotionCadArray_ImportVectGraph command to import and open the CAD file, and perform the segmentation accuracy of the small line segments.

Secondly, use the ZMotionCadArray_GetVectNum command to obtain the array length, and then build a "struct_zcad_array" structure type (the structure has been stated in the ZMotionCad library, so it can be directly defined and called) to save motion data, motion type, etc.

Thirdly, use the "ZMotionCadArray_GetVectArray" command to save the graphics' motion data into the array.

Finally, use the "ZMotionCadArray_MergeSeg" command to connect the points into lines.

The operation idea is shown in the figure.

16.png

(2) Commands

17.png 

(3) Generate Motion trajectory Data

After importing the .dxf file:

--use the ZMotionCadArray_ImportVectGraph command to import the CAD file and split the small line segments.

--use ZMotionCadArray_GetVectNum to get the data length, after that, create an array of type Struct_ZCad_Array.

--at this time, CAD data is saved in this structure array. Use the ZMotionCadArray_GetVectArray command to get the graphic data.

--create an array of type StringBuilder, use a loop to access the motion type of the Struct_ZCad_Array type array, and insert its motion coordinate tail into the array.

--use file IO to build one bas file, and insert the motion data tail of the StringBuilder type array into the bas file.

18.png

a. import the graphic file, obtain the point information of the CAD through the thread, and use the brush to display the point information on the drawing board.

19.png

--codes for getting CAD point information--

20.png

b. click "run", and send the motion command that is generated by thread to make controller run CAD point coordinates.

21.png

(4) Running Effect

22.png




3. Self-Define Encapsulate Command Function

In the actual development process, if there are no ready-made commands in the ZMotion PC function library, you can self-define and encapsulate function to achieve needed functions, then, improve the efficiency of interaction.

Next, see how to self-define command function encapsulation through sending multiple commands at one time.

(1) Command

23.png


(2) Codes

24.png

Refer to above codes:

a. it defines 4 parameters at first, they are handle, how many axes, axis list (starting axis No. to end axis No.), each axis' motion distance (it can be multiple point information, use ";" as the end mark of a point information).

b. in the self-defined function, cut the axis_distance content in the parameter with ";" and save it in the dir_move array.

c. the point information in the dir_move array is scanned in cycle, and is spliced as "moveabs" motion commands by splicing character string, then save these commands into the variable (name is cmdbuff, the type is string).

d. send command ZAux_DirectCommand to send multiple motion instructions in the variable named cmdbuff to the control card or controller.

--call self-defined encapsulated function commands--

25.png


(3) Effect

A. data in parameter "direct_str[0]":

26.png

B. data spliced in cmdbuff

27.png

These two data show above codes are logical and realizes the efficient transmission of multiple data processing in one command.




4. Real-Time Switch Analog and Speed


(1) Steps

First, set the automatic running task No. of the Basic file. You can check how many tasks the controller supports at most in the "Controller State" on the RTSys (ZDevelop). Then fill in the automatic running task No. on the Basic file (it cannot exceed the maximum number of tasks supported), at last, download it to the controller.

A. Confirm Control Max Task

28.png

B. Fill in AutoRun Task No.

29.png

C. Download Written Program into Controller

30.png

D. Set "Transfer Ratio K Value (0-1)" in PC

31.png


(2) Commands

32.png

Note: in this sample code, when the "Varname" parameter of ZAux_Direct_SetUserVar in the PC command is using, Basic file's global variable s_ratio is written.


(3) Example Description

In the Basic program below, it can control controller DA (analog output) according to axis speed, it also can modify the conversion ratio K of analog and speed through PC.

After using an oscilloscope to capture the output waveforms of speed and analog, it can be seen that the waveforms of speed and analog are basically the same.

33.png

--Basic Codes--

GLOBAL s_ratio    'speed ratio

WHILE 1

'the speed is proportional to the analog.

AOUT(0)=4.095*VP_SPEED(0)*s_ratio

WEND

end


--PC Codes--

int ret = zmcaux.ZAux_Direct_SetUserVar(G_CardHandle, "s_ratio", Convert.ToSingle(textBox4.Text));  //set the conversion ratio between analog and speed

err_inform("ratio's ZAux_Direct_SetUserVar",ret);

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

Contact Us-Youtube