Difference between revisions of "Category:EtherCAT:EC SETUP"

From SoftMC-Wiki
Jump to: navigation, search
 
(30 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Languages|EtherCAT:EC_SETUP}}
 
{{Category
 
{{Category
|description=How to setup EtherCAT.
+
|description=How to Set up EtherCAT.
 
|frontpage=[[EtherCAT]]
 
|frontpage=[[EtherCAT]]
  
 +
==Introduction==
 +
Before starting to work with the softMC, you must setup the EtherCAT master to work with the slaves.<br/>
 +
You must configure the axes in the system in a certain manner, then invoke certain functions and subroutines in an orderly manner, and make sure no errors occur.
  
Before starting to work with the softMC you must setup the EtherCAT master to work properly with the slaves.<br/>
+
A CONFIG.PRG and a program file EC_SETUP.PRG exist in the repository, and demonstrate the following process.
You must configure the axes in the system in a certain manner, then invoke certain functions and subroutines in an orderly fashion, and make sure no errors occur.<br/>
+
 
A CONFIG.PRG and a program file EC_SETUP.PRG exist in the repository, and demonstrate the following process.<br/>
+
CONFIG.PRG allocates an array of generic axes by the name Axes[], and sets all the existing axes in the system into this array.<br/>
<br/>
+
{{Note| Since verison 0.4.15.3rc6 the global axis array systemAxis[] is introduced, and the array Axes[] is made redundant, therefore it is removed from CONFIG.PRG }}
CONFIG.PRG allocates an array of generic axis by the name Axes[], and sets all the existing axes in the system into this array.<br/>
+
EC_SETUP.PRG and AX_SETUP.PRG use this array to setup the system automatically.
EC_SETUP.PRG and AX_SETUP.PRG use this array to setup the system automatically.<br/><br/>
 
  
 
{{Note/Important|
 
{{Note/Important|
 
It is critical to maintain the demonstrated order of the EtherCAT setup.<br/>Any change in the given example may result in undefined behavior!}}
 
It is critical to maintain the demonstrated order of the EtherCAT setup.<br/>Any change in the given example may result in undefined behavior!}}
  
<br/><br/>
 
 
==EC_SETUP.PRG==
 
==EC_SETUP.PRG==
EC_SETUP.PRG is a generic script. Its goal is to configure the EtherCAT master and slaves before they are started, start the master, and eventually run additional actions to complete the EtherCAT start up procedure.
+
EC_SETUP.PRG is a generic script. Its purpose is to configure the EtherCAT master and slaves before they are started, start the master, and eventually run additional actions to complete the EtherCAT startup procedure.
  
 
EC_SETUP.PRG is written in a manner that easily allows embedding code to configure specific motion drives and IO modules.
 
EC_SETUP.PRG is written in a manner that easily allows embedding code to configure specific motion drives and IO modules.
  
This article details the more important steps taken upon EtherCAT start up as they are carried out by EC_SETUP.PRG.
+
This article details the main steps that occur upon EtherCAT startup as they are executed by EC_SETUP.PRG.
  
==A word about drive address==
+
==Drive Address==
Each EtherCAT slave has an address. At the moment this address is determined strictly according to the slave's location in the
+
Each EtherCAT slave has an address. Currently this address is determined strictly according to the slave location in the
[[:File:Axystems;EC_master_slave_position_topology.PNG|physical topology]] of the system, i.e., the first slave that is attached to the MC is assigned drive address 1, the second slave in the chain gets
+
[[:File:Axystems;EC_master_slave_position_topology.PNG|physical topology]] of the system; that is, the first slave attached to the MC is assigned drive address 1, the second slave in the chain gets slave address 2, and so on.  
slave address 2, etc.<br/>An EtherCAT slave can be a motion drive or an IO module.
 
  
 +
An EtherCAT slave can be a motion drive, an IO module or a Gateway.
  
==PRE-OP stage==
+
==PRE-OP Mode ==
  
Before the master is started all the slaves are in PRE-OP mode. In this stage the master is created and the system gathers from the slaves information that is used to creating data structures that are used by the master to setup the EtherCAT communication.
+
Before the master is started all the slaves are in PRE-OP mode. In this stage the master is created and the system gathers information from the slaves in order to create data structures that are used by the master to set up the EtherCAT communication.
  
 
+
First, differentiate between '''motion drives''' and '''IO modules'''. For each slave query the slave's Vendor ID and Product Code.
First, differentiate between 'Motion Drives' and 'IO Modules'. About each slave query the slave's Vendor ID and Product Code.
+
This data can later be used to identify specific products and create specific configuration for them, as in the [[EtherCAT:EC_INSTALL_STX_CDHD|CDHD Configuration example]].
This data can later be used to identify specific products and create specific configuration for them, as in the [[EtherCAT:CDHD_CONFIGURE|CDHD Configuration example]].
+
<syntaxhighlight lang="vb">
<pre>
 
 
numOfSlaves = EC_ETHERCAT_INIT
 
numOfSlaves = EC_ETHERCAT_INIT
</pre>
+
</syntaxhighlight>
  
Look for an unknown generic DS402 motion drive. If found, remap its PDO's to the required minimum.
+
Look for an unknown generic DS402 motion drive. If found, remap its PDOs to the required minimum.<br/>
<pre>
+
You may update the following code by replacing the define GENERIC_DS402_DRIVE_VENDOR with your device's vendor ID, by doing so remapping its PDO's to the required minimum to create sync position motion:
 +
<syntaxhighlight lang="vb">
 
for drive_addr = 1 to numOfSlaves
 
for drive_addr = 1 to numOfSlaves
 
if ETSLAVES[drive_addr]->et_slavetype = ECAT_MOTIONSLAVE then
 
if ETSLAVES[drive_addr]->et_slavetype = ECAT_MOTIONSLAVE then
if EC_SLAVES_INFO[drive_addr]->vendor_id = GENERIC_DS402_DRIVE_VENDOR then
+
if EC_SLAVES_INFO[drive_addr]->vendor_id = GENERIC_DS402_DRIVE_VENDOR then '  replace with your product's vendor ID
 
call EC_REMAP_MINIMUM_PDOS(drive_addr)
 
call EC_REMAP_MINIMUM_PDOS(drive_addr)
 
end if
 
end if
 
end if
 
end if
 
next
 
next
</pre>
+
</syntaxhighlight>
Create the EtherCAT Master
+
 
<pre>
+
===Check the EtherCAT Topology for Wiring Errors===
 +
EtherCAT topology is sensitive to the direction of the wiring. Each EtherCAT slave has an INPUT connector and an OUTPUT connector.<br/>
 +
The cable that "starts" from the EtherCAT master's OUTPUT must be connected to the INPUT of the first EtherCAT slave. A second cable will "exit" from the OUTPUT of the first slave and get connected to the INPUT of the second slave, etc...<br/>
 +
'Miswiring' on most occasions means that somewhere in the topology the EtherCAT cable wiring got confused between the INPUT and the OUTPUT connectors.<br/>
 +
This situation results UNDEFINED behavior, even up to making the wrong motor move, which is a safety issue.
 +
{{Note/Important|If a miswiring is detected, an error will be thrown and EC_SETUP.PRG will stop running}}
 +
<syntaxhighlight lang="vb">
 +
retVal = CHECK_TOPOLOGY
 +
</syntaxhighlight>
 +
 
 +
Create the EtherCAT Master.
 +
<syntaxhighlight lang="vb">
 
call EC_CREATE_MASTER
 
call EC_CREATE_MASTER
</pre>
+
</syntaxhighlight>
  
Set Motion Cycle Time: 4000, 2000, 1000, 500 or 250[us]
+
Set Motion Cycle Time: 4000, 2000, 1000, 500 or 250 [us]
<pre>
+
<syntaxhighlight lang="vb">
call EC_SET_BUS_CYCLETIME(4000)  '  For a cycle time of 500/250[us], add to FWCONFIG: hpetfreq = 2000
+
call EC_SET_BUS_CYCLETIME(4000)  '  for a cycle time of 500/250[us], add to FWCONFIG: hpetfreq = 2000
</pre>
+
</syntaxhighlight>
  
  
 
From here on EC_SETUP.PRG uses the gathered information to configure the slaves. A 'For Loop' goes over the slaves and tries to match
 
From here on EC_SETUP.PRG uses the gathered information to configure the slaves. A 'For Loop' goes over the slaves and tries to match
them to already known products (as the CDHD). When found, product specific functions are invoked to create in the master data structures
+
them to already known products (such as the CDHD). When found, product specific functions are invoked to create data structures in the master that elaborate the PDO mapping of the slaves, be it a motion drive or an IO module. This is where you can add your own code to configure your own EtherCAT slave. Just add another case to match your Vendor ID.<br/>
that elaborate the PDO mapping of the slaves, be it a motion drive or an IO module.
+
You may use the already prepared GENERIC_DS402_DRIVE_VENDOR case.<br/>
This is where you can add your own code to configure your own EtherCAT slave. Just add another case to match your Vendor ID.
+
Replace the define GENERIC_DS402_DRIVE_VENDOR with your device's vendor ID, and GENERIC_DS402_DRIVE_PRODUCT_ID with the device's product code:
  
If an STX CDHD motion drive is found, the function [[EtherCAT:EC_INSTALL_STX_CDHD|EC_INSTALL_STX_CDHD]] is invoked. This function sets some parameters in the drive,
+
<syntaxhighlight lang="vb">
creates the PDO map of the CDHD and queries the drive's PNUM and PDEN to allow calculation of the [[MC-Basic:axis.POSITIONFACTOR|Position Factor]].
+
      Case GENERIC_DS402_DRIVE_VENDOR  ' replace with your vendor id
In case of a generic drive, a minimum PDO mapping and default values are used.
 
More about STX CDHD configuration in [[EtherCAT:CDHD_CONFIGURE|CDHD Configuration]].
 
  
After the slave configuration is done a few more subroutines are called one after another to finish the master's preparation,
+
        if EC_SLAVES_INFO[drive_addr]->product_code = GENERIC_DS402_DRIVE_PRODUCT_ID then  ' replace with your product id
and the master is started:
 
<pre>
 
call EC_ASSIGN_PDOS_AUTO
 
  
' After telling the master with which slaves we would like to work, we create the PDO map
+
          call EC_INSTALL_GENERIC_DRIVE(drive_addr, Counts_Per_Revolution)  ' Counts Per motor Revolution
call EC_CREATE_PDOS_MAP
+
          num_Of_Motion_Drives = num_Of_Motion_Drives + 1
  
call EC_SET_CYCLETIME  ' Set EtherCAT cycle time
+
        end if
 +
</syntaxhighlight>
  
' Raise slaves to OP-Mode
+
If a Servotronix (STX) CDHD servo motion drive is found, the function [[EtherCAT:EC_INSTALL_STX_CDHD|EC_INSTALL_STX_CDHD]] is invoked. This function sets certain parameters in the drive, creates the PDO map of the CDHD, and queries the drive's PNUM and PDEN to allow calculation of the [[MC-Basic:axis.POSITIONFACTOR|Position Factor]].
call EC_STARTMASTER ' sync clocks between the master and the slaves, and sets master's opmode to operational
 
</pre>
 
  
The master attempts to raise all the slaves to OP-Mode. If it fails the procedure is stopped and an error is thrown.
+
For a generic drive, a minimum PDO mapping and default values are used.  
If it is successful EtherCAT communication is now online and EC_SETUP.PRG starts the second stage of configuration.
 
  
==OP-Mode stage==
+
The user can add his own code to [[EtherCAT:EC_USER_PREOP_CONFIG|EC_USER_PREOP_CONFIG]] to perform any specific configuration that must take place while the slaves are in PREOP mode.
  
Again, a 'For Loop' goes over all the slaves. When a motion drive is met EC_SETUP.PRG attaches its drive address to an axis and
+
After the slave configuration is done the master is started:
 +
<syntaxhighlight lang="vb">
 +
' Create PDOs mapping, set bus cycle time, sync clocks between the master and the slaves,
 +
' raise slaves to OP-Mode and sets master's opmode to operational
 +
call EC_STARTMASTER  ' Syncs clocks between the master and the slaves, and sets master's opmode to operational
 +
</syntaxhighlight>
 +
 
 +
The master attempts to raise all the slaves to OP Mode. If it fails, the procedure is stopped and an error is issued.
 +
If it is successful, EtherCAT communication is now online and EC_SETUP.PRG starts the second stage of configuration.
 +
 
 +
==OP Mode ==
 +
 
 +
Again, a For Loop goes over all the slaves. When a motion drive is encountered, EC_SETUP.PRG attaches its drive address to an axis and
 
attempts to clear its faults.
 
attempts to clear its faults.
<pre>
+
Again, the user can add his own code to [[EtherCAT:EC_USER_SAFEOP_CONFIG|EC_USER_SAFEOP_CONFIG]] and [[EtherCAT:EC_USER_OP_CONFIG|EC_USER_OP_CONFIG]] to perform any specific configuration that must take place while the slaves are in "SAFEOP" or "OP" mode.<br/>
' Assign slave address to an axis
+
 
Axes[Axis_Attached_To_Drive].dadd = drive_addr
+
<syntaxhighlight lang="vb">
 +
' SAFEOP state configuration - Add code to EC_USER_SAFEOP_CONFIG(byval drive_addr as long)
 +
retVal = EC_USER_SAFEOP_CONFIG(drive_addr)
 +
 
 +
' OP state configuration - Add code to EC_USER_OP_CONFIG(byval drive_addr as long)
 +
retVal = EC_USER_OP_CONFIG(drive_addr)
 +
 
 +
' Assign ECAT bus ID and slave address to an axis
 +
systemAxis(Axis_Attached_To_Drive).busnumber = ECAT_BUSID
 +
systemAxis(Axis_Attached_To_Drive).dadd = drive_addr
  
 
' Attempt to clear faults in the drives
 
' Attempt to clear faults in the drives
Line 110: Line 137:
  
 
End Try
 
End Try
</pre>
+
</syntaxhighlight>
All the motion drives are set to 'Synchronous Position' Mode
+
 
<pre>
+
 
 +
All the motion drives are set to Synchronous Position Mode:
 +
<syntaxhighlight lang="vb">
 
' Set drives to sync position mode
 
' Set drives to sync position mode
 
if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x6060, 0) then
 
if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x6060, 0) then
Line 119: Line 148:
 
call EC_SDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8, 8)
 
call EC_SDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8, 8)
 
