IGH_ Summary of master master station configuration drive servo motor and frequency converter

Time:2021-11-22

IGH_ Summary of master master station configuration drive servo motor and frequency converter

EtherCAT is an industrial fieldbus protocol proposed by Beifu company, which has good real-time performance. Igh is an open source EtherCAT master station implementation protocol. This paper summarizes the use of IgH_ Experience of master driving servo motor and frequency converter

1、Ethercat_ Use of tools

Install the IgH_ After master, in/ethercat/igh/out/binFolder, use./ethercat --helpCommand can view the tools of EtherCAT. These tools can view various information of slave stations connected to the master station, which greatly facilitates the preparation of master station driver. The following describes the use of various parameters and commands, of which [] is a required parameter and < > is an optional parameter.

Set alias address

Command:ethercat alias [ OPTIONS ] < ALIAS >
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- force - F: match all slave stations;

example:
sudo ethercat alias --position 0 0x2000
Resolution: the alias of the corresponding slave station 0 on the bus (0 by default) is0x2000
Note: you must have a slave connection to use this command.

Display bus configuration

Command:ethercat config [ OPTIONS ]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- verbose - V: display details;

example:
sudo ethercat config -v
Resolution: displays the detailed configuration information of all slave stations.
Note: you must start the application to view using this command.

Output PDO information in C language

Note: the generated PDO information can be directly used by the application layerecrt_slave_config_pdos()Function call.
Command:ethercat cstruct [ OPTIONS ]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;

example:
sudo ethercat cstruct -a 100
Resolution: output the PDO information of the slave station with alias 100.
Note: you must have a slave connection to use this command.

Display process data

Description: output binary process data.
Command:ethercat data [ OPTIONS ]
Parameters:

*-- domain - D: the index value of the domain. If no parameter is filled in, all process data will be displayed.

example:
sudo ethercat data
Parse: displays all PDO process data.
Note: you must start the application to view using this command.

Set master debugging level

Note: set the debugging level of the master station, and the debugging information will be output in the/var/log/syslogFile.
Command:ethercat debug

There may be the following cases:

*0: no debugging information output
    *1: output some debugging information
    *2: output the contents of all frames (please use with caution due to the large amount of output information)

example:
sudo ethercat debug 1
Parsing: open some debugging information output

Configure domain

Description: displays information about the domain.
Command:ethercat domains [ OPTIONS ]
Parameters:

*-- domain - D: match the domain according to the index number;
*-- verbose -v: detailed information of display field (information of FMMU and process data);

example:
sudo ethercat domainsDisplay after execution

Domain0:LogBaseAddr 0x00000000, Size 12, WorkingCounter 0/3

Meanings of the above fields:

*Logbaseaddr: logical base address of logical addressing;
*Size: number of bytes of domain exchange data;
*Workingcounter: the first number is the current value of WKC, and the second number is the expected value of WKC;

Resolve: displays the basic information of the domain.

sudo ethercat domains -vDisplay after execution

Domain0:LogBaseAddr 0x00000000, Size 12, WorkingCounter 3/3
    SlaveConfig 0:0, SM2 (Output), LogAddr 0x00000000, Size 6 06 00 9d aa 00 00
    SlaveConfig 0:0, SM3 (Input), LogAddr 0x00000000, Size 6 31 0a 9d aa 00 00

Meanings of the above fields:
*Slaveconfig: slave configuration information, mainly including alias and address (absolute address or relative address);
*SM2: synchronization manager 2;
*Logaddr: address of FMMU mapping;
*Size: the size of the mapping address;
*Data bit: process data displayed in hexadecimal;

Analysis: displays the detailed information of the domain (information of FMMU and process data).
Note: you must start the application to view using this command.

Write SDO

Note: write a PDO entry to the slave station.
Command:ethercat download [ OPTIONS ]

Parameters:
(1) optional parameters:

*Index: 16 bit unsigned integer SDO index;
*Subindex: 8-bit unsigned integer SDO sub index;
*Value: the value of the SDO to be written

