From fb08e8b56c23e928edad2306a51a155f6149577d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 26 Sep 2017 19:43:52 +1000 Subject: [PATCH] Tune timer and PID rates --- workspace/TS100/inc/FreeRTOSConfig.h | 2 +- workspace/TS100/src/Setup.c | 7 +++---- workspace/TS100/src/Translation.c | 9 ++++++++- workspace/TS100/src/main.cpp | 2 +- workspace/ts100/.cproject | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/workspace/TS100/inc/FreeRTOSConfig.h b/workspace/TS100/inc/FreeRTOSConfig.h index fc482351..3fa00f06 100644 --- a/workspace/TS100/inc/FreeRTOSConfig.h +++ b/workspace/TS100/inc/FreeRTOSConfig.h @@ -92,7 +92,7 @@ extern uint32_t SystemCoreClock; #endif -#define configUSE_PREEMPTION 0 +#define configUSE_PREEMPTION 1 #define configSUPPORT_STATIC_ALLOCATION 0 #define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configUSE_IDLE_HOOK 0 diff --git a/workspace/TS100/src/Setup.c b/workspace/TS100/src/Setup.c index 6e4fc784..3b5d41d5 100644 --- a/workspace/TS100/src/Setup.c +++ b/workspace/TS100/src/Setup.c @@ -29,7 +29,7 @@ static void MX_DMA_Init(void); static void MX_GPIO_Init(void); void Setup_HAL() { - + SystemClock_Config(); MX_GPIO_Init(); MX_DMA_Init(); MX_I2C1_Init(); @@ -130,7 +130,7 @@ static void MX_ADC1_Init(void) { sConfigInjected.InjectedChannel = ADC_CHANNEL_8; sConfigInjected.InjectedRank = 1; sConfigInjected.InjectedNbrOfConversion = 4; - sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_71CYCLES_5; + sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_55CYCLES_5; sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1; sConfigInjected.AutoInjectedConv = DISABLE; sConfigInjected.InjectedDiscontinuousConvMode = DISABLE; @@ -139,7 +139,6 @@ static void MX_ADC1_Init(void) { sConfigInjected.InjectedRank = 2; HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); sConfigInjected.InjectedRank = 3; - sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_55CYCLES_5; HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); sConfigInjected.InjectedRank = 4; HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); @@ -233,7 +232,7 @@ static void MX_TIM2_Init(void) { //Timer 2 is fairly slow as its being used to run the PWM and trigger the ADC in the PWM off time. htim2.Instance = TIM2; - htim2.Init.Prescaler = 2000; + htim2.Init.Prescaler = 1500; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 120; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4; //2mhz diff --git a/workspace/TS100/src/Translation.c b/workspace/TS100/src/Translation.c index ffb186ca..3295bdee 100644 --- a/workspace/TS100/src/Translation.c +++ b/workspace/TS100/src/Translation.c @@ -5,10 +5,16 @@ * Author: Ben V. Brown */ + +#ifndef LANG_EN +#define LANG_EN +#endif + +#ifdef LANG_EN const char* SettingsLongNames[12] = { /*These are all the help text for all the settings.*/ - /*All must start with 6 spaces so they come on screen nicely.*/ + /*No requirements on spacing or length*/ "Power source. Sets cutoff voltage. ", "Sleep Temperature ", "Sleep Timeout ", @@ -37,3 +43,4 @@ const char* SettingsShortNames[12] = { "CLBLNK ", "RESET? " }; +#endif diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index c7ebfdd3..ed7ab0a9 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -716,7 +716,7 @@ void startPIDTask(void const * argument) { } derivativeLastValue = rawTemp; //store for next loop HAL_IWDG_Refresh(&hiwdg); - osDelay(10); // 100 Hz temp loop + osDelay(100); // 10 Hz temp loop } } #define MOVFilter 4 diff --git a/workspace/ts100/.cproject b/workspace/ts100/.cproject index 7197dca0..83c86dfa 100644 --- a/workspace/ts100/.cproject +++ b/workspace/ts100/.cproject @@ -121,7 +121,7 @@ - +