Ignore:
Timestamp:
Aug 21, 2025, 3:14:57 PM (6 days ago)
Author:
f.jahn
Message:

Änderung neuer Controller mit mehr Speicher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/firmware_v2/SES/src/main.c

    r22 r23  
    8585
    8686  /* USER CODE BEGIN 1 */
    87 
     87  int temperature = 0;
     88  unsigned pwm = 0U;
     89  uint32_t uin = 0;
     90  uint32_t uout = 0;
    8891  /* USER CODE END 1 */
    8992
     
    108111  MX_DMA_Init();
    109112  MX_ADC1_Init();
    110   MX_TIM3_Init();
     113  MX_TIM16_Init();
    111114  MX_TIM17_Init();
    112115 // MX_USART1_UART_Init();
     
    163166        {
    164167          msCounter = 0;
    165       CHIP_TEMPERATURE_Exec( adcData[4]);
     168      temperature = CHIP_TEMPERATURE_Exec(adcData[4]);
    166169         
    167           static unsigned pwm = 100U;
     170          if (temperature > 50)
     171          { 
     172                  pwm++;
     173                  if (pwm > 100U) pwm = 100U;   
     174                 
     175          }
     176          if (temperature < 50)
     177          {
     178                if (pwm > 0) pwm--;
     179          }
     180          SetFANSpeed(pwm);
     181
     182
     183          if (temperature > 80)
     184          {
     185                 
     186         
     187          BUTTON_SetModeOff(); //Damit nicht von alleine wieder eingeschaltet wird
     188                  LEDS_GN_Off();
     189          LEDS_RT_BlinkCode_Start(BLINK_CODE_ERROR_TEMP, LED_RT_ON_TIME_WARN_TEMP, LED_RT_OFF_TIME, LED_RT_OFF_TIME *5); //Fehler Anzeigen
     190          printf("Temperature too high!\n");
     191         
     192          }
     193
     194          // Starting measuring frequency of the FAN tacho output
     195          static unsigned stage;
     196          extern uint32_t freq, ic_overflows;
     197
     198          switch (stage)
     199          {
     200                  case 0:
     201                          ic_overflows = 0U;
     202                          __HAL_TIM_SetCounter(&htim16, 0U);
     203                          HAL_TIM_Base_Start_IT(&htim16);
     204                          HAL_TIM_IC_Start_IT(&htim16, TIM_CHANNEL_1);
     205                          //printf("IC started\n");
     206                          stage++;
     207                          break;
     208                 
     209                  case 1: stage++; break;
     210                  case 2: stage++; break;
     211                  case 3: stage++; break;
     212                  case 4: stage++; break;
     213                  case 5: stage++; break;
     214                  case 6:
     215                          //printf("F = %u\n", freq);
     216                          if (!freq)
     217                          {
     218                                  static unsigned zeroFreqCnt;
     219
     220                                  zeroFreqCnt++;
     221                                  // Checking if we set last time non-zero FAN-speed, but
     222                                  // tacho-sensor signal is absent more than 15 sec.
     223                                  if (zeroFreqCnt > 3U && GetLastSpeed())
     224                                  {
     225                                          SetFANSpeed(0U);
     226                                          // ACHTUNG! Der Lüfter ist kaputt!
     227                                  }
     228                          }
     229                          stage = 0;
     230                          break;
     231          }
     232
     233          uin = VOLTAGE_MEAS_GetUin();
     234          uout = VOLTAGE_MEAS_GetUout();
     235          printf("uin= %d, uout=%d, temp=%d, pwm=%d, fan=%d\r\n", uin, uout, temperature,pwm,freq);
    168236         
    169           SetFANSpeed(pwm);
    170 
    171           pwm++;
    172           if (pwm > 300U) pwm = 300U;   // 30.0%
    173         }
     237         
     238        } //endsecond tick
    174239
    175240
     
    190255
    191256          case MODE_MAINSWITCH_LVP_OVP:
    192         MODE_LVP_OVP_Exec();
     257     //   MODE_LVP_OVP_Exec();
    193258      break;
    194259
Note: See TracChangeset for help on using the changeset viewer.