(2) parameters of [options]:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- type - t: data type of SDO entry;

Type available types are:

bool、int8、int16、int32、int64、uint8、uint16、uint32、uint64、float、double、string、octet_string、unicode_string

For sign and magnet coding:
sm8、sm16、sm32、sm64

example:

sudo ethercat download -t int16 -p 0 0x6060 00 08
Parsing: write PDO entry value "0x08" to the address with index number 0x6060 (16 bits) and sub index number 00 (8 bits) of slave station 0;

Read SDO

Description: read an SDO entry from the slave station.
Command:ethercat upload [ OPTIONS ]
Parameters:
(1) optional parameters:

*Index: 16 bit unsigned integer SDO index;
*Subindex: 8-bit unsigned integer SDO sub index;

(2) parameters of [options]:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- type - t: data type of SDO entry;

Type available types are:

bool、int8、int16、int32、int64、uint8、uint16、uint32、uint64、float、double、string、octet_string、unicode_string

For sign and magnet coding:
sm8、sm16、sm32、sm64

example:

sudo ethercat upload -t int16 -p 0 0x6060 00
Parsing: read the SDO entry with index number 0x6060 (16 bits) and sub index number 00 (8 bits) in slave station 0.

Note: you must have a slave connection to use this command.

Create a topology graph

Description: output bus topology.
Command:ethercat graph [ OPTIONS ]

example:
sudo ethercat graph | dot -Tsvg > ~/Desktop/bus.svg
Analysis: output the bus topology diagram to the desktop.

Master station and Ethernet equipment

Description: display the information of master station and Ethernet equipment.
Command:ethercat master [ OPTIONS ]
Parameters:

*-- Master - M: indexes is the index of the master station. All equipment information is displayed by default;

example:

sudo ethercat master

Analysis: display the device information of all hosts (sending frame, receiving frame, reference clock and application time).

Note: to display the application time, you need to start the application.

Synchronization management, PDOS, PDO entries

Description: displays the parameters of synchronization manager and PDO task and mapping information.
Command:ethercat pdos [OPTIONS]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- skin - s: "skin" can select "default" and "etherlab";

example:

Sudo EtherCAT PDOS - P 0 - s default displays after execution:

SM2:PhysAddr 0x1400, DefaultSize 64, ControlRegister 0x34, Enable 1
    RxPDO 0x1600 "Receive PDO1 Mapping"
        PDO entry 0x6040:00, 16 bit, " "
        PDO entry 0x607a:00, 32 bit, " "

Meanings of the above fields:
(1) synchronization manager information
*SM2: synchronization manager 2;
*Physaddr: physical address start address;
*Defaultsize: default data size;
*Controlregister: control register;
*Enable: enable word

(2) display PDO direction, index value and PDO name
*Rxpdo: represents the direction of sending data from the slave station (receiving data from the slave station);
*0x1600: index value of PDO;
*"Receive pdo1 mapping": the name of the PDO;

⑶ display the index and sub index of PDO entry (both in hexadecimal form), display bit width and description
*0x6040:00: indicates index and sub index;
*16bit: indicates the bit width of the entry;
*"": indicates the description of this bit;

Register access

Gets the contents of the corresponding slave register

Command:ethercat reg_read [ OPTIONS ] [ SIZE ]
Parameters:
① Optional parameters

*Address: 16 bit unsigned register address;
*Size: number of corresponding register bytes to be read (16 bit unsigned value); [size] + address cannot exceed 64K. If the type parameter implies the number of bytes to be read, the [size] parameter can be ignored;

② [options] parameter

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- type - t: matching data type;

Type available types are:

bool、int8、int16、int32、int64、uint8、uint16、uint32、uint64、float、double、string、octet_string、unicode_string

For sign and magnet coding:
sm8、sm16、sm32、sm64

example:

sudo ethercat reg_read -p 6 -t sm32 0x092c

Parsing: get the value stored in 0x092c register of slave station 6.

Writes the contents to the specified slave register

