added piggyback PCB for ACU-DCDC, calibrated VSense
This commit is contained in:
@ -11,16 +11,16 @@
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
// convert ADC quants to V
|
||||
#define ADC_V_FACTOR ((3.3f / 4095) * (3.3f / 3.14f)) // 3.3V / 12bit
|
||||
#define ADC_V_FACTOR (3.3f / 4095) // 3.3V / 12bit
|
||||
// scale to LV by divider to mV
|
||||
#define LV_SENSE_FACTOR (1e3 * (ADC_V_FACTOR * ((12.f + 1.8f) / 1.8f))) // scaled with voltage divider
|
||||
#define LV_SENSE_FACTOR (1e3 * (ADC_V_FACTOR * ((12.f + 1.8f) / 1.8f)) * 1.054f) // scaled with voltage divider and measured deviation
|
||||
|
||||
// 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)
|
||||
#define CURR_SENSE_IS_FACTOR_4_5A (ADC_V_FACTOR / 1.f) // 3.3V / 12bit / 1kOhm
|
||||
#define CURR_SENSE_IS_FACTOR_1A (ADC_V_FACTOR / 4.f) // 3.3V / 12bit / 4kOhm
|
||||
// convert ADC quants to I_L in mA
|
||||
#define CURR_SENSE_FACTOR_1A (300 * CURR_SENSE_IS_FACTOR_1A) // typical current sense ratio (datasheet PROFET)
|
||||
#define CURR_SENSE_FACTOR_1A (300 * CURR_SENSE_IS_FACTOR_1A) // typical current sense ratio, (k_ILIS in datasheet of PROFET)
|
||||
#define CURR_SENSE_FACTOR_4_5A (1500 * CURR_SENSE_IS_FACTOR_4_5A)
|
||||
#define CURR_SENSE_FACTOR_9A (3900 * CURR_SENSE_IS_FACTOR_9A)
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ void ChannelControl_UpdateGPIOs(enable_gpios UpdatePorts){
|
||||
}
|
||||
}
|
||||
if ((prev_epsc_state == 1 && UpdatePorts.porta.epsc == 0) || (prev_epsc_state == UpdatePorts.porta.epsc)){
|
||||
HAL_GPIO_WritePin(PC_EN_GPIO_Port, PC_EN_Pin, 0); // ensure precharge is disabled, when not needed or stopped
|
||||
HAL_GPIO_WritePin(PC_EN_GPIO_Port, PC_EN_Pin, 0); // ensure precharge is disabled, when not needed or stopped before completion
|
||||
HAL_GPIO_WritePin(IN5_GPIO_Port, IN5_Pin, (GPIO_PinState)UpdatePorts.porta.epsc);
|
||||
prev_epsc_state = UpdatePorts.porta.epsc;
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ extern volatile uint8_t canmsg_received;
|
||||
|
||||
volatile enable_gpios update_ports;
|
||||
uint32_t lastheartbeat;
|
||||
int inhibit_SDC; // wenn =1 ist es unmoeglich den SDC zu schliessen
|
||||
int inhibit_SDC; // prevents closing of SDC when =1
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@ -120,6 +120,10 @@ int main(void)
|
||||
MX_TIM6_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
ChannelControl_init();
|
||||
can_init(&hcan);
|
||||
current_monitor_init(&hadc1, &hadc2, &htim6);
|
||||
|
||||
// begin start-up animation
|
||||
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(100);
|
||||
@ -146,13 +150,9 @@ int main(void)
|
||||
|
||||
HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_SET); // indicates running STM
|
||||
|
||||
ChannelControl_init();
|
||||
can_init(&hcan);
|
||||
current_monitor_init(&hadc1, &hadc2, &htim6);
|
||||
uint32_t lasttick = HAL_GetTick(); // time in ms since start
|
||||
|
||||
uint32_t lasttick = HAL_GetTick(); // Zeit in ms seit Start
|
||||
|
||||
inhibit_SDC = 0;
|
||||
inhibit_SDC = 0; // allow SDC to be closed
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user