end if
 
end if
</pre>
+
</syntaxhighlight>
 
 
The last thing done is creating an association between motion drive's digital inputs/outputs and system's digital inputs/outputs.<br/>
 
This association is done according to the drive address in the following manner:<br/>
 
<br/>
 
Drive address x  &  drive's digital inputs/outputs [1...y]  --->  system's digital inputs/outputs [100*x...100*x+(y-1)]
 
<br/>
 
<pre>
 
'  If mapped to PDO, set 0x60FD and 0x60FE as digital inputs/outputs
 
if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x60FD, 0) then
 
call EC_SET_DRIVE_DINS(drive_addr, drive_addr*100, num_Of_Digital_Inputs)
 
printu "Drive  # : sys.din. # to sys.din. #" ;drive_addr, drive_addr*100 , drive_addr*100+(num_Of_Digital_Inputs-1)
 
end if
 
if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x60FE, 1) then
 
call EC_SET_DRIVE_DOUTS(drive_addr, drive_addr*100, num_Of_Digital_Outputs)
 
printu "Drive  # : sys.dout. # to sys.dout. #";drive_addr, drive_addr*100 , drive_addr*100+(num_Of_Digital_Outputs-1)
 
end if
 
</pre>
 
 
 
More information about digital IOs can be found in [[EtherCAT:DIGITAL-IOS|DIGITAL-IOS]].
 
  
''Example''
 
  
An STX CDHD drive has 11 inputs and 6 outputs and is positioned 3rd in the physical topology, meaning its drive address is 3.<br/>
 