Command:ethercat reg_write [ OPTIONS ]
Parameters:
① Optional parameters

*Address: 16 bit unsigned register address;
*Data: data to be written to the register; If the "type" data type is specified, "data" parses the data according to the specified data type; If the "type" data type is not specified, "data" can be the specified file or set "data" to "-", indicating that data is obtained from standard input;

② [options] parameter

*-- alias - A: match the alias of the slave station;
*-- position - P: matches the absolute address of the slave station;
*-- type - t: matching data type;
*-- emergency - E: request to write files in an emergency manner;

example:

sudo ethercat reg_write -p 5 -t sm32 0x092c 200

Analysis: write data 200 to register 0x092c of slave station 5.

SDO dictionary

Description: lists the SDO Dictionary (SDO information and SDO entry information).
Command:ethercat sdos [ OPTIONS ]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: match the absolute position of the slave station;
*-- quiet - Q: output only PDOS, not PDO entry information;

example:

Sudo EtherCAT SDOs is displayed after execution

SDO 0x1000,"Device type"
    0x1000:0, r-r-r-, uint32, 32 bit, "Device type"

SDOs:SDO 0x1000,”Device type”
*0x1000: SDO index value;
*"Device type": SDO name;

SDO entry: 0x1000:0, r-r-r -, uint32, 32 bit, "device type"
*0x1000:0: index value and sub index value;
*R-r-r -: indicates access permission;
*Uint32: indicates the data type of the entry;
*32bit: indicates the bit width of the entry;
*"Device type": description of the item;

Display information of slave station

Description: displays the information of the slave station on the bus.
Command:ethercat slaves [ OPTIONS ]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: matches the absolute address of the slave station;
*-- verbose - V: display the details of the slave station;

example:

sudo ethercat slaves -v

Resolution: displays the details of all slave stations.

Generate slave configuration description

Description: generate slave information description file.
Command:ethercat xml [ OPTIONS ]
Parameters:

*-- alias - A: match the alias of the slave station;
*-- position - P: matches the absolute address of the slave station;

example:

sudo ethercat xml -p 0

Parsing: generate and display the slave information description file of slave 0.

I refer to the contents of this sectionFamine awarenessofUse of command line tools for EtherCAT parsing (12)This article only lists the tools needed to configure servo and frequency conversion. For more tools, please move to the author’s original text. Thank youFamine awarenessSharing

2. Key points of master station configuration

Application program is a control program module written by users according to the control requirements of their own control system, which runs in the kernel layer. It includes the configuration of master station and slave station and the tasks of periodic real-time operation. The communication between master and slave stations and various NC algorithms are realized in the real-time task program. It mainly includes two parts:

  • Configuration of master station and slave station;
  • Implementation of periodic tasks;

Start with the above figure:
主站配置流程

The configuration process of master station, slave station and data domain is as follows

  • Request EtherCAT master station for real-time operation and call EcRT_ request_ Master(), get the pointer EC of the master station_ master_ t *;

    master = ecrt_request_master(0)
  • Create a new process data field and call EcRT_ master_ create_ Domain(), get a data domain pointer EC of the master_ domain_ t *;

    domain1 = ecrt_master_create_domain(master)
  • Get the slave configuration and call EcRT_ master_ slave_ Config() generates the slave configuration information SC by inputting the master pointer, slave alias, slave location, slave manufacturer ID and slave product number_ ana_ In and obtain the slave configuration pointer EC_ slave_ config_ t *;

    sc_ ana_ in = ecrt_ master_ slave_ Config ('master pointer ',' configuration information ',' slave information ')
  • Call EcRT_ slave_ config_ PDOS (), define a complete PDO configuration by inputting slave configuration information and slave synchronization management information;

    ecrt_ slave_ config_ PDOS ('slave configuration pointer ', ec_end,' slave synchronization management information ')
  • *Call EcRT_ slave_ config_ create_ sdo_ Request(), obtain the SDO request pointer by inputting the slave configuration information, SDO index number, sub index number and data length, so as to create a complete SDO request and exchange SDO data for real-time operation;

    sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2)
  • *Call EcRT_ sdo_ request_ Timeout(), set the maximum timeout of SDO request

    ecrt_sdo_request_timeout(sdo, 500); // ms
  • Call EcRT_ domain_ reg_ pdo_ entry_ List() registers a series of PDO entries for the data domain by entering the data domain pointer and the registration information of the slave PDO entry

    ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)
  • Call EcRT_ master_ Activate() to complete this configuration phase and prepare to enter the real-time cycle task cycle:

    ecrt_master_activate(master)
  • Call EcRT_ domain_ Data() returns the process data pointer of the data field, assigns an address to the data field pointer, and prepares to access the data field in real time

    domain1_pd = ecrt_domain_data(domain1)
  • End the configuration, create a real-time timer and execute the periodic task function cyclic_ task

