Hi, all

I use ethercat-1.5.2 and connect to HIWIN D2COE

When I execute my program, the terminal always show the slave state is:
0  0:0  PREOP  E  D2 CoE Drive

The main problem seems to be the "Invalid input configuration".

I think it's something wrong in PDO mapping, but i can't fix it.

Did anyone encounter this problem?

os is ubuntu10.04

driver is generic Ethernet driver


the "dmesg" shows that:


[25828.631083] EtherCAT WARNING 0-0: Slave does not support changing
the PDO mapping!
[25828.631085] EtherCAT WARNING 0-0: Currently mapped PDO entries:
(none). Entries to map: 0x6060:00/8 0x6040:00/16 0x60FF:00/32
0x6083:00/32 0x6084:00/32
[25828.883769] EtherCAT WARNING 0-0: Slave does not support changing
the PDO mapping!
[25828.883771] EtherCAT WARNING 0-0: Currently mapped PDO entries:
(none). Entries to map: 0x6041:00/16 0x60F4:00/32
[25829.147118] EtherCAT 0: Domain 0: Working counter changed to 2/3.
[25829.157863] EtherCAT ERROR 0-0: Failed to set SAFEOP state, slave
refused state change (PREOP + ERROR).
[25829.178418] EtherCAT ERROR 0-0: AL status message 0x001E: "Invalid
input configuration"

-----------------------------------------------------

And this is my code:

#include <errno.h> #include <signal.h> #include <stdio.h> #include
<string.h> #include <sys/resource.h> #include <sys/time.h> #include
<sys/types.h> #include <unistd.h>
/****************************************************************************/
#include "ecrt.h"
/****************************************************************************/
// Application parameters #define FREQUENCY 100 #define PRIORITY 1
/****************************************************************************/
// EtherCAT static ec_master_t *master = NULL; static ec_master_state_t
master_state = {}; static ec_domain_t *domainInput = NULL; static
ec_domain_state_t domainInput_state = {}; static ec_domain_t *domainOutput
= NULL; static ec_domain_state_t domainOutput_state = {}; static
ec_slave_config_t *sc_motor = NULL; static ec_slave_config_state_t
sc_motor_state = {}; // Timer static unsigned int sig_alarms = 0; static
unsigned int user_alarms = 0; static ec_sdo_request_t *sdo;
/****************************************************************************/
// process data static uint8_t *domainOutput_pd = NULL; static uint8_t
*domainInput_pd = NULL; #define MotorSlavePos 0, 0 #define HIWIN
0x0000AAAA, 0x00000003 // offsets for PDO entries static unsigned int
hiwin_cntlwd; static unsigned int hiwin_tarvel; static unsigned int
hiwin_tarpos; static unsigned int hiwin_provel; static unsigned int
hiwin_proacc; static unsigned int hiwin_prodec; static unsigned int
hiwin_maxvel; static unsigned int hiwin_maxspd; static unsigned int
hiwin_mottyp; static unsigned int hiwin_modeop; static unsigned int
hiwin_status; static unsigned int hiwin_actpos; static unsigned int
hiwin_actvel; static unsigned int hiwin_acttor; static unsigned int
hiwin_modedp; static unsigned int hiwin_fevalue; static unsigned int
hiwin_prodec; static unsigned int counter = 0; const static
ec_pdo_entry_reg_t domainOutput_regs[] = { { MotorSlavePos, HIWIN, 0x6060,
0, &hiwin_modeop }, { MotorSlavePos, HIWIN, 0x6040, 0, &hiwin_cntlwd }, {
MotorSlavePos, HIWIN, 0x60FF, 0, &hiwin_tarvel }, { MotorSlavePos, HIWIN,
0x6083, 0, &hiwin_proacc }, { MotorSlavePos, HIWIN, 0x6084, 0,
&hiwin_prodec }, { MotorSlavePos, HIWIN, 0x6041, 0, &hiwin_status }, {
MotorSlavePos, HIWIN, 0x60F4, 0, &hiwin_fevalue }, {} };
ec_pdo_entry_info_t slave_0_pdo_entries[] = { {0x6060, 0x00, 8}, {0x6040,
0x00, 16}, {0x60ff, 0x00, 32}, {0x6083, 0x00, 32}, {0x6084, 0x00, 32},
{0x6041, 0x00, 16}, {0x60f4, 0x00, 32}, }; ec_pdo_info_t slave_0_pdos[] = {
{0x1600, 5, slave_0_pdo_entries + 0}, {0x1a00, 2, slave_0_pdo_entries + 5},
}; ec_sync_info_t hiwin_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_ENABLE}, {3, EC_DIR_INPUT, 1,
slave_0_pdos + 1, EC_WD_DISABLE}, {0xff} };
/*****************************************************************************/
void check_domain_state(void) { ec_domain_state_t ds;
ecrt_domain_state(domainOutput, &ds); if (ds.working_counter !=
domainOutput_state.working_counter) printf("domainOutput: WC %u.\n",
ds.working_counter); if (ds.wc_state != domainOutput_state.wc_state)
printf("domainOutput: State %u.\n", ds.wc_state); domainOutput_state = ds;
}
/*****************************************************************************/
void check_master_state(void) { ec_master_state_t ms;
ecrt_master_state(master, &ms); if (ms.slaves_responding !=
master_state.slaves_responding) printf("%u slave(s).\n",
ms.slaves_responding); if (ms.al_states != master_state.al_states)
printf("AL states: 0x%02X.\n", ms.al_states); if (ms.link_up !=
master_state.link_up) printf("Link is %s.\n", ms.link_up ? "up" : "down");
master_state = ms; }
/*****************************************************************************/
void check_slave_config_states(void) { ec_slave_config_state_t s;
ecrt_slave_config_state(sc_motor, &s); if (s.al_state !=
sc_motor_state.al_state) printf("Motor: State 0x%02X.\n", s.al_state); if
(s.online != sc_motor_state.online) printf("Motor: %s.\n", s.online ?
"online" : "offline"); if (s.operational != sc_motor_state.operational)
printf("Motor: %soperational.\n", s.operational ? "" : "Not ");
sc_motor_state = s; }
/*****************************************************************************/
void cyclic_task() { // receive process data ecrt_master_receive(master);
ecrt_domain_process(domainOutput); check_domain_state(); if (counter) {
counter--; } else { // do this at 1 Hz counter = FREQUENCY; // check for
master state (optional) check_master_state(); // check for islave
configuration state(s) (optional) check_slave_config_states(); #if
SDO_ACCESS // read process data SDO read_sdo(); #endif } static int state =
-300; state++; switch (state){ case -1: printf("-1\n");
EC_WRITE_U16(domainOutput_pd + hiwin_cntlwd, 0x80); break; case 0:
printf("0\n"); EC_WRITE_S8(domainOutput_pd + hiwin_modeop, 3); case 3:
printf("3\n"); EC_WRITE_U16(domainOutput_pd + hiwin_cntlwd, 0x06); break;
case 4: printf("4\n"); EC_WRITE_U16(domainOutput_pd + hiwin_cntlwd, 0x07);
break; case 5: printf("5\n"); EC_WRITE_U16(domainOutput_pd + hiwin_cntlwd,
0xF); break; } if (state > 5) { EC_WRITE_U32(domainOutput_pd +
hiwin_prodec, 50); EC_WRITE_U32(domainOutput_pd + hiwin_proacc, 100);
EC_WRITE_U32(domainOutput_pd + hiwin_tarvel, 3200); } printf("state %d
status = 0x%02X.\n",state ,EC_READ_U16(domainOutput_pd + hiwin_status));
ecrt_domain_queue(domainOutput); ecrt_master_send(master); }
/****************************************************************************/
int main(int argc, char **argv) { // Requests an EtherCAT master for
realtime operation. master = ecrt_request_master(0); // Index of the master
to request. if (!master) return -1; // Creates a new process data domain
domainOutput = ecrt_master_create_domain(master); if (!domainOutput) return
-1; // Obtains a slave configuration if (!(sc_motor =
ecrt_master_slave_config(master, MotorSlavePos, HIWIN))) { fprintf(stderr,
"Failed to get slave configuration.\n"); return -1; }
ecrt_slave_config_sdo8(sc_motor, 0x1C12,0,0);
ecrt_slave_config_sdo8(sc_motor, 0x1600,0,0);
ecrt_slave_config_sdo8(sc_motor, 0x1600,1, 0x60600000);
ecrt_slave_config_sdo16(sc_motor, 0x1600,2, 0x60400010);
ecrt_slave_config_sdo32(sc_motor, 0x1600,3, 0x60FF0020);
ecrt_slave_config_sdo32(sc_motor, 0x1600,4, 0x60830020);
ecrt_slave_config_sdo32(sc_motor, 0x1600,5, 0x60840020);
ecrt_slave_config_sdo8(sc_motor, 0x1C12,0,5);
ecrt_slave_config_sdo16(sc_motor,0x1C12,1,0x1600);
ecrt_slave_config_sdo8(sc_motor, 0x1C13,0,0);
ecrt_slave_config_sdo8(sc_motor, 0x1A00,0,0);
ecrt_slave_config_sdo16(sc_motor, 0x1A00,1, 0x60410010);
ecrt_slave_config_sdo32(sc_motor, 0x1A00,2, 0x60F40020);
ecrt_slave_config_sdo8(sc_motor, 0x1C13,0,2);
ecrt_slave_config_sdo16(sc_motor,0x1C13,1,0x1A00);
printf("Configuring PDOs...\n"); if (ecrt_slave_config_pdos(sc_motor,
EC_END, hiwin_syncs)) { fprintf(stderr, "Failed to configure PDOs.\n");
return -1; } if (ecrt_domain_reg_pdo_entry_list(domainOutput,
domainOutput_regs)) { fprintf(stderr, "PDO entry registration failed!\n");
return -1; } printf("Activating master...\n"); if
(ecrt_master_activate(master)) return -1; if (!(domainOutput_pd =
ecrt_domain_data(domainOutput))) { return -1; } printf("Started.\n"); while
(1) { usleep(1000000 / FREQUENCY); cyclic_task(); } return 0; }
/****************************************************************************/


Thanks

Best regard, Young
_______________________________________________
etherlab-users mailing list
etherlab-users@etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users

Reply via email to