dsel 8 added , current monitoring restructructing agtempt 1
This commit is contained in:
		@ -13,10 +13,9 @@
 | 
			
		||||
// 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_31A (34100 * 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_(7.5)A (5450 * CURR_SENSE_IS_FACTOR)
 | 
			
		||||
#define CURR_SENSE_FACTOR_21A (22700 * CURR_SENSE_IS_FACTOR)
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
 | 
			
		||||
@ -59,6 +59,8 @@ void Error_Handler(void);
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
/* Private defines -----------------------------------------------------------*/
 | 
			
		||||
#define DSEL_8_Pin GPIO_PIN_0
 | 
			
		||||
#define DSEL_8_GPIO_Port GPIOA
 | 
			
		||||
#define DSEL_3_Pin GPIO_PIN_12
 | 
			
		||||
#define DSEL_3_GPIO_Port GPIOB
 | 
			
		||||
#define DSEL_4_Pin GPIO_PIN_13
 | 
			
		||||
 | 
			
		||||
@ -10,13 +10,13 @@
 | 
			
		||||
 | 
			
		||||
volatile union adc1_channels {
 | 
			
		||||
  struct {
 | 
			
		||||
    uint16_t isense9;
 | 
			
		||||
    uint16_t isense8;
 | 
			
		||||
    uint16_t isense2;
 | 
			
		||||
    uint16_t isense12;
 | 
			
		||||
    uint16_t isense11;
 | 
			
		||||
    uint16_t isense6;
 | 
			
		||||
    uint16_t isense13;
 | 
			
		||||
    uint16_t isense5;
 | 
			
		||||
    uint16_t isense3;
 | 
			
		||||
    uint16_t dietemp;
 | 
			
		||||
    uint16_t vbat;
 | 
			
		||||
    uint16_t vrefint;
 | 
			
		||||
    uint16_t isense7;
 | 
			
		||||
  } adcbank1;
 | 
			
		||||
 | 
			
		||||
  uint16_t adcbuffer[7]; // array 7*16 bit
 | 
			
		||||
@ -25,16 +25,14 @@ volatile union adc1_channels {
 | 
			
		||||
// ADC's anpassen adc1 - 9, adc2 ist halt 5 , buffer anpassen und namen auch ( isense usw)
 | 
			
		||||
volatile union adc2_channels {
 | 
			
		||||
  struct {
 | 
			
		||||
    uint16_t isense11;
 | 
			
		||||
    uint16_t isense10;
 | 
			
		||||
    uint16_t isense5;
 | 
			
		||||
    uint16_t isense4;
 | 
			
		||||
    uint16_t isense2;
 | 
			
		||||
    uint16_t isense1;
 | 
			
		||||
    uint16_t isense7;
 | 
			
		||||
    uint16_t isense6;
 | 
			
		||||
  } adcbank1;
 | 
			
		||||
    uint16_t isense10;
 | 
			
		||||
    uint16_t isense4;
 | 
			
		||||
 | 
			
		||||
  uint16_t adcbuffer[7];
 | 
			
		||||
  } adcbank2;
 | 
			
		||||
 | 
			
		||||
  uint16_t adcbuffer[4];
 | 
			
		||||
 | 
			
		||||
} adc_channels2;
 | 
			
		||||
 | 
			
		||||
@ -48,11 +46,11 @@ ADC_HandleTypeDef* adc2;
 | 
			
		||||
 | 
			
		||||
void currentMonitor_init(ADC_HandleTypeDef* hadc1, ADC_HandleTypeDef* hadc2, // init ist initilisierung 
 | 
			
		||||
                         TIM_HandleTypeDef* trigtim) {
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin, adcbank1); //DSELs zu adc's neu zuordnen 
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_3_GPIO_Port, DSEL_3_Pin, adcbank2); //DSELs zu adc's neu zuordnen 
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_4_GPIO_Port, DSEL_4_Pin, adcbank2);
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_5_GPIO_Port, DSEL_5_Pin, adcbank2);
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_6_GPIO_Port, DSEL_6_Pin, adcbank2);
 | 
			
		||||
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_5_GPIO_Port, DSEL_5_Pin, adcbank1);
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_7_GPIO_Port, DSEL_7_Pin, adcbank1);
 | 
			
		||||
  HAL_GPIO_WritePin(DSEL_8_GPIO_Port, DSEL_8_Pin, adcbank2);
 | 
			
		||||
  adc1 = hadc1;
 | 
			
		||||
  adc2 = hadc2;
 | 
			
		||||
  HAL_TIM_Base_Start(trigtim);
 | 
			
		||||
 | 
			
		||||
@ -53,7 +53,7 @@ TIM_HandleTypeDef htim2;
 | 
			
		||||
TIM_HandleTypeDef htim3;
 | 
			
		||||
 | 
			
		||||
UART_HandleTypeDef huart1;
 | 
			
		||||
//Test
 | 
			
		||||
 | 
			
		||||
/* USER CODE BEGIN PV */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END PV */
 | 
			
		||||
 | 
			
		||||
@ -118,7 +118,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
    GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
 | 
			
		||||
    GPIO_InitStruct.Pin = DSEL_8_Pin|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
 | 
			
		||||
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 | 
			
		||||
    GPIO_InitStruct.Pull = GPIO_NOPULL;
 | 
			
		||||
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 | 
			
		||||
@ -195,7 +195,7 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
 | 
			
		||||
    */
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOC, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
 | 
			
		||||
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
 | 
			
		||||
    HAL_GPIO_DeInit(GPIOA, DSEL_8_Pin|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
 | 
			
		||||
 | 
			
		||||
  /* USER CODE BEGIN ADC1_MspDeInit 1 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -103,6 +103,8 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 | 
			
		||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
 | 
			
		||||
NVIC.USB_LP_CAN_RX0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
 | 
			
		||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
 | 
			
		||||
PA0.GPIOParameters=GPIO_Label
 | 
			
		||||
PA0.GPIO_Label=DSEL 8
 | 
			
		||||
PA0.Locked=true
 | 
			
		||||
PA0.Mode=IN1-Single-Ended
 | 
			
		||||
PA0.Signal=ADC1_IN1
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user