diff --git a/inc/main.h b/inc/main.h index f4aef79a..f79e81be 100644 --- a/inc/main.h +++ b/inc/main.h @@ -20,7 +20,8 @@ typedef enum { JOINT_FB_ERROR, POS_ERROR, SAT_ERROR, - HV_ERROR, + HV_CRC_ERROR, + HV_TIMEOUT_ERROR, HV_TEMP_ERROR, HV_VOLT_ERROR, MOT_TEMP_ERROR, diff --git a/shared/comps/fault.c b/shared/comps/fault.c index 7d7add38..bc07f7a6 100644 --- a/shared/comps/fault.c +++ b/shared/comps/fault.c @@ -163,8 +163,14 @@ static void rt_func(float period, volatile void *ctx_ptr, volatile hal_pin_inst_ } if(err_filter(&(ctx->hv_error), 3.0, 0.001, PIN(hv_error) > 0.0)) { - ctx->fault = HV_ERROR; + if(PIN(hv_error) > 1.0){ + ctx->fault = HV_TIMEOUT_ERROR; + } + else{ + ctx->fault = HV_CRC_ERROR; + } ctx->state = SOFT_FAULT; + } if(ABS(PIN(pos_error)) > PIN(max_pos_error)) { @@ -321,8 +327,12 @@ static void nrt_func(volatile void *ctx_ptr, volatile hal_pin_inst_t *pin_ptr) { printf("saturation error\n"); break; - case HV_ERROR: - printf("HV error\n"); + case HV_CRC_ERROR: + printf("HV crc error\n"); + break; + + case HV_TIMEOUT_ERROR: + printf("HV timeout error\n"); break; case HV_TEMP_ERROR: diff --git a/src/comps/hv.c b/src/comps/hv.c index b2761980..b4ad1e96 100644 --- a/src/comps/hv.c +++ b/src/comps/hv.c @@ -211,10 +211,10 @@ static void rt_func(float period, volatile void *ctx_ptr, volatile hal_pin_inst_ } } - if(ctx->timeout > 5) { + if(ctx->timeout > 3) { PIN(timeout) ++; - PIN(com_error) = 1.0; + PIN(com_error) = 2.0; } ctx->timeout++;