Develop EtherCAT Motion Control by LabView

ZMOTION CONTROLLER - Oct 29 - - Dev Community

If you master PC Labview knowledge, you can develop EtherCAT motion control and capture data in real-time easily.
Let's see how to do that.
Here, take one EtherCAT Motion Controller as the example.

1. How to Develop Motion Control by LabVIEW?

(1) Build LabVIEW Project

Image description

(2) Download "zauxdll" folder of LabVIEW Vi function library into PC, then copy it into "LabVIEW/user.lib".

Labview function library file and corresponding development examples can be obtained.

(3) PC Function | Related Interfaces

Zmotion provides general API function, it includes all kinds of host computer languages.

A. ZAux_OpenEth(): connection

Image description

B. ZAux_Direct_GetTable: get data from table, and import oscillocope data source

Image description

C. ZAux_Direct_GetDpos: get DPOS (demand position)

Image description

D. ZAux_Direct_GetMspeed: get feedback speed

Image description

E. ZAux_Direct_GetVpSpeed: get planning speed

Image description

F. ZAux_Direct_GetMpos: get MPOS (measurement position)

Image description

G. ZAux_Direct_Cam: do eletronic cam motion

Image description

(4) How to Get Real-Time Data

A. creat new vi in front board, and right click the mouse to select "control" to do UI designning, as it is shown in the below, the left is "connection" interface, the right is planning position of oscilloscope.

Image description

B. add "while" loop in added frame through mouse, then add "event structure" in "while", and right click to choose "add event branch", the "timeout" event, then get current needed data and import them into oscilloscope.

Image description

C. select event structure, and right-click to select "add event branch". In "while" structure, when the handle is blank, it will automatically get current controller IP, then use "Z Aux Open Eth.vi" function to connect to controller.

Image description

D. select event structure, and right-click to select "add event branch", the "disconnect" value changing, then use "Z Aux Close.vi" function to disconnect the connection.

Image description

E. select event structure, and right-click to select "add event branch", the "trigger" value changing, then use "Z Aux Trigger.vi" function to trigger oscillscope to capture the data.

Image description

F. select event structure, and right-click to select "add event branch", the "ON SCOPE " value changing, then use "Z Aux Execute.vi" function to call "SCOPE" command to open data acquisition, and save them into table register.

Image description

Image description

G. select event structure, and right-click to select "event", the "XY Graphic:" mouse changing . Then in this event branch, the coordinate position of the mouse within the corresponding range of the XY oscilloscope and the XY2 oscilloscope is read in real time and displayed on the interface.

Image description

Image description

H. select the condition structure. When the sine motion button is pressed, the two sine motions execute the two electronic cam motion commands in the sequence of tiling. Use the "Z Aux Cam.vi" function to move corresponding electronic cam motions according to data that has been loaded in table register in advance.

Image description

2. Debug & Watch

Compile the routine, and connect to ZDevelop / RTSys at the same time. Then run one "SIN" waveform trajectory through the corresponding single-axis routine. When the motion is running, capture the real-time data through LabVIEW oscillocope and ZDevelop oscilloscope synchronously.

(1) Algorithm Command: generate SIN waveform data

DIM  num_p,scale,m,t   'define variable
num_p=100
scale=500
FOR p=0 TO num_p
    TABLE(p,((-SIN(PI*2*p/num_p)/(PI*2))+p/num_p)*scale) 'save cam motion parameters into table
NEXT
Enter fullscreen mode Exit fullscreen mode

(2) Waveform Comparison

A. ZDevelop and LabVIEW captures DPOS demand position.

--ZDevelop Oscilloscope Waveform--

Image description

--LabVIEW Oscilloscope Waveform--

Image description

It can be seen they are consistent.

B. ZDevelop and LabVIEW captures VP_SPEED.

Image description

Also, their waveforms are the same.

That's all, thank you for your reading -- EtherCAT Motion Controller LabVIEW Motion Control Development & Real-Time Data Reading.

This article is edited by ZMOTION, here, share with you, let's learn together.

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

Have a good day, best wishes, see you next time.

. . .