Difference between revisions of "Category:EtherCAT:EC SETUP"
Line 121: | Line 121: | ||
</pre> | </pre> | ||
− | The last thing done is | + | 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] | ||
+ | <br/> | ||
<pre> | <pre> | ||
' If mapped to PDO, set 0x60FD and 0x60FE as digital inputs/outputs | ' If mapped to PDO, set 0x60FD and 0x60FE as digital inputs/outputs | ||
Line 135: | Line 138: | ||
</pre> | </pre> | ||
− | + | ''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 association will be as follows:<br/> | ||
+ | The drive's digital inputs are set as follows:<br/> | ||
+ | Sys.Dout[300][6] = <6 bits value><br/> | ||
+ | The drive's digital inputs are read as follows:<br/> | ||
+ | ?Sys.Dout[300][11]<br/> | ||
+ | <br/> | ||
+ | |SEE ALSO= | ||
+ | * [[EtherCAT:EC ETHERCAT INIT|EC_ETHERCAT_INIT]] | ||
Revision as of 12:54, 6 October 2014
Category:EtherCAT:EC SETUP How to setup EtherCAT.
The front page is EtherCAT
Before starting to work with the softMC you must setup the EtherCAT master to work properly with the slaves.
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.
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 axis by the name Axes[], and sets all the existing axes in the system into this array.
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 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 written in a manner that easily allows embedding code to configure specific motion drives.
This article details the more important steps taken upon EtherCAT start up as they are carried out by EC_SETUP.PRG.
A word about drive address
Each EtherCAT slave has an address. At the moment this address is determined strictly according to the slave's location in the
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
slave address 2, etc. An EtherCAT slave can be a motion drive or an IO module.
PRE-OP stage
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.
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 CDHD example.
numOfSlaves = EC_ETHERCAT_INIT
Look for an unknown generic DS402 motion drive. If found, remap its PDO's to the required minimum.
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 call EC_REMAP_MINIMUM_PDOS(drive_addr) end if end if next
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 (as the CDHD). When found, product specific functions are invoked to create in the master data structures
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.
If an STX CDHD motion drive is found, the function EC_INSTALL_STX_CDHD is invoked. This function sets some 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. In case of a generic drive, a minimum PDO mapping and default values are used.
After the slave configuration is done a few more subroutines are called one after another to finish the master's preparation,
and the master is started:
call EC_ASSIGN_PDOS_AUTO ' After telling the master with which slaves we would like to work, we create the PDO map call EC_CREATE_PDOS_MAP call EC_SET_CYCLETIME ' Set EtherCAT cycle time ' Raise slaves to OP-Mode call EC_STARTMASTER ' sync 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 thrown. If it is successful EtherCAT communication is now online and EC_SETUP.PRG starts the second stage of configuration.
OP-Mode stage
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 attempts to clear its faults.
' Assign slave address to each axis Axes[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
The last thing done is creating an association between motion drive's digital inputs/outputs and system's digital inputs/outputs.
This association is done according to the drive address in the following manner:
Drive address x --> drive's digital inputs/outputs [1..y] --> system's digital inputs/outputs [100*x..100*x+y]
' 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
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.
The association will be as follows:
The drive's digital inputs are set as follows:
Sys.Dout[300][6] = <6 bits value>
The drive's digital inputs are read as follows:
?Sys.Dout[300][11]
This category currently contains no pages or media.