2024-05-12 13:58:33 +02:00
|
|
|
/*
|
|
|
|
* 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_5A (3700 * CURR_SENSE_IS_FACTOR)
|
2024-05-13 13:35:20 +02:00
|
|
|
#define CURR_SENSE_FACTOR_7_5A (5450 * CURR_SENSE_IS_FACTOR)
|
2024-05-12 14:08:58 +02:00
|
|
|
#define CURR_SENSE_FACTOR_21A (22700 * CURR_SENSE_IS_FACTOR)
|
2024-05-13 13:35:20 +02:00
|
|
|
#define CURR_SENSE_FACTOR_31A (34100 * CURR_SENSE_IS_FACTOR)
|
2024-05-12 13:58:33 +02:00
|
|
|
|
|
|
|
typedef struct {
|
2024-05-13 13:35:20 +02:00
|
|
|
uint16_t acu;
|
|
|
|
uint16_t epsc;
|
|
|
|
uint16_t radiator_fans;
|
|
|
|
uint16_t tsac_fans;
|
|
|
|
uint16_t gss;
|
|
|
|
uint16_t lidar;
|
|
|
|
uint16_t sdc;
|
|
|
|
uint16_t inverters;
|
2024-05-12 13:58:33 +02:00
|
|
|
uint16_t servos;
|
2024-05-13 13:35:20 +02:00
|
|
|
uint16_t aggregat;
|
2024-05-12 13:58:33 +02:00
|
|
|
uint16_t misc;
|
|
|
|
uint16_t always_on;
|
2024-05-13 13:35:20 +02:00
|
|
|
uint16_t ebs_cs_valve;
|
|
|
|
uint16_t reserved;
|
|
|
|
uint16_t ebsvalve_a;
|
|
|
|
uint16_t ebsvalve_b;
|
|
|
|
uint16_t cooling_pump;
|
2024-05-12 13:58:33 +02:00
|
|
|
} CurrentMeasurements;
|
|
|
|
|
|
|
|
void currentMonitor_init(ADC_HandleTypeDef* hadc1, ADC_HandleTypeDef* hadc2,
|
|
|
|
TIM_HandleTypeDef* trigtim);
|
|
|
|
uint8_t currentMonitor_checklimits();
|
|
|
|
|
|
|
|
#endif /* INC_CURRENT_MONITORING_H_ */
|