Today, Zheng Motion Assistant will share with you the axis parameter description of the EtherCAT motion control card ECI2828 and how to use LabVIEW to initialize the EtherCAT bus.
ECI2828 Hardware Introduction
The ECI2828 series motion control card supports up to 16-axis linear interpolation, arbitrary circular interpolation, spatial circular interpolation, helical interpolation, electronic cams, electronic gears, synchronous following, virtual axes, and robot commands; it uses an optimized network communication protocol to achieve real-time motion control.
The ECI2828 series motion control card supports Ethernet and a RS-232 communication interface to connect to a computer, receive commands from the computer, and can connect to various expansion modules via EtherCAT and CAN buses to expand the number of input/output points or motion axes.
Applications for the ECI2828 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 easier debugging and observation.
Typical connection configuration diagram of ECI2828 series
II. Introduction to Basic Axis Parameters in LabVIEW
ATYPE: Axis function type setting, can only be set to the characteristics that the axis has (axis characteristics can be found in the hardware manual or by using ZDevelop software to connect to the controller and check the controller status).
UNITS: Pulse equivalent, specifies the number of pulses sent per unit, supporting 5 decimal places of precision.
ACCEL: Axis acceleration, in units/s/s. In multi-axis motion, the acceleration of the interpolated motion is the principal axis acceleration. It is recommended to set the acceleration and deceleration before motion and not to modify them during motion, as adjustments during motion will cause changes to the velocity curve.
DECEL: Axis deceleration, unit: units/s/s. Used as deceleration for interpolation in multi-axis motion. When set to 0, it automatically equals the acceleration value (ACCEL) for symmetrical acceleration and deceleration. It is recommended to set the acceleration and deceleration before starting the motion and not modify them during motion, as adjustments during motion will cause changes to the velocity curve.
SPEED: Axis speed, measured in units/s. Used as the interpolation speed in multi-axis motion. Modifications to SPEED take effect immediately, enabling dynamic speed changes, but there may be jitter upon change. For smooth speed changes, please use the SPEED_RATIO command.
The above are the basic parameters for controlling axis movement. As long as the hardware connection is correct, you can control the movement of a servo or stepper motor by setting these 5 parameters.
III. Preparation of Bus Initialization Files
Bus initialization files can generally be edited using ZDevelop, the development environment for Positive Motion.
We can directly open the ".zpj" project, which contains the "ECAT initialization.bas" file. Alternatively, we can directly open the "ECAT initialization.bas" file to modify the initialization procedure.
The following is the content of the initialization file:
'*******************************************************ECAT Bus Initialization''''''''''''global CONST BUS_TYPE = 0 'Bus type. Used by the host computer to distinguish the current mode. global CONST MAX_AXISNUM = 16 'Maximum number of axes. global CONST Bus_Slot = 0 'Slot number 0. global CONST Bus_AxisStart = 0 'Starting axis number of the bus axis. global Bus_InitStatus 'Bus initialization completion status. Bus_InitStatus = -1. global Bus_TotalAxisnum 'Check the total number of axes scanned. delay(3000) 'Delay 3S to wait for the driver to power on.'**********************Initialize ECAT bus. Ecat_Init() end
global sub Ecat_Init() local temp_axis for i=0 to MAX_AXISNUM - 1 'Initialize and restore axis type AXIS_ENABLE(i) = 0 atype(i)=0 next Bus_InitStatus = -1 Bus_TotalAxisnum = 0 SLOT_STOP(Bus_Slot) delay(200) slot_scan(Bus_Slot) 'Start scanning if return then 'Bus scan successful,' 'Number of connected devices:' NODE_COUNT(Bus_Slot) 'Start mapping axis number' for i=0 to NODE_COUNT(Bus_Slot)-1 'Traverse all slave nodes under the bus if NODE_AXIS_COUNT(Bus_Slot,i) <>0 then 'Check if the current node has a motor for j=0 to NODE_AXIS_COUNT(Bus_Slot,i)-1 temp_axis = Bus_AxisStart +Bus_TotalAxisnum `base(temp_axis) AXIS_ADDRESS=Bus_TotalAxisnum+1 'Map axis number ATYPE=65 'Set control mode 65-position 66-speed 67-torque DRIVE_PROFILE= 0 'Set PROFILE function disable_group(temp_axis) 'Group each axis separately' DRIVE_IO = 128 + (temp_axis)*16 'Map IO status on the drive' REV_IN = 128 + (temp_axis)*16 ' FWD_IN = 129 + (temp_axis)*16 ' DATUM_IN = 130 + (temp_axis)*16 ' INVERT_IN(128 + (temp_axis)*16,ON) ' INVERT_IN(129 + (temp_axis)*16,ON) ' INVERT_IN(130 + (temp_axis)*16,ON)` Bus_TotalAxisnum=Bus_TotalAxisnum+1 'Total number of axes +1 next endif next 'Axis number mapping complete,'"Total number of axes connected:"Bus_TotalAxisnum wa 2000 SLOT_START(Bus_Slot) 'Start bus if return then 'Bus started successfully' 'Start clearing driver errors (based on driver data dictionary settings)' for i= Bus_AxisStart to Bus_AxisStart + Bus_TotalAxisnum - 1 DRIVE_CONTROLWORD(i)=128 'Based on driver data dictionary wa 100 DRIVE_CONTROLWORD(i)=6 wa 100 DRIVE_CONTROLWORD(i)=15 wa 100 next 'Driver error clearing complete' wa 100 'Clear controller errors' datum(0) DRIVE_CLEAR(0) 'Controller error clearing complete' wa 100 'Axis enable preparation' for i = Bus_AxisStart to Bus_AxisStart + Bus_TotalAxisnum - 1 base(i) AXIS_ENABLE=1 next wdog=1 'Enable master switch Bus_InitStatus = 1 'Axis enable complete' else 'Bus start failed' Bus_InitStatus = 0 endif else 'Bus scan failed' Bus_InitStatus = 0 endif end sub
IV. Introduction to LabVIEW Programming
Before delving into the specific program details, let's first get a general understanding of how LabVIEW is programmed.
1. LabVIEW Programming Structure -- while Loop Structure
As the name suggests, the while loop structure is similar to the while loop in C language, or the while loop used in the ZDevelop development environment, to perform a loop scan of the program. We can control whether the while loop ends by inputting a BOOL type, and we can connect an exclamation mark (!) to a display control to show the number of times the while loop has been run.
2. LabVIEW Programming Structure - Event Structure
The event structure is the main structure for human-computer interaction. In the event structure, we can freely add trigger events for external controls.
For example, we added an "Ethernet Connection" control to the front panel. When we want to execute the corresponding program when this control is pressed, we can add an event for this control to the event structure to achieve our goal.
Step 1: Controller Connection
Step 2: Add event branches
Third step: Editing events
Step 4: Add Ethernet connection control
Step 5: Press the "Ethernet Connection" control.
When we press the "Ethernet Connection" control, a message box pops up that displays "Mouse pressed," which is the character constant we want to display.
3. LabVIEW Programming Structures -- Conditional Structures.
This structure is similar to the if statement in the C language. When the input in the conditional structure is true, the program inside the "true" condition is executed; when the input in the conditional structure is false, the program inside the "false" condition is executed.
4. LabVIEW Programming Structure -- Program Execution Sequence.
In LabVIEW, the last function added is usually executed first.
Therefore, in order to perform execution sequentially, we can use a sequential structure for classification.
first step
Step 2
Step 3
5. Initialize the EtherCAT bus using LabVIEW
1. Download initialization file function.
Now let's introduce the functions used to download the "Bas file" to the controller.
2. Examples of using functions in LabVIEW.
Below, we will use Example 8 - Bus Control Motion Example - to explain how to use the ZAux_BasDown function.
(1) First, we added a mouse press event to the event structure: “[Download Bas file] value changed”.
This event is triggered when the "Download Bas File" button on our control interface is pressed.
(2) Next, the condition in the "condition structure" is met, that is, when the handle is not 0, the "true" program in the condition structure is executed.
In the "Conditional Structure," we see a "File Dialog Box" control, which opens a dialog box for selecting the file to download. All that's left is to select the bus file we need to initialize.
(3) After initialization, we can see that the axis status is 65, which means that we are using the CSP position mode.
3. Displaying the status of the central axis in LabVIEW.
(1) Since the axis status bar is updated in real time, we need to access the axis parameters in the controller repeatedly. Here we can write our axis parameter reading program in the "Timeout" field of the "Event Structure". The "Timeout" event is the default event executed in the "Event Structure" when no other events are triggered.
Here we can see that there are two "conditional structures" in this "timeout" event, one of which is the axis parameter reading "conditional structure". In the axis parameter reading conditional structure, when the connection handle is not 0, the axis parameter reading "conditional structure" is in the execution state. That is, as long as we connect to the controller, the axis parameters are always in the real-time reading state.
Another "conditional structure" is the bus initialization display program. When any of the three variables, "file download flag", "initialization status", and "connection handle", fails to meet the requirements, the bus node, the "Bus_InitStatus" initialization completion flag in the initialization file, and the "Bus_TotalAxisnum" total number of bus axes are reread.
4. EtherCAT interaction in LabVIEW.
To understand the program implementation of SDO communication on the EtherCAT bus, we can look at the programs in the "Set" and "Read" buttons in the "Event Structure".
(1) "Settings" event procedure.
We can see that the "Settings" event only needs to call one function, "ZAux_BusCmd_SDOWrite", to achieve the desired result.
(2) "Read" event procedure.
Reading can also be achieved simply by calling the "ZAux_BusCmd_SDORead" function.
VI. Debugging and Monitoring
1. Because the ECI2828 establishes a connection with the PC via TCP/IP, this means we can establish multiple connections. Therefore, when starting a LabVIEW program, we can also use the ZDevelop motion development environment to monitor the current controller's operating status.
The printed information shows that the bus initialization was successful.
2. Oscilloscope usage.
Connect to the "ZDevelop" software to monitor the controller status through the axis parameters on the right side of the software. Alternatively, click "View" → "Oscilloscope" to open the oscilloscope and monitor the axis movement.
An oscilloscope can monitor the current command location and feedback location in real time.
3. Debug the video.
This concludes the third installment of our series on building intelligent equipment using EtherCAT motion control cards and LabVIEW.
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.