46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
/*
|
|
* 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_1A (670 * CURR_SENSE_IS_FACTOR)
|
|
#define CURR_SENSE_FACTOR_2A (1075 * CURR_SENSE_IS_FACTOR)
|
|
#define CURR_SENSE_FACTOR_5A (3700 * CURR_SENSE_IS_FACTOR)
|
|
#define CURR_SENSE_FACTOR_10A (9500 * 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_ */
|