The drive's inputs will be associated with system digital inputs Sys.Din[300][11].<br/>
 
The drive's outputs will be associated with system digital outputs Sys.Dout[300][6].<br/>
 
<br/>
 
The drive's digital inputs are read as follows:<br/>
 
?Sys.Din[300][11]<br/>
 
The drive's digital outputs are set as follows:<br/>
 
Sys.Dout[300][6] = <6 bits value><br/>
 
  
<br/>
+
==See Also==
==SEE ALSO==
 
 
* [[EtherCAT:EC ETHERCAT INIT|EC_ETHERCAT_INIT]]
 
* [[EtherCAT:EC ETHERCAT INIT|EC_ETHERCAT_INIT]]
 
* [[EtherCAT:EC REMAP MINIMUM PDOS|EC_REMAP_MINIMUM_PDOS]]
 
* [[EtherCAT:EC REMAP MINIMUM PDOS|EC_REMAP_MINIMUM_PDOS]]
 
* [[EtherCAT:EC CREATE MASTER|EC_CREATE_MASTER]]
 
* [[EtherCAT:EC CREATE MASTER|EC_CREATE_MASTER]]
 
* [[EtherCAT:EC SET BUS CYCLETIME|EC_SET_BUS_CYCLETIME]]
 
* [[EtherCAT:EC SET BUS CYCLETIME|EC_SET_BUS_CYCLETIME]]
* [[EtherCAT:EC ASSIGN PDOS AUTO|EC_ASSIGN_PDOS_AUTO]]
+
* [[EtherCAT:EC GET BUS CYCLETIME|EC_GET_BUS_CYCLETIME]]
* [[EtherCAT:EC CREATE PDOS MAP|EC_CREATE_PDOS_MAP]]
 