Periodic task function_ task

  • The master station obtains the data frame from the device and processes the message

    // receive process data
      ecrt_master_receive(master);
  • Judge the status of data field message

    ecrt_domain_process(domain1);
  • Judge whether the data field, master station and slave station have changed, and prompt the information if there is any change

    // check process data state (optional)
      check_domain1_state();
    
      // check for master state (optional)
      check_master_state();
      // check for islave configuration state(s) (optional)
      check_slave_config_states();
  • Reading and writing process data correlation function

    EC_ READ_ U16 ("data field pointer + address offset")
      EC_ WRITE_ U16 ("data field pointer + address offset")
  • Insert all messages in the data field into the message sequence of the master station

    // send process data
      ecrt_domain_queue(domain1);
  • Send all messages from the master station to the transmission sequence

    ecrt_master_send(master)

This section mainly refers to igh software code description. Thanks for not finding the source!

3. Key points of servo motor configuration

This time, we use Delta’s servo motor, model asda-a2-e, and use CANopen to control the servo motor based on ds402 protocol. The specific process is as follows:

1. Useethercat slaves [ OPTIONS ]The command reads the list of slave stations to ensure that the slave station is normally connected to the master station

0  15:0  PREOP  +  Delta ASDA-A2-E EtherCAT(CoE) Drive Rev4
1   1:0  PREOP  +  EK1100 EtherCAT Coupler (2A E-Bus)
2   2:0  PREOP  +  EL1809 16K. Dig. Eingang 24V, 3ms

Resolution:
    The first column is the absolute position of the slave station relative to the master station. You can use this absolute position to read the slave station configuration. After some command options, you can add an option such as' - p 1 'to read the information of slave station 1. Of course, it can also be used  
    ethercat alias [ OPTIONS ] < ALIAS >  
    Set an alias for the slave station, and then use '- a' to access the specified slave station;
    
    There will be the model of the slave station equipment later to help determine whether the master station is successfully connected as we expect;

2. Usesudo ethercat slaves -v -p 0All current information of slave station 0 can be output

===Master 0, slave 0 = = // master and slave station numbers
Alias: 15 // alias
Device: Main
State: prep // state
Flag: +
Identity:
Vendor Id:       0x000001dd
Product Code: 0x10305070 // product ID and number
Revision number: 0x02040608
Serial number:   0x00000000
DL information:
FMMU bit operation: no
Distributed clocks: yes, 32 bit
DC system time transmission delay: 0 ns
Port  Type  Link  Loop    Signal  NextSlave  RxTime [ns]  Diff [ns]   NextDc [ns]
0  MII   up    open    yes             -    488154000           0           0
1  MII   up    open    yes             1    488158324        4324         641
2  N/A   down  closed  no              -            -           -           -
3  N/A   down  closed  no              -            -           -           -
Mailboxes:
Bootstrap RX: 0x0000/0, TX: 0x0000/0
Standard  RX: 0x1000/128, TX: 0x10c0/128
Supported protocols: CoE
General:
Group: ServoDrive
Image name: 
Order number: 
Device name: Delta asda-a2-e EtherCAT (COE) drive rev4 // device model
Coe details: // setting information
    Enable SDO: yes
    Enable SDO Info: yes
    Enable PDO Assign: yes
    Enable PDO Configuration: yes
    Enable Upload at startup: no
    Enable SDO complete access: no
