implemented current and voltage monitoring (currently NOT tested)
This commit is contained in:
@ -10,16 +10,16 @@
|
||||
|
||||
#include "channel_control.h"
|
||||
#include "can_halal.h"
|
||||
//#include "current_monitoring.h"
|
||||
#include "current_monitoring.h"
|
||||
|
||||
#define RX_STATUS_HEARTBEAT 0xC7 // IDs of all CAN-packages (may be other IDs next year)
|
||||
#define RX_STATUS_MSG_ID 0xC8 // TODO: check new IDs
|
||||
#define RX_STATUS_MSG_ID 0xC8
|
||||
#define TX_STATUS_MSG_ID 0xC9
|
||||
#define CUR_CHANNELS_1_ID 0xCA
|
||||
#define CUR_CHANNELS_2_ID 0xCB
|
||||
#define CUR_CHANNELS_3_ID 0xCC
|
||||
#define CUR_CHANNELS_4_ID 0xCD
|
||||
#define LV_SENS_ID 0xCE
|
||||
//#define LV_SENS_ID 0xCE // not used
|
||||
|
||||
typedef struct { // TODO: add error-codes
|
||||
enable_gpios iostatus;
|
||||
|
||||
51
Software/Code/Core/Inc/current_monitoring.h
Normal file
51
Software/Code/Core/Inc/current_monitoring.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* current_monitoring.h
|
||||
*
|
||||
* Created on: Mar 13, 2025
|
||||
* Author: janek
|
||||
*/
|
||||
|
||||
#ifndef INC_CURRENT_MONITORING_H_
|
||||
#define INC_CURRENT_MONITORING_H_
|
||||
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
// convert ADC quants to V
|
||||
#define ADC_V_FACTOR (3.3f / 4096) // 3.3V / 12bit
|
||||
// scale to LV by divider to mV
|
||||
#define LV_SENSE_FACTOR (1e3 * (ADC_V_FACTOR * ((12.f + 1.8f) / 1.8f)))
|
||||
#define PC_VSENSE_FACTOR (1e3 * (ADC_V_FACTOR * ((100.f + 10.f) / 10.f)));
|
||||
|
||||
// convert ADC quants to I_S in mA
|
||||
#define CURR_SENSE_IS_FACTOR_9A (ADC_V_FACTOR / 1.2f) // 3.3V / 12bit / 1.2kOhm
|
||||
#define CURR_SENSE_IS_FACTOR_4_5A (ADC_V_FACTOR / 1.f)
|
||||
#define CURR_SENSE_IS_FACTOR_1A (ADC_V_FACTOR / 4.f)
|
||||
// convert ADC quants to I_L in mA
|
||||
#define CURR_SENSE_FACTOR_1A (300 * CURR_SENSE_IS_FACTOR) // typical current sense ratio (datasheet PROFET)
|
||||
#define CURR_SENSE_FACTOR_4_5A (1500 * CURR_SENSE_IS_FACTOR)
|
||||
#define CURR_SENSE_FACTOR_9A (3900 * CURR_SENSE_IS_FACTOR)
|
||||
|
||||
typedef struct {
|
||||
uint16_t acc_cooling;
|
||||
uint16_t ts_cooling;
|
||||
uint16_t drs;
|
||||
uint16_t acu;
|
||||
uint16_t epsc;
|
||||
uint16_t inverter;
|
||||
uint16_t lidar;
|
||||
uint16_t misc;
|
||||
uint16_t alwayson;
|
||||
uint16_t sdc;
|
||||
uint16_t ebs1;
|
||||
uint16_t ebs2;
|
||||
uint16_t ebs3;
|
||||
uint16_t epsc_precharge;
|
||||
uint16_t lvms_v;
|
||||
uint16_t asms_v;
|
||||
} current_measurements;
|
||||
|
||||
void current_monitor_init(ADC_HandleTypeDef* hadc1, ADC_HandleTypeDef* hadc2, TIM_HandleTypeDef* trigtim);
|
||||
|
||||
uint8_t current_monitor_checklimits();
|
||||
|
||||
#endif /* INC_CURRENT_MONITORING_H_ */
|
||||
Reference in New Issue
Block a user