* [[EtherCAT:EC SET CYCLETIME|EC_SET_CYCLETIME]]
 
 
* [[EtherCAT:EC STARTMASTER|EC_STARTMASTER]]
 
* [[EtherCAT:EC STARTMASTER|EC_STARTMASTER]]
 
* [[EtherCAT:EC CLEAR FAULTS|EC_CLEAR_FAULTS]]
 
* [[EtherCAT:EC CLEAR FAULTS|EC_CLEAR_FAULTS]]
* [[EtherCAT:EC SET DRIVE DINS|EC_SET_DRIVE_DINS]]
 
* [[EtherCAT:EC SET DRIVE DOUTS|EC_SET_DRIVE_DOUTS]]
 
 
* [[EtherCAT:EC SDO READ|EC_SDO_READ]]
 
* [[EtherCAT:EC SDO READ|EC_SDO_READ]]
 
* [[EtherCAT:EC SDO WRITE|EC_SDO_WRITE]]
 
* [[EtherCAT:EC SDO WRITE|EC_SDO_WRITE]]
Line 169: Line 165:
 
* [[EtherCAT:EC PDO WRITE|EC_PDO_WRITE]]
 
* [[EtherCAT:EC PDO WRITE|EC_PDO_WRITE]]
 
* [[EtherCAT:EC IS PDO|EC_IS_PDO]]
 