Flags: // status information
    Enable SafeOp: no
    Enable notLRW: no
Current consumption: 0 mA


Through this information, we can judge the current status and operability of the slave station;

Vendor Id:       0x000001dd
Product code:    0x10305070
This is the information of the slave station, which can be used to determine the target slave station, so a device can be established first:

    #define asda_Pos0 0, 0
    #define asda 0x000001dd, 0x10305070

3. Now we need to establish the slave configuration pointer in the program:

static ec_slave_config_t *sc_asda;
static ec_slave_config_state_t sc_asda_state;

Also, useethercat xml -p 0Command, we can view the device description file:

//Slave station 0

    477


    
    
        
        
        
        
        
        
        /*
            The device has four synchronous management channels:
                ·The first two are mailbox Mbox transmission mode, which is used for COE protocol communication and is responsible for SDO transmission;
                ·The latter two are process data transmission modes, which are responsible for PDO transmission;
            Of which:
            The startaddress parameter is the physical starting address, that is, the starting address of the synchronization management channel on the dual port RAM;
            The controlbyte parameter is a control word, which contains the transmission mode, transmission direction and other information of the channel;
            Minsize, maxsize and defaultsize specify the size of the channel.  
        */
        
        
        #X1600 // rxpdo address
        Rxpdo // receive (slave) PDO
        
            #x6040
            0 // index number is 0
            16 // the size of bytes determines the EC you want to use_ WRITE_ U16 write
            
            UINT16
        
        
            #x607a
            0
            32
            
            UINT32
        
        
            #x6060
            0
            8
            
            UINT8
        
        
        
        #X1a00 // txpdo address
        Txpdo // send (to the master station) PDO
        
            #x6041
            0
            16 // the size of bytes determines the EC you want to use_ READ_ U16 read
            
            UINT16
        
        
            #x6064
            0
            32
            
            UINT32
        
        
            #x6061
            0
            8
            
            UINT8
        
        
            #x603f
            0
            16
            
            UINT16

4. Useethercat cstruct -p 0Command to get the C language PDO information automatically generated by EtherCAT master station, which can be pasted directly into the program;

/* Master 0, Slave 0
* Vendor ID:       0x000001dd
* Product code:    0x10305070
* Revision number: 0x02040608
*/

ec_pdo_entry_info_t slave_0_pdo_entries[] = {
    {0x6040, 0x00, 16}, // ds402 operation word
    {0x607a, 0x00, 32},
    {0x6060, 0x00, 8},
    {0x6041, 0x00, 16}, // ds402 status word
    {0x6064, 0x00, 32},
    {0x6061, 0x00, 8},
    {0x603f, 0x00, 16},
};

ec_pdo_info_t slave_0_pdos[] = {
    {0x1600, 3, slave_0_pdo_entries + 0}, /* RxPDO */
    {0x1a00, 4, slave_0_pdo_entries + 3}, /* TxPDO */
};

