/x86_64: char-1byte,int-4bytes,long-8bytes/
struct IS620N_offset {
//RxPDO
unsigned int control_word; //0x6040:控制字,subindex:0,bitlen:16
unsigned int target_position;//0x607A:目标位置,subindex:0,bitlen:32
unsigned int touch_probe; //0x60B8:探针,subindex:0,bitlen:16
unsigned int pysical_outputs;//0x60FE:pysical_outputs,subindex:1,bitlen:32
unsigned int target_velocity;//0x60FF:target_velocity,subindex:0,bitlen:32
unsigned int target_torque;//0x6071:int target_torque,subindex:0,bitlen:16
unsigned int modes_operation;//0x6060:Modes of operation,subindex:0,bitlen:8
unsigned int max_profile_velocity;//0x607F:max_profile_velocity,subindex:0,bitlen:32
unsigned int positive_torque_limit_value;//0x60E0:positive_torque_limit_value,subindex:0,bitlen:16
unsigned int negative_torque_limit_value;//0x60E1:negaitive_torque_limit_value,subindex:0,bitlen:16
unsigned int torque_offset;//0x60B2:torque offset,subindex:0,bitlen:16
//TxPDo
unsigned int status_word;//0x6041:status_word,subindex:0,bitlen:16
unsigned int position_actual_value;//0x6064:position_actual_value,subindex:0,bitlen:32
unsigned int touch_probe_status;//0x60B9,subindex:0,bitlen:16
unsigned int touch_probe_pos1_pos_value;//0x60BA,subindex:0,bitlen:32
unsigned int touch_probe_pos2_pos_value;//0x60BC ,subindex:0,bitlen:32
unsigned int error_code;//0x603F,subindex:0,bitlen:16
unsigned int digital_inputs;//0x60FD,subindex:0,bitlen:32
unsigned int torque_actual_value;//0x6077,subindex:0,bitlen:16
unsigned int following_error_actual_value;//0x60F4,subindex:0,bitlen:32
unsigned int modes_of_operation_display;//0x6061,subindex:0,bitlen:8
unsigned int velocity_actual_value;//0x606C,subindex:0,bitlen:32
};
the code below can not controll the INOVANCE IS620N and panasonic Minas A6B,can someone help me?
/*****
include
include
include
include
include <sys/resource.h>
include <sys/time.h>
include <sys/types.h>
include
include <sys/mman.h>
/****/
include "ecrt.h"
/****/
define SERVO_STAT_SWION_DIS 0x250 /switched on disabled/
define SERVO_STAT_RDY_SWION 0x231 /ready to switch on/
define SERVO_STAT_SWION_ENA 0x233 /switch on enabled/
define SERVO_STAT_OP_ENA 0x237 /operation enable/
define SERVO_STAT_ERROR 0x218 /error/
/Application Parameters/
define TASK_FREQUENCY 100 /Hz/
define TIMOUT_CLEAR_ERROR (1TASK_FREQUENCY) /clearing error timeout*/
define TARGET_VELOCITY 10241024 //8388608 /target velocity*/
define PROFILE_VELOCITY 3 /Operation mode for 0x6060:0/
/*****/
/EtherCAT/ static ec_master_t *master = NULL; static ec_master_state_t master_state = {};
static ec_domain_t *domain1 = NULL; static ec_domain_state_t domain1_state = {};
static ec_slave_config_t *sc_IS620N; static ec_slave_config_state_t sc_IS620N_state = {};
/****/
/Process Data/ static uint8_t *domain1_pd = NULL;
define IS620NSlavePos 0,0 /EtherCAT address on the bus/
define INOVANCE_IS620N 0x00100000, 0x000C0108 /IS620N Vendor ID, product code/
/x86_64: char-1byte,int-4bytes,long-8bytes/ struct IS620N_offset { //RxPDO unsigned int control_word; //0x6040:控制字,subindex:0,bitlen:16 unsigned int target_position;//0x607A:目标位置,subindex:0,bitlen:32 unsigned int touch_probe; //0x60B8:探针,subindex:0,bitlen:16 unsigned int pysical_outputs;//0x60FE:pysical_outputs,subindex:1,bitlen:32 unsigned int target_velocity;//0x60FF:target_velocity,subindex:0,bitlen:32 unsigned int target_torque;//0x6071:int target_torque,subindex:0,bitlen:16 unsigned int modes_operation;//0x6060:Modes of operation,subindex:0,bitlen:8 unsigned int max_profile_velocity;//0x607F:max_profile_velocity,subindex:0,bitlen:32 unsigned int positive_torque_limit_value;//0x60E0:positive_torque_limit_value,subindex:0,bitlen:16 unsigned int negative_torque_limit_value;//0x60E1:negaitive_torque_limit_value,subindex:0,bitlen:16 unsigned int torque_offset;//0x60B2:torque offset,subindex:0,bitlen:16
//TxPDo unsigned int status_word;//0x6041:status_word,subindex:0,bitlen:16 unsigned int position_actual_value;//0x6064:position_actual_value,subindex:0,bitlen:32 unsigned int touch_probe_status;//0x60B9,subindex:0,bitlen:16 unsigned int touch_probe_pos1_pos_value;//0x60BA,subindex:0,bitlen:32 unsigned int touch_probe_pos2_pos_value;//0x60BC ,subindex:0,bitlen:32 unsigned int error_code;//0x603F,subindex:0,bitlen:16 unsigned int digital_inputs;//0x60FD,subindex:0,bitlen:32 unsigned int torque_actual_value;//0x6077,subindex:0,bitlen:16 unsigned int following_error_actual_value;//0x60F4,subindex:0,bitlen:32 unsigned int modes_of_operation_display;//0x6061,subindex:0,bitlen:8 unsigned int velocity_actual_value;//0x606C,subindex:0,bitlen:32 };
static struct IS620N_offset offset;
const static ec_pdo_entry_reg_t domain1_regs[] = { //RxPDO {IS620NSlavePos, INOVANCE_IS620N, 0x6040, 0, &offset.control_word}, {IS620NSlavePos, INOVANCE_IS620N, 0x607A, 0, &offset.target_position}, {IS620NSlavePos, INOVANCE_IS620N, 0x60FF, 0, &offset.target_velocity}, {IS620NSlavePos, INOVANCE_IS620N, 0x6071, 0, &offset.target_torque}, {IS620NSlavePos, INOVANCE_IS620N, 0x6060, 0, &offset.modes_operation}, {IS620NSlavePos, INOVANCE_IS620N, 0x60B8, 0, &offset.touch_probe}, {IS620NSlavePos, INOVANCE_IS620N, 0x607F, 0, &offset.max_profile_velocity}, //TxPDO {IS620NSlavePos, INOVANCE_IS620N, 0x603F, 0, &offset.error_code}, {IS620NSlavePos, INOVANCE_IS620N, 0x6041, 0, &offset.status_word}, {IS620NSlavePos, INOVANCE_IS620N, 0x6064, 0, &offset.position_actual_value}, {IS620NSlavePos, INOVANCE_IS620N, 0x6077, 0, &offset.torque_actual_value}, {IS620NSlavePos, INOVANCE_IS620N, 0x6061, 0, &offset.modes_of_operation_display}, {IS620NSlavePos, INOVANCE_IS620N, 0x60B9, 0, &offset.touch_probe_status}, {IS620NSlavePos, INOVANCE_IS620N, 0x60BA, 0, &offset.touch_probe_pos1_pos_value}, {IS620NSlavePos, INOVANCE_IS620N, 0x60BC, 0, &offset.touch_probe_pos2_pos_value}, {IS620NSlavePos, INOVANCE_IS620N, 0x60FD, 0, &offset.digital_inputs}, {} };
static unsigned int counter = 0; //static int state = -500;
/重新映射PDO才需要定义下面这3个数组,如果使用servo的固定映射则不需要/ /Config PDOs/ static ec_pdo_entry_info_t IS620N_pdo_entries[] = { //RxPdo 0x1702 {0x6040, 0x00, 16}, {0x607A, 0x00, 32}, {0x60FF, 0x00, 32}, {0x6071, 0x00, 16}, {0x6060, 0x00, 8}, {0x60B8, 0x00, 16}, {0x607F, 0x00, 32}, //TxPdo 0x1B02 {0x603F, 0x00, 16}, {0x6041, 0x00, 16}, {0x6064, 0x00, 32}, {0x6077, 0x00, 16}, {0x6061, 0x00, 8}, {0x60B9, 0x00, 16}, {0x60BA, 0x00, 32}, {0x60BC, 0x00, 32}, {0x60FD, 0x00, 32}, };
static ec_pdo_info_t IS620N_pdos[] = { //RxPdo //{0x1600, 3, IS620N_pdo_entries + 0 }, {0x1600, 7, IS620N_pdo_entries + 0 }, //TxPdo //{0x1A00, 8, IS620N_pdo_entries + 3 } {0x1A00, 9, IS620N_pdo_entries + 7 } };
static ec_sync_info_t IS620N_syncs[] = { { 0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE }, { 1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE }, { 2, EC_DIR_OUTPUT, 1, IS620N_pdos + 0, EC_WD_DISABLE }, { 3, EC_DIR_INPUT, 1, IS620N_pdos + 1, EC_WD_DISABLE }, { 0xFF} };
/*****/
void check_domain1_state(void) { ec_domain_state_t ds; ecrt_domain_state(domain1, &ds); if (ds.working_counter != domain1_state.working_counter) printf("Domain1: WC %u.\n", ds.working_counter);
}
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);
}
/*****/
void check_slave_config_states(void) { ec_slave_config_state_t s; ecrt_slave_config_state(sc_IS620N, &s); if (s.al_state != sc_IS620N_state.al_state) printf("IS620N: State 0x%02X.\n", s.al_state);
}
/***/
void cyclic_task() { static unsigned int timeout_error = 0; static uint16_t status_mask=0x004F; static int32_t target_velocity = TARGET_VELOCITY;
}
/****/
int main(int argc, char **argv) { master = ecrt_request_master(0); if (!master) exit(EXIT_FAILURE);
// printf("alias=%d,vid=%d,watchdog_divider=%d",sc_IS620N->alias,sc_IS620N->position,sc_IS620N->watchdog_divider);
/if(ecrt_slave_config_sdo32(sc_IS620N,0x60FF,0,TARGET_VELOCITY)) printf("fail to configure slave sdo 0x60FF!\n"); if(ecrt_slave_config_sdo16(sc_IS620N,0x6040,0,0x6)) printf("fail to configure slave sdo 0x6040!\n"); if(ecrt_slave_config_sdo16(sc_IS620N,0x6040,0,0x7)) printf("fail to configure slave sdo 0x6040!\n"); if(ecrt_slave_config_sdo16(sc_IS620N,0x6040,0,0xf)) printf("fail to configure slave sdo 0x6040!\n");/
}