* [[EtherCAT:EC IS PDO|EC_IS_PDO]]
 
+
* [[EtherCAT:EC_USER_PREOP_CONFIG|EC_USER_PREOP_CONFIG]]
 +
* [[EtherCAT:EC_USER_SAFEOP_CONFIG|EC_USER_SAFEOP_CONFIG]]
 +
* [[EtherCAT:EC_USER_OP_CONFIG|EC_USER_OP_CONFIG]]
 
}}
 
}}
  

Latest revision as of 16:18, 3 May 2017

Language: English

Category:EtherCAT:EC SETUP How to Set up EtherCAT.

The front page is EtherCAT

Introduction

Before starting to work with the softMC, you must setup the EtherCAT master to work with the slaves.
You must configure the axes in the system in a certain manner, then invoke certain functions and subroutines in an orderly manner, and make sure no errors occur.

A CONFIG.PRG and a program file EC_SETUP.PRG exist in the repository, and demonstrate the following process.

CONFIG.PRG allocates an array of generic axes by the name Axes[], and sets all the existing axes in the system into this array.

NOTE-Info.svgNOTE
Since verison 0.4.15.3rc6 the global axis array systemAxis[] is introduced, and the array Axes[] is made redundant, therefore it is removed from CONFIG.PRG

EC_SETUP.PRG and AX_SETUP.PRG use this array to setup the system automatically.