ec_sync_info_t slave_0_syncs[] = {
    {0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
    {1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
    {2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_DISABLE},
    {3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE},
    {0xff}
};

After carefully observing the generated PDO information, I found that:
Step 1: Slave_ 0_ pdo_ Entries [] creates an operation array;
Step 2: in slave_ 0_ In PDOS [], according to the XML information obtained earlier, the slave_ 0_ pdo_ The three addresses from position 0 (slave_0_pdo_entries + 0) in entries [] correspond to the servo driver rxpdo address - > 0x1600;
slave_ 0_ pdo_ The four addresses from position 3 (slave_0_pdo_entries + 3) in entries [] correspond to the servo driver txpdo address - > 0x1a00;
Step 3: save PDO information_ 0_ PDOS [] corresponds to the synchronization information slave_ 0_ Syncs []:
slave_ 0_ PDOS + 0 is {0x1600, 3, slave_0_pdo_entries + 0}, / * rxpdo * /, and the direction is output
slave_ 0_ PDOS + 1 is {0x1a00, 4, slave_0_pdo_entries + 3}, / * txpdo * /, and the direction is input

    The application writes the above synchronization management information to the data structure EC_ sync_ info_ In T, as
ecrt_ slave_ config_ PDOS (), and finally complete the complete PDO configuration by calling this function.

    This is my personal understanding. If you have any questions, please point them out;

5. Obtain the slave configuration and call EcRT_ master_ slave_ Config(), the slave configuration information SC is generated by inputting the master pointer, the slave alias / slave location / slave manufacturer ID and slave product number_ ana_ In and obtain the slave configuration pointer EC_ slave_ config_ t *;

ecrt_master_slave_config(master, asda_Pos0, asda);

6. Call EcRT_ slave_ config_ PDOS (), define a complete PDO configuration by inputting the slave configuration pointer and slave synchronization management information;

ecrt_slave_config_pdos(sc_asda, EC_END, asda_syncs);

Parameters:
1 - > slave pointer;
2->EC_ End (check the library file and find - > #define ec_end ~ 0U. The comment says: / * * end of list marker, which is a fixed format and should have other parameters, but it is not used and has not been studied in depth at present);
3 - > synchronization information

7. Call EcRT_ domain_ reg_ pdo_ entry_ List() registers a series of PDO entries for the data domain by entering the data domain pointer and the registration information of the slave PDO entry

domainServoOutput = ecrt_master_create_domain(master);
domainServoInput = ecrt_master_create_domain(master);
//By EcRT_ master_ create_ Domain ("master pointer") creates a new data field

static unsigned int cntlwd;                     // Control word
static unsigned int ipData;                     // Target location
static unsigned int status|;                     // Status word
static unsigned int actpos|;                     // Current feedback location
static unsigned int modes_of_operation|;         //6060
static unsigned int modes_of_operation_display|; //6061
static unsigned int errcode;                    // error code 
//Define slave information receiving variables

ec_pdo_entry_reg_t domainServoOutput_regs[] = {
{asda_Pos0, asda, 0x6040, 0x00, &cntlwd, NULL},
{asda_Pos0, asda, 0x607a, 0x00, &ipData, NULL},
{asda_Pos0, asda, 0x6060, 0x00, &modes_of_operation[0], NULL},
{}};
//For write operation status word registration, take the first article as an example. The parameters required for each article are:
    asda_ Pos0 master / slave station number
    Asda slave information
    0x6040 PDO address
    0x00 offset address
    &Cntlwd slave information variable
    NULL 

    
ec_pdo_entry_reg_t domainServoInput_regs[] = {
{asda_Pos0, asda, 0x6064, 0x00, &actpos, NULL},
{asda_Pos0, asda, 0x6041, 0x00, &status, NULL},
{asda_Pos0, asda, 0x6061, 0x00, &modes_of_operation_display[0], NULL},
{asda_Pos0, asda, 0x603f, 0x00, &errcode, NULL},
{}};
                    //Read operation status word registration

ecrt_domain_reg_pdo_entry_list(domainServoOutput, domainServoOutput_regs)
ecrt_domain_reg_pdo_entry_list(domainServoInput, domainServoInput_regs)
//Parameters are: data field pointer, PDO entry registration information list

//Here, the output PDO and input PDO are separated into two domains, which are registered as domainservooutput and domainservoinput respectively to facilitate reading and writing operations;

static uint8_t *domainOutput_pd = NULL;
static uint8_ t *domainInput_ pd = NULL;      // Define data field pointer

domainOutput_pd = ecrt_domain_data(domainServoOutput)
domainInput_pd = ecrt_domain_data(domainServoInput)
//Call EcRT_ domain_ Data(), get the process data pointer of the data field, assign an address to the data field pointer, and prepare to access the data field in real time

//The data field is the mapping of EtherCAT process data (PDO) to the data structure in the program. It provides the entry for the user program to access the data of each slave station on the bus. After the slave PDO entry is registered successfully, different slave stations will obtain their own address offset. The user can read and write the required PDO through the method of "data field process data pointer + address offset".

//When reading and writing, the PDO is operated by using the respective data field process data pointer + offset address (e.g. cntlwd, errCode)

Example:
    EC_READ_U16(domainInput_pd + status);

8. Here, the PDO configuration is completed. Next, read and write the corresponding bytes in the PDO mapping table according to the instruction manual of the servo motor

The functions used to read and write addresses in PDO are:

EC_ READ_ U16 ("data field pointer + address offset")
EC_ WRITE_ U16 ("data field pointer + address offset")

U32, U16 and U8 are the byte width to be read, EC_ READ_ U8 () reads data with a width of 8 bits
Example:
    EC_READ_U16(domainInput_pd + Status)
    domainInput_ PD is the process data pointer of the data field, and status is the address offset

According to the manual, the driver must guide the servo driver according to the process specified in the standard ds402 protocol before the servo driver can run in the specified state. The specific process is as follows:

台达伺服驱动流程

Description of each status:

initialization Drive initialization and internal self-test have been completed. The parameters of the drive cannot be set and the drive function cannot be performed.
Servo no fault The servo driver has no faults or errors, which have been eliminated. Drive parameters can be set
Servo ready The servo drive is ready. Drive parameters can be set.
Wait to turn on the servo enable The servo driver waits to turn on the servo enable. Drive parameters can be set.
Servo operation The driver operates normally, a servo operation mode has been enabled, the motor has been powered on, and the motor rotates when the command is not 0. If the drive parameter attribute is “run change”, it can be set, and others cannot be set.
fast stop The quick stop function is activated and the drive is performing the quick stop function. If the drive parameter attribute is “run change”, it can be set, and others cannot be set.
Fault shutdown The drive has failed and is in the process of performing a fault shutdown. If the drive parameter attribute is “run change”, it can be set, and others cannot be set.
fault When the fault shutdown is completed, all drive functions are disabled and the drive parameters are allowed to be changed in order to troubleshoot.

6040状态字

The starting process is: write 6-7-15 to 6040pdo in sequence (write it in sequence according to the feedback signal of 6041 status word. Practice shows that it is not recommended to check the status directly by byte, but simply check the status by bit, because normal changes of other bits may lead to different bytes. It is recommended to judge the status of bits directly)

(EC_READ_U16(domainInput_pd + status[i]) & 0x031) == 49
Serial number describe 6040 control word 6041 bit status
2 Servo no fault servo ready 0x0006 0010 0011 0001(b)
3 The servo is ready to wait for the servo enable to be turned on 0x0007 0010 0011 0011(b)
4 Wait for the servo to turn on to enable servo operation 0x000F 0100 0011 0011(b)

The sample program is as follows:

if ((cur_status[i] & 0x0250) == 592)
{
    printf("*********************Servo Power on*********************\n");
    EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x06);
}
if ((cur_status[i] & 0x031) == 49)
            {
                if ((cur_status[i] & 0x033) == 51)
                {
                    if ((cur_status[i] & 0x0433) == 1075)
                    {
                        EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x1f);

                    }
                    else
                    {
                        printf("*********************Servo Waitting*********************\n");
                        EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x0f);
                    }

                }
                else
                {
                    printf("*********************Servo Enable*********************\n");
                    EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x07);
                }    
            }
        }

