/* * Current_Monitoring.h * * Created on: 24. April, 2024 * Author: nived */ #ifndef INC_CURRENT_MONITORING_H_ #define INC_CURRENT_MONITORING_H_ #include "stm32f3xx_hal.h" // Convert ADC quants to I_S in mA #define CURR_SENSE_IS_FACTOR ((3.3f / 4096) / 1.2f) // 3.3V / 12bit / 1.2kOhm // Convert ADC quants to I_L in mA #define CURR_SENSE_FACTOR_31A (34100 * CURR_SENSE_IS_FACTOR) #define CURR_SENSE_FACTOR_5A (3700 * CURR_SENSE_IS_FACTOR) #define CURR_SENSE_FACTOR_(7.5)A (5450 * CURR_SENSE_IS_FACTOR) #define CURR_SENSE_FACTOR_21A (22700 * CURR_SENSE_IS_FACTOR) typedef struct { uint16_t servicebrake; uint16_t sensorbox; uint16_t fans; uint16_t aggregat; uint16_t inverter; uint16_t pumps; uint16_t steering; uint16_t servos; uint16_t misc; uint16_t always_on; uint16_t shutdown_circuit; uint16_t modevalve_1; uint16_t modevalve_2; uint16_t ebsvalve_1; uint16_t ebsvalve_2; } CurrentMeasurements; void currentMonitor_init(ADC_HandleTypeDef* hadc1, ADC_HandleTypeDef* hadc2, TIM_HandleTypeDef* trigtim); uint8_t currentMonitor_checklimits(); #endif /* INC_CURRENT_MONITORING_H_ */