IMPORTANT.svgIMPORTANT
It is critical to maintain the demonstrated order of the EtherCAT setup.
Any change in the given example may result in undefined behavior!

EC_SETUP.PRG

EC_SETUP.PRG is a generic script. Its purpose is to configure the EtherCAT master and slaves before they are started, start the master, and eventually run additional actions to complete the EtherCAT startup procedure.

EC_SETUP.PRG is written in a manner that easily allows embedding code to configure specific motion drives and IO modules.

This article details the main steps that occur upon EtherCAT startup as they are executed by EC_SETUP.PRG.

Drive Address

Each EtherCAT slave has an address. Currently this address is determined strictly according to the slave location in the physical topology of the system; that is, the first slave attached to the MC is assigned drive address 1, the second slave in the chain gets slave address 2, and so on.

An EtherCAT slave can be a motion drive, an IO module or a Gateway.

PRE-OP Mode

Before the master is started all the slaves are in PRE-OP mode. In this stage the master is created and the system gathers information from the slaves in order to create data structures that are used by the master to set up the EtherCAT communication.

First, differentiate between motion drives and IO modules. For each slave query the slave's Vendor ID and Product Code. This data can later be used to identify specific products and create specific configuration for them, as in the CDHD Configuration example.

	numOfSlaves = EC_ETHERCAT_INIT

Look for an unknown generic DS402 motion drive. If found, remap its PDOs to the required minimum.
You may update the following code by replacing the define GENERIC_DS402_DRIVE_VENDOR with your device's vendor ID, by doing so remapping its PDO's to the required minimum to create sync position motion:

	for drive_addr = 1 to numOfSlaves
		if ETSLAVES[drive_addr]->et_slavetype = ECAT_MOTIONSLAVE then
			if EC_SLAVES_INFO[drive_addr]->vendor_id = GENERIC_DS402_DRIVE_VENDOR then  '  replace with your product's vendor ID
				call EC_REMAP_MINIMUM_PDOS(drive_addr)
			end if
		end if
	next

Check the EtherCAT Topology for Wiring Errors

EtherCAT topology is sensitive to the direction of the wiring. Each EtherCAT slave has an INPUT connector and an OUTPUT connector.
The cable that "starts" from the EtherCAT master's OUTPUT must be connected to the INPUT of the first EtherCAT slave. A second cable will "exit" from the OUTPUT of the first slave and get connected to the INPUT of the second slave, etc...
'Miswiring' on most occasions means that somewhere in the topology the EtherCAT cable wiring got confused between the INPUT and the OUTPUT connectors.
This situation results UNDEFINED behavior, even up to making the wrong motor move, which is a safety issue.

IMPORTANT.svgIMPORTANT
If a miswiring is detected, an error will be thrown and EC_SETUP.PRG will stop running
	retVal = CHECK_TOPOLOGY

Create the EtherCAT Master.

	call EC_CREATE_MASTER