Description of each bit of 6040 control word register

6040操作字

6041 description of each bit of status word register
6041操作字

The content of this section refers toYan Jun blogofSwitching steps of Huichuan is620n servo cia402 state machine – description of 6040 control word and 6041 state wordThanks for this article!

9. So far, the configuration of servo motor has been basically completed, but during the actual test, we found that:

  • When the program does not end normally (manual Ctrl + C is closed), or the motor does not enter the waiting state after the program ends, and the operation is carried out later, the motor will not respond (unless the power is cut off and the servo motor is powered on again). This is because the motor produces a fault, that is, the position 3 of 6041h status word will be 1. In this case, the motor will not work, At this time, we need to clear the fault, that is, for position 1 of No. 7 in 6040h, and then enable it again, so that the motor will enter normal operation;

    cur_status = EC_READ_U16(domainInput_pd + status);
      if (EC_READ_U16(domainInput_pd + errcode) != 0 || (cur_status & 0x0008))
      {
          printf("Error Capture:servo %d error\n", i);
    
          for (int i = 0; i < drive_count; i++)
          {
              if (EC_READ_U16(domainInput_pd + errcode[i]) != 0 || (cur_status[i] & 0x0008))
              {
                  EC_WRITE_U16(domainOutput_pd + cntlwd[i], (EC_READ_U16(domainOutput_pd + cntlwd[i]) | 0x0080));
              }
              else
              {
                  EC_WRITE_U16(domainOutput_pd + cntlwd[i], (EC_READ_U16(domainOutput_pd + cntlwd[i]) & 0xff7f));
              }
          }
    
          if ((cur_status[i] & 0x031) == 49)
          {
              if ((cur_status[i] & 0x033) == 51)
              {
                  if ((cur_status[i] & 0x0433) == 1075)
                  {
                      EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x1f);
    
                  }
                  else
                  {
                      printf("33\n");
                      EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x0f);
                  }
              }
              else
              {
                  printf("31\n");
                  EC_WRITE_U16(domainOutput_pd + cntlwd[i], 0x07);
              }
          }
          printf("Error Solved!!!!\n");
      }

