Difference between revisions of "Category:EtherCAT:EC SETUP"
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Languages|EtherCAT:EC_SETUP}} | ||
{{Category | {{Category | ||
|description=How to Set up EtherCAT. | |description=How to Set up EtherCAT. | ||
Line 4: | Line 5: | ||
==Introduction== | ==Introduction== | ||
− | Before starting to work with the softMC you must setup the EtherCAT master to work with the slaves.<br/> | + | 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. | 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. | ||
Line 10: | Line 11: | ||
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/> | 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/> | ||
+ | {{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 }} | ||
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. | ||
Line 26: | Line 28: | ||
[[: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. | [[: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. | ||
− | An EtherCAT slave can be a motion drive | + | An EtherCAT slave can be a motion drive, an IO module or a Gateway. |
==PRE-OP Mode == | ==PRE-OP Mode == | ||
Line 38: | Line 40: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | Look for an unknown generic DS402 motion drive. If found, remap its PDOs to the required minimum. | + | Look for an unknown generic DS402 motion drive. If found, remap its PDOs to the required minimum.<br/> |
+ | 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"> | <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 | ||
Line 49: | Line 52: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | ===Check the EtherCAT | + | ===Check the EtherCAT Topology for Wiring Errors=== |
− | EtherCAT topology is sensitive to the direction of the wiring. Each | + | 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 | + | 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/> | '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. | This situation results UNDEFINED behavior, even up to making the wrong motor move, which is a safety issue. | ||
Line 66: | Line 69: | ||
Set Motion Cycle Time: 4000, 2000, 1000, 500 or 250 [us] | Set Motion Cycle Time: 4000, 2000, 1000, 500 or 250 [us] | ||
<syntaxhighlight lang="vb"> | <syntaxhighlight lang="vb"> | ||
− | call EC_SET_BUS_CYCLETIME(4000) ' | + | call EC_SET_BUS_CYCLETIME(4000) ' for a cycle time of 500/250[us], add to FWCONFIG: hpetfreq = 2000 |
</syntaxhighlight> | </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 (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. | + | 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/> |
+ | You may use the already prepared GENERIC_DS402_DRIVE_VENDOR case.<br/> | ||
+ | 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: | ||
+ | |||
+ | <syntaxhighlight lang="vb"> | ||
+ | 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 | ||
+ | </syntaxhighlight> | ||
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]]. | 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]]. | ||
Line 77: | Line 93: | ||
For a generic drive, a minimum PDO mapping and default values are used. | For a generic drive, a minimum PDO mapping and default values are used. | ||
− | 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 | + | 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. |
− | After the slave configuration is done | + | After the slave configuration is done the master is started: |
− | |||
<syntaxhighlight lang="vb"> | <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 | call EC_STARTMASTER ' Syncs clocks between the master and the slaves, and sets master's opmode to operational | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 109: | Line 118: | ||
retVal = EC_USER_OP_CONFIG(drive_addr) | retVal = EC_USER_OP_CONFIG(drive_addr) | ||
− | ' Assign slave address to an axis | + | ' 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 147: | Line 157: | ||
* [[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 | + | * [[EtherCAT:EC GET BUS CYCLETIME|EC_GET_BUS_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]] |
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
Contents
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 | |
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 | |
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 | |
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
- EC_ETHERCAT_INIT
- EC_REMAP_MINIMUM_PDOS
- EC_CREATE_MASTER
- EC_SET_BUS_CYCLETIME
- EC_GET_BUS_CYCLETIME
- EC_STARTMASTER
- EC_CLEAR_FAULTS
- EC_SDO_READ
- EC_SDO_WRITE
- EC_PDO_READ
- EC_PDO_WRITE
- EC_IS_PDO
- EC_USER_PREOP_CONFIG
- EC_USER_SAFEOP_CONFIG
- EC_USER_OP_CONFIG
This category currently contains no pages or media.