Set Motion Cycle Time: 4000, 2000, 1000, 500 or 250 [us]

	call EC_SET_BUS_CYCLETIME(4000)  '  for a cycle time of 500/250[us], add to FWCONFIG: hpetfreq = 2000


From here on EC_SETUP.PRG uses the gathered information to configure the slaves. A 'For Loop' goes over the slaves and tries to match them to already known products (such as the CDHD). When found, product specific functions are invoked to create data structures in the master that elaborate the PDO mapping of the slaves, be it a motion drive or an IO module. This is where you can add your own code to configure your own EtherCAT slave. Just add another case to match your Vendor ID.
You may use the already prepared GENERIC_DS402_DRIVE_VENDOR case.
Replace the define GENERIC_DS402_DRIVE_VENDOR with your device's vendor ID, and GENERIC_DS402_DRIVE_PRODUCT_ID with the device's product code:

      Case GENERIC_DS402_DRIVE_VENDOR  '  replace with your vendor id

        if EC_SLAVES_INFO[drive_addr]->product_code = GENERIC_DS402_DRIVE_PRODUCT_ID then  '  replace with your product id

          call EC_INSTALL_GENERIC_DRIVE(drive_addr, Counts_Per_Revolution)  '  Counts Per motor Revolution
          num_Of_Motion_Drives = num_Of_Motion_Drives + 1

        end if

If a Servotronix (STX) CDHD servo motion drive is found, the function EC_INSTALL_STX_CDHD is invoked. This function sets certain parameters in the drive, creates the PDO map of the CDHD, and queries the drive's PNUM and PDEN to allow calculation of the Position Factor.

For a generic drive, a minimum PDO mapping and default values are used.

The user can add his own code to EC_USER_PREOP_CONFIG to perform any specific configuration that must take place while the slaves are in PREOP mode.

After the slave configuration is done the master is started:

	' Create PDOs mapping, set bus cycle time, sync clocks between the master and the slaves,
	' raise slaves to OP-Mode and sets master's opmode to operational
	call EC_STARTMASTER  ' Syncs clocks between the master and the slaves, and sets master's opmode to operational

The master attempts to raise all the slaves to OP Mode. If it fails, the procedure is stopped and an error is issued. If it is successful, EtherCAT communication is now online and EC_SETUP.PRG starts the second stage of configuration.

OP Mode

Again, a For Loop goes over all the slaves. When a motion drive is encountered, EC_SETUP.PRG attaches its drive address to an axis and attempts to clear its faults. Again, the user can add his own code to EC_USER_SAFEOP_CONFIG and EC_USER_OP_CONFIG to perform any specific configuration that must take place while the slaves are in "SAFEOP" or "OP" mode.

	' SAFEOP state configuration - Add code to EC_USER_SAFEOP_CONFIG(byval drive_addr as long)
	retVal = EC_USER_SAFEOP_CONFIG(drive_addr)

	' OP state configuration - Add code to EC_USER_OP_CONFIG(byval drive_addr as long)
	retVal = EC_USER_OP_CONFIG(drive_addr)

	' Assign ECAT bus ID and slave address to an axis
	systemAxis(Axis_Attached_To_Drive).busnumber = ECAT_BUSID
	systemAxis(Axis_Attached_To_Drive).dadd = drive_addr

	' Attempt to clear faults in the drives
	Try

		call EC_CLEAR_FAULTS(drive_addr)

	Catch Else

		' if clear faults failed due to PLL Sync Error, wait a little longer and retry
		if EC_SDO_READ(drive_addr, 0x603f, 0) = 0x7386 then
			printu "PLL Error in drive #. Sleeping 5 seconds and retrying to clear fault";drive_addr
			sleep 5000
			call EC_CLEAR_FAULTS(drive_addr)
		end if

	End Try


All the motion drives are set to Synchronous Position Mode:

	' Set drives to sync position mode
	if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x6060, 0) then
		call EC_PDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8)
	else
		call EC_SDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8, 8)
	end if


See Also


This category currently contains no pages or media.