4. Key points of frequency converter drive configuration

This time we use Omron’s 3g3mx2 frequency converter with ECT EtherCAT option as the slave station

变频器配置

1. Hardware settings: A001 and a002 need to be set in hardware to ensure normal communication. The specific contents are as follows:

A001 = 04 frequency given selection, 04 = option
A002 = 04 operation command selection, 04 = option
A003 = 50 reference frequency = 50Hz, motor rated frequency
A004 = 60Hz maximum frequency = 60Hz
A044 = 00 control mode, 00 = constant torque
A061 = 60Hz upper frequency limit
A062 = 0Hz lower frequency limit
F002 = 2 acceleration time, 2S
F003 = 2 deceleration time, 2S
F004 = 00 running direction, 00 = forward, 01 = reverse
H003 = 0.55 motor capacity = 0.55kw

2. PDO configuration:

Command (5000h) controls start stop and forward and reverse rotation
Frequency reference (5010h)

Status (5100h) operation status of frequency converter
Output frequency monitor (5110h)

3. Meaning of operation word and status word bit

5000h: motor start, forward and reverse rotation, reset
5000h

5010h: for frequency setting, directly give a hex value

5100h: inverter status feedback
5100h

5110h: frequency feedback of frequency converter – > hex value

4. Attention!!

  • Frequency converter operation sequence: 5000h = 0x0 – > 5010h = ‘frequency hexadecimal’ – > 5000h = 0x1

That is, you must first set the command word to 0, then the frequency, and finally set the command word to 1 to start

EC_WRITE_U16(domainOutput_pd + ECT_Command, 0);
EC_WRITE_U16(domainOutput_pd + ECT_Frequency, ECTFrequency);
EC_WRITE_U16(domainOutput_pd + ECT_Command, 0x1);
  • Like the server, if the frequency converter is shut down before the program runs normally, it will produce a fault. The third digit of 5100h will be 1. At this time, it is also necessary to clear the error. Compared with the frequency converter, it is easier to clear the error. Just turn the 7th position of the frequency converter to 1, and then operate normally;

    if (EC_READ_U16(domainInput_pd + ECT_Status) & 0x8)
      {
          EC_WRITE_U16(domainOutput_pd + ECT_Command, 0x80);
      }

The above is igh_ Master application drives the operation steps and possible problems of servo and frequency converter. When designing and operating in the industrial field, the equipment manual must be the top priority, or you should read the manual more.

This article refers to a lot of online materials and marks the main references. Some may not be marked. Thank you!