diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h index 69fb407de7..d264ac4018 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoemsappl/EOMtheEMSapplCfg_cfg.h @@ -75,7 +75,7 @@ extern "C" { #define EOMTHEEMSAPPLCFG_VERSION_MAJOR 3 // minor <0-255> // minor <0-255> -#define EOMTHEEMSAPPLCFG_VERSION_MINOR 37 +#define EOMTHEEMSAPPLCFG_VERSION_MINOR 38 // version @@ -83,13 +83,13 @@ extern "C" { // year <2010-2030> #define EOMTHEEMSAPPLCFG_BUILDDATE_YEAR 2021 // month <1-12> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 2 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MONTH 3 // day <1-31> -#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 19 +#define EOMTHEEMSAPPLCFG_BUILDDATE_DAY 22 // hour <0-23> -#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 15 +#define EOMTHEEMSAPPLCFG_BUILDDATE_HOUR 18 // minute <0-59> -#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 30 +#define EOMTHEEMSAPPLCFG_BUILDDATE_MIN 24 // build date // Info diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoprot-callbacks/EoProtocolMN_fun_ems4rd.c b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoprot-callbacks/EoProtocolMN_fun_ems4rd.c index ec226a584a..36776344b8 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoprot-callbacks/EoProtocolMN_fun_ems4rd.c +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/cfg/eoprot-callbacks/EoProtocolMN_fun_ems4rd.c @@ -93,6 +93,278 @@ static void s_eoprot_ep_mn_fun_queryarraycommand(eOmn_command_t* command); // - definition (and initialisation) of static variables // -------------------------------------------------------------------------------------------------------------------- +#if defined(TESTethboardsfix) +static const eOmn_serv_configuration_t s_serv_config_strain_generic = +{ + .type = eomn_serv_AS_strain, + .filler = {0}, + .data.as.strain = + { + .boardtype = + { + .type = eobrd_strain2, + .firmware = {2, 0, 10}, + .protocol = {2, 0} + }, + .canloc = + { + .port = eOcanport1, + .addr = 13, + .insideindex = eobrd_caninsideindex_none, + .dummy = 0 + } + } +}; + +static const eOmn_serv_configuration_t s_serv_config_mc_mc4plus_eb24 = +{ + .type = eomn_serv_MC_mc4plus, + .filler = {0}, + .data.mc.mc4plus_based = + { + .arrayofjomodescriptors = + { + .head = + { + .capacity = 4, + .itemsize = sizeof(eOmc_jomo_descriptor_t), + .size = 4, + .internalmem = 0 + }, + .data = + { + { // joint 0 + .actuator.pwm = + { + .port = eobrd_port_mc4plusP5, + .dummy = 0 + }, + .encoder1 = + { + .type = eomc_enc_qenc, + .port = eobrd_port_mc4plusP5, + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_qenc, + .port = eobrd_port_mc4plusP5, + .pos = eomc_pos_atmotor + } + }, + { // joint 1 + .actuator.pwm = + { + .port = eobrd_port_mc4plusP2, + .dummy = 0 + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_mc4plusP10, + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_qenc, + .port = eobrd_port_mc4plusP2, + .pos = eomc_pos_atmotor + } + }, + { // joint 2 + .actuator.pwm = + { + .port = eobrd_port_mc4plusP4, + .dummy = 0 + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_mc4plusP11, + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_qenc, + .port = eobrd_port_mc4plusP4, + .pos = eomc_pos_atmotor + } + }, + { // joint 3 + .actuator.pwm = + { + .port = eobrd_port_mc4plusP3, + .dummy = 0 + }, + .encoder1 = + { + .type = eomc_enc_absanalog, + .port = eobrd_port_mc4plusP3, + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_none, + .port = eobrd_port_none, + .pos = eomc_pos_none + } + } + } + }, + .jomocoupling = + { + .joint2set = + { // 3 sets: set0 = {0}, set1 = {1, 2}, set2 = {3} + 0, 1, 1, 2 + }, + .joint2motor = + { // tbd + { EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(-1.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f) } + }, + .encoder2joint = + { // nearly identical matrix + { EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) } + } + } + } +}; + +static const eOmn_serv_configuration_t s_serv_config_mc_eb1_eb3_zeroprotocol = +{ // eb1 / eb3 + .type = eomn_serv_MC_foc, + .filler = {0}, + .data.mc.foc_based = + { + .version = + { + .firmware = { .major = 0, .minor = 0, .build = 0 }, + .protocol = { .major = 0, .minor = 0 } + }, + .filler = {0}, + .arrayofjomodescriptors = + { + .head = + { + .capacity = 4, + .itemsize = sizeof(eOmc_jomo_descriptor_t), + .size = 4, + .internalmem = 0 + }, + .data = + { + { // joint 0 + .actuator.foc.canloc = + { + .port = eOcanport1, + .addr = 1, + .insideindex = eobrd_caninsideindex_first + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_emsP6, // hal_encoder1 + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_none, + .port = eobrd_port_none, + .pos = eomc_pos_none + } + }, + { // joint 1 + .actuator.foc.canloc = + { + .port = eOcanport1, + .addr = 2, + .insideindex = eobrd_caninsideindex_first + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_emsP7, // hal_encoder4 + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_none, + .port = eobrd_port_none, + .pos = eomc_pos_none + } + }, + { // joint 2 + .actuator.foc.canloc = + { + .port = eOcanport1, + .addr = 3, + .insideindex = eobrd_caninsideindex_first + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_emsP8, // hal_encoder2 + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_none, + .port = eobrd_port_none, + .pos = eomc_pos_none + } + }, + { // joint 3 + .actuator.foc.canloc = + { + .port = eOcanport1, + .addr = 4, + .insideindex = eobrd_caninsideindex_first + }, + .encoder1 = + { + .type = eomc_enc_aea, + .port = eobrd_port_emsP9, // hal_encoder5 + .pos = eomc_pos_atjoint + }, + .encoder2 = + { + .type = eomc_enc_none, + .port = eobrd_port_none, + .pos = eomc_pos_none + } + } + } + }, + .jomocoupling = + { + .joint2set = + { // each joint is on a different set + 0, 1, 2, 3 + }, + .joint2motor = + { // zero matrix: use matrix embedded in controller and seecetd by boardtype4mccontroller + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) } + }, + .encoder2joint = + { // identical matrix + { EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) }, + { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f) } + } + } + } +}; + +#endif // TESTethboardsfix // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of extern variables @@ -411,6 +683,61 @@ extern void eoprot_fun_UPDT_mn_appl_cmmnds_go2state(const EOnv* nv, const eOropd } + +#if defined(TESTethboardsfix) + + +static eOmn_service_cmmnds_command_t s_command = {0}; + +volatile uint32_t count = 0; +volatile uint8_t thisstep = 0; +extern void eoprot_fun_UPDT_mn_appl_cmmnds_timeset(const EOnv* nv, const eOropdescriptor_t* rd) +{ + eOabstime_t *timeset = (eOabstime_t *)nv->ram; + + + static const uint8_t period = 4; + static const eOmn_serv_operation_t ops[4] = + { + eomn_serv_operation_verifyactivate, + eomn_serv_operation_start, + eomn_serv_operation_stop, + eomn_serv_operation_deactivate + }; + + + s_command.operation = ops[count % period]; + + if(count >=8) + { + thisstep = 1; + } + + // strain service: it is ok in both ems and mc4plus +// s_command.category = eomn_serv_category_strain; +// memcpy(&s_command.parameter.configuration, &s_serv_config_strain_generic, sizeof(eOmn_serv_configuration_t)); + + + s_command.category = eomn_serv_category_mc; + #if defined(USE_EMS4RD) + memcpy(&s_command.parameter.configuration, &s_serv_config_mc_eb1_eb3_zeroprotocol, sizeof(eOmn_serv_configuration_t)); + #else + memcpy(&s_command.parameter.configuration, &s_serv_config_mc_mc4plus_eb24, sizeof(eOmn_serv_configuration_t)); + #endif + + + eOmn_service_cmmnds_command_t *command = &s_command; + + count ++; + + // ok, we have received a command for a given service. we ask the object theservices to manage the thing + + eo_services_ProcessCommand(eo_services_GetHandle(), command); + +} + +#else // not TESTethboardsfix + extern void eoprot_fun_UPDT_mn_appl_cmmnds_timeset(const EOnv* nv, const eOropdescriptor_t* rd) { eOabstime_t *timeset = (eOabstime_t *)nv->ram; @@ -484,6 +811,8 @@ extern void eoprot_fun_UPDT_mn_appl_cmmnds_timeset(const EOnv* nv, const eOropde } +#endif // TESTethboardsfix + extern void eoprot_fun_UPDT_mn_service_cmmnds_command(const EOnv* nv, const eOropdescriptor_t* rd) { diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/proj/ems4rd.diagnostic2ready.uvoptx b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/proj/ems4rd.diagnostic2ready.uvoptx index cc14f556b9..512effd3ca 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/proj/ems4rd.diagnostic2ready.uvoptx +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/proj/ems4rd.diagnostic2ready.uvoptx @@ -2586,7 +2586,7 @@ appl-services - 1 + 0 0 0 0 diff --git a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOCurrentsWatchdog.c b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOCurrentsWatchdog.c index 58a6aeca91..04df20324b 100644 --- a/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOCurrentsWatchdog.c +++ b/emBODY/eBcode/arch-arm/board/ems004/appl/v2/src/eoappservices/EOCurrentsWatchdog.c @@ -104,6 +104,21 @@ EO_static_inline eObool_t s_eo_currents_watchdog_averageCalc_collectDataIsComple // - definition (and initialisation) of static variables // -------------------------------------------------------------------------------------------------------------------- + +#if defined(EOCURRENTSWATCHDOG_CORRECT_THE_INITIALISE_BUG) +static EOCurrentsWatchdog s_eo_currents_watchdog = +{ + EO_INIT(.themotors) {NULL, NULL, NULL, NULL}, + EO_INIT(.numberofmotors) 0, + //EO_INIT(.filter_reg) NULL, + EO_INIT(.nominalCurrent2) {0, 0, 0, 0}, + EO_INIT(.I2T_threshold) {0, 0, 0, 0}, + EO_INIT(.avgCurrent) {0, 0, 0, 0}, + EO_INIT(.accomulatorEp) {0, 0, 0, 0}, + EO_INIT(.initted) eobool_false, + EO_INIT(.motorinI2Tfault) {eobool_false, eobool_false, eobool_false, eobool_false} +}; +#else static EOCurrentsWatchdog s_eo_currents_watchdog = { EO_INIT(.themotors) NULL, @@ -116,11 +131,12 @@ static EOCurrentsWatchdog s_eo_currents_watchdog = EO_INIT(.initted) eobool_false, EO_INIT(.motorinI2Tfault) NULL }; +#endif static uint16_t suppliedVoltage_counter = 0; static eOmc_controller_t *nv_controller_ptr = NULL; #define SUMMPLIED_VOLTAGE_COUNTER_MAX 500 -//static const char s_eobj_ownname[] = "EOCurrentsWatchdog"; +static const char s_eobj_ownname[] = "EOCurrentsWatchdog"; static int16_t maxReadCurrent[4] ={15, 15, 15, 15};//15 mA is the cureent with no load see datasheet of motor (debug only) @@ -132,6 +148,57 @@ static int16_t maxReadCurrent[4] ={15, 15, 15, 15};//15 mA is the cureent with n extern EOCurrentsWatchdog* eo_currents_watchdog_Initialise(void) { + +#if defined(EOCURRENTSWATCHDOG_CORRECT_THE_INITIALISE_BUG) + + uint8_t m = 0; + + + // marco.accame on 09 mar 2021 + // the folloing part could go inside a eo_currents_watchdog_Activate() + // as in here there is just a preparation of static ram. + + // get the number of used motors + s_eo_currents_watchdog.numberofmotors = eo_entities_NumOfMotors(eo_entities_GetHandle()); + + if((0 == s_eo_currents_watchdog.numberofmotors) || ( s_eo_currents_watchdog.numberofmotors > maxmotors)) + { + s_eo_currents_watchdog.numberofmotors = 0; + return(&s_eo_currents_watchdog); + } + + + // retrieve pointers to motors + for(m=0; m