1
0
forked from me/IronOS

Tune timer and PID rates

This commit is contained in:
Ben V. Brown
2017-09-26 19:43:52 +10:00
parent d726734792
commit fb08e8b56c
5 changed files with 14 additions and 8 deletions

View File

@@ -92,7 +92,7 @@
extern uint32_t SystemCoreClock; extern uint32_t SystemCoreClock;
#endif #endif
#define configUSE_PREEMPTION 0 #define configUSE_PREEMPTION 1
#define configSUPPORT_STATIC_ALLOCATION 0 #define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configUSE_IDLE_HOOK 0 #define configUSE_IDLE_HOOK 0

View File

@@ -29,7 +29,7 @@ static void MX_DMA_Init(void);
static void MX_GPIO_Init(void); static void MX_GPIO_Init(void);
void Setup_HAL() { void Setup_HAL() {
SystemClock_Config();
MX_GPIO_Init(); MX_GPIO_Init();
MX_DMA_Init(); MX_DMA_Init();
MX_I2C1_Init(); MX_I2C1_Init();
@@ -130,7 +130,7 @@ static void MX_ADC1_Init(void) {
sConfigInjected.InjectedChannel = ADC_CHANNEL_8; sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
sConfigInjected.InjectedRank = 1; sConfigInjected.InjectedRank = 1;
sConfigInjected.InjectedNbrOfConversion = 4; sConfigInjected.InjectedNbrOfConversion = 4;
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_71CYCLES_5; sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_55CYCLES_5;
sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1; sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1;
sConfigInjected.AutoInjectedConv = DISABLE; sConfigInjected.AutoInjectedConv = DISABLE;
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE; sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
@@ -139,7 +139,6 @@ static void MX_ADC1_Init(void) {
sConfigInjected.InjectedRank = 2; sConfigInjected.InjectedRank = 2;
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
sConfigInjected.InjectedRank = 3; sConfigInjected.InjectedRank = 3;
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_55CYCLES_5;
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
sConfigInjected.InjectedRank = 4; sConfigInjected.InjectedRank = 4;
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected); 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. //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.Instance = TIM2;
htim2.Init.Prescaler = 2000; htim2.Init.Prescaler = 1500;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
htim2.Init.Period = 120; htim2.Init.Period = 120;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4; //2mhz htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV4; //2mhz

View File

@@ -5,10 +5,16 @@
* Author: Ben V. Brown * Author: Ben V. Brown
*/ */
#ifndef LANG_EN
#define LANG_EN
#endif
#ifdef LANG_EN
const char* SettingsLongNames[12] = const char* SettingsLongNames[12] =
{ {
/*These are all the help text for all the settings.*/ /*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. <DC 10V> <S 3.3V per cell>", "Power source. Sets cutoff voltage. <DC 10V> <S 3.3V per cell>",
"Sleep Temperature <C>", "Sleep Temperature <C>",
"Sleep Timeout <Minutes>", "Sleep Timeout <Minutes>",
@@ -37,3 +43,4 @@ const char* SettingsShortNames[12] = {
"CLBLNK ", "CLBLNK ",
"RESET? " "RESET? "
}; };
#endif

View File

@@ -716,7 +716,7 @@ void startPIDTask(void const * argument) {
} }
derivativeLastValue = rawTemp; //store for next loop derivativeLastValue = rawTemp; //store for next loop
HAL_IWDG_Refresh(&hiwdg); HAL_IWDG_Refresh(&hiwdg);
osDelay(10); // 100 Hz temp loop osDelay(100); // 10 Hz temp loop
} }
} }
#define MOVFilter 4 #define MOVFilter 4

View File

@@ -121,7 +121,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot;; arm-none-eabi-size -B &quot;${BuildArtifactFileName}&quot;"> <configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573" name="Release" parent="fr.ac6.managedbuild.config.gnu.cross.exe.release" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.bin&quot;; arm-none-eabi-size -B &quot;${BuildArtifactFileName}&quot; ;arm-none-eabi-objcopy -O ihex &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${BuildArtifactFileBaseName}.hex&quot;">
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573." name="/" resourcePath=""> <folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.release.723264573." name="/" resourcePath="">
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.1456567544" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release"> <toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release.1456567544" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.release">
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.67332574" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/> <option id="fr.ac6.managedbuild.option.gnu.cross.mcu.67332574" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="STM32F103T8Ux" valueType="string"/>