diff --git a/.vscode/settings.json b/.vscode/settings.json index 02d71d4..9234a4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -60,7 +60,15 @@ "pid_g.h": "c", "mode_pwmp.h": "c", "eeprom_m95.h": "c", - "sys.h": "c" + "sys.h": "c", + "data_type_def.h": "c", + "at_hc24.h": "c", + "board.h": "c", + "dacs.h": "c", + "entity.h": "c", + "pid.h": "c", + "filter.h": "c", + "convert.h": "c" }, "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/MDK-ARM/RTE/_controller-v2/RTE_Components.h b/MDK-ARM/RTE/_controller-v2/RTE_Components.h index 481bf87..391636b 100644 --- a/MDK-ARM/RTE/_controller-v2/RTE_Components.h +++ b/MDK-ARM/RTE/_controller-v2/RTE_Components.h @@ -1,6 +1,6 @@ /* - * Auto generated Run-Time-Environment Component Configuration File + * Auto generated Run-Time-Environment Configuration File * *** Do not modify ! *** * * Project: 'controller-v2' @@ -17,4 +17,5 @@ #define CMSIS_device_header "stm32l4xx.h" + #endif /* RTE_COMPONENTS_H */ diff --git a/MDK-ARM/controller-v2.uvoptx b/MDK-ARM/controller-v2.uvoptx index 57ce19e..4dea436 100644 --- a/MDK-ARM/controller-v2.uvoptx +++ b/MDK-ARM/controller-v2.uvoptx @@ -103,7 +103,7 @@ 1 0 0 - 6 + 4 @@ -325,6 +325,7 @@ 1 + 0 0 2 10000000 diff --git a/MDK-ARM/controller-v2.uvprojx b/MDK-ARM/controller-v2.uvprojx index 2573059..9b0f096 100644 --- a/MDK-ARM/controller-v2.uvprojx +++ b/MDK-ARM/controller-v2.uvprojx @@ -10,14 +10,14 @@ controller-v2 0x4 ARM-ADS - 5060061::V5.06 update 1 (build 61)::ARMCC + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 STM32L476VGTx STMicroelectronics - Keil.STM32L4xx_DFP.2.1.0 - http://www.keil.com/pack + Keil.STM32L4xx_DFP.2.6.2 + https://www.keil.com/pack/ IRAM(0x20000000,0x00018000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -184,6 +184,9 @@ 0 0 1 + 0 + 0 + 0 1 0 8 @@ -350,7 +353,7 @@ 0 0 0 - 0 + 4 @@ -991,7 +994,7 @@ 2 2 2 - 2 + 0 @@ -1043,8 +1046,8 @@ STM32L476VGTx STMicroelectronics - Keil.STM32L4xx_DFP.2.1.0 - http://www.keil.com/pack + Keil.STM32L4xx_DFP.2.6.2 + https://www.keil.com/pack/ IRAM(0x20000000,0x00018000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -1211,6 +1214,9 @@ 0 0 1 + 0 + 0 + 0 1 0 8 @@ -1377,7 +1383,7 @@ 0 0 0 - 0 + 4 @@ -1880,8 +1886,8 @@ STM32L476VGTx STMicroelectronics - Keil.STM32L4xx_DFP.2.1.0 - http://www.keil.com/pack + Keil.STM32L4xx_DFP.2.6.2 + https://www.keil.com/pack/ IRAM(0x20000000,0x00018000) IRAM2(0x10000000,0x00008000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 DSP CLOCK(12000000) ELITTLE @@ -2048,6 +2054,9 @@ 0 0 1 + 0 + 0 + 0 1 0 8 @@ -2214,7 +2223,7 @@ 0 0 0 - 0 + 4 @@ -2303,7 +2312,7 @@ 2 2 2 - 2 + 0 @@ -2382,7 +2391,7 @@ 2 2 2 - 2 + 0 @@ -2506,7 +2515,7 @@ 2 2 2 - 2 + 0 @@ -2640,7 +2649,7 @@ 2 2 2 - 2 + 0 @@ -2719,7 +2728,7 @@ 2 2 2 - 2 + 0 @@ -2808,7 +2817,7 @@ 2 2 2 - 2 + 0 @@ -2937,7 +2946,7 @@ 2 2 2 - 2 + 0 @@ -3046,7 +3055,7 @@ 2 2 2 - 2 + 0 @@ -3225,7 +3234,7 @@ 2 2 2 - 2 + 0 @@ -3334,7 +3343,7 @@ 2 2 2 - 2 + 0 diff --git a/MDK-ARM/controller-v2/controller-v2.4 b/MDK-ARM/controller-v2/controller-v2.4 index d64ddf7..1bd77ac 100644 Binary files a/MDK-ARM/controller-v2/controller-v2.4 and b/MDK-ARM/controller-v2/controller-v2.4 differ diff --git a/MDK-ARM/startup_stm32l476xx.lst b/MDK-ARM/startup_stm32l476xx.lst new file mode 100644 index 0000000..37ee33b --- /dev/null +++ b/MDK-ARM/startup_stm32l476xx.lst @@ -0,0 +1,1772 @@ + + + +ARM Macro Assembler Page 1 + + + 1 00000000 ;******************************************************* + ************************ + 2 00000000 ;* File Name : startup_stm32l476xx.s + 3 00000000 ;* Author : MCD Application Team + 4 00000000 ;* Description : STM32L476xx Ultra Low Power devi + ces vector table for MDK-ARM toolchain. + 5 00000000 ;* This module performs: + 6 00000000 ;* - Set the initial SP + 7 00000000 ;* - Set the initial PC == Reset_Ha + ndler + 8 00000000 ;* - Set the vector table entries w + ith the exceptions ISR address + 9 00000000 ;* - Branches to __main in the C li + brary (which eventually + 10 00000000 ;* calls main()). + 11 00000000 ;* After Reset the Cortex-M4 proces + sor is in Thread mode, + 12 00000000 ;* priority is Privileged, and the + Stack is set to Main. + 13 00000000 ;******************************************************* + ************************* + 14 00000000 ;* @attention + 15 00000000 ;* + 16 00000000 ;* Copyright (c) 2017 STMicroelectronics. + 17 00000000 ;* All rights reserved. + 18 00000000 ;* + 19 00000000 ;* This software is licensed under terms that can be fou + nd in the LICENSE file + 20 00000000 ;* in the root directory of this software component. + 21 00000000 ;* If no LICENSE file comes with this software, it is pr + ovided AS-IS. + 22 00000000 ; + 23 00000000 ;******************************************************* + ************************ + 24 00000000 ;* <<< Use Configuration Wizard in Context Menu >>> + 25 00000000 ; Amount of memory (in bytes) allocated for Stack + 26 00000000 ; Tailor this value to your application needs + 27 00000000 ; Stack Configuration + 28 00000000 ; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + 29 00000000 ; + 30 00000000 + 31 00000000 00001000 + Stack_Size + EQU 0x1000 + 32 00000000 + 33 00000000 AREA STACK, NOINIT, READWRITE, ALIGN +=3 + 34 00000000 Stack_Mem + SPACE Stack_Size + 35 00001000 __initial_sp + 36 00001000 + 37 00001000 + 38 00001000 ; Heap Configuration + 39 00001000 ; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + 40 00001000 ; + 41 00001000 + 42 00001000 00000800 + Heap_Size + EQU 0x800 + + + +ARM Macro Assembler Page 2 + + + 43 00001000 + 44 00001000 AREA HEAP, NOINIT, READWRITE, ALIGN= +3 + 45 00000000 __heap_base + 46 00000000 Heap_Mem + SPACE Heap_Size + 47 00000800 __heap_limit + 48 00000800 + 49 00000800 PRESERVE8 + 50 00000800 THUMB + 51 00000800 + 52 00000800 + 53 00000800 ; Vector Table Mapped to Address 0 at Reset + 54 00000800 AREA RESET, DATA, READONLY + 55 00000000 EXPORT __Vectors + 56 00000000 EXPORT __Vectors_End + 57 00000000 EXPORT __Vectors_Size + 58 00000000 + 59 00000000 00000000 + __Vectors + DCD __initial_sp ; Top of Stack + 60 00000004 00000000 DCD Reset_Handler ; Reset Handler + 61 00000008 00000000 DCD NMI_Handler ; NMI Handler + 62 0000000C 00000000 DCD HardFault_Handler ; Hard Fault + Handler + 63 00000010 00000000 DCD MemManage_Handler + ; MPU Fault Handler + + 64 00000014 00000000 DCD BusFault_Handler + ; Bus Fault Handler + + 65 00000018 00000000 DCD UsageFault_Handler ; Usage Faul + t Handler + 66 0000001C 00000000 DCD 0 ; Reserved + 67 00000020 00000000 DCD 0 ; Reserved + 68 00000024 00000000 DCD 0 ; Reserved + 69 00000028 00000000 DCD 0 ; Reserved + 70 0000002C 00000000 DCD SVC_Handler ; SVCall Handler + 71 00000030 00000000 DCD DebugMon_Handler ; Debug Monito + r Handler + 72 00000034 00000000 DCD 0 ; Reserved + 73 00000038 00000000 DCD PendSV_Handler ; PendSV Handler + + 74 0000003C 00000000 DCD SysTick_Handler + ; SysTick Handler + 75 00000040 + 76 00000040 ; External Interrupts + 77 00000040 00000000 DCD WWDG_IRQHandler + ; Window WatchDog + 78 00000044 00000000 DCD PVD_PVM_IRQHandler ; PVD/PVM1/P + VM2/PVM3/PVM4 throu + gh EXTI Line detect + ion + 79 00000048 00000000 DCD TAMP_STAMP_IRQHandler ; Tamper + and TimeStamps thro + ugh the EXTI line + 80 0000004C 00000000 DCD RTC_WKUP_IRQHandler ; RTC Wakeu + p through the EXTI + line + + + +ARM Macro Assembler Page 3 + + + 81 00000050 00000000 DCD FLASH_IRQHandler ; FLASH + 82 00000054 00000000 DCD RCC_IRQHandler ; RCC + 83 00000058 00000000 DCD EXTI0_IRQHandler ; EXTI Line0 + 84 0000005C 00000000 DCD EXTI1_IRQHandler ; EXTI Line1 + 85 00000060 00000000 DCD EXTI2_IRQHandler ; EXTI Line2 + 86 00000064 00000000 DCD EXTI3_IRQHandler ; EXTI Line3 + 87 00000068 00000000 DCD EXTI4_IRQHandler ; EXTI Line4 + 88 0000006C 00000000 DCD DMA1_Channel1_IRQHandler + ; DMA1 Channel 1 + 89 00000070 00000000 DCD DMA1_Channel2_IRQHandler + ; DMA1 Channel 2 + 90 00000074 00000000 DCD DMA1_Channel3_IRQHandler + ; DMA1 Channel 3 + 91 00000078 00000000 DCD DMA1_Channel4_IRQHandler + ; DMA1 Channel 4 + 92 0000007C 00000000 DCD DMA1_Channel5_IRQHandler + ; DMA1 Channel 5 + 93 00000080 00000000 DCD DMA1_Channel6_IRQHandler + ; DMA1 Channel 6 + 94 00000084 00000000 DCD DMA1_Channel7_IRQHandler + ; DMA1 Channel 7 + 95 00000088 00000000 DCD ADC1_2_IRQHandler ; ADC1, ADC2 + 96 0000008C 00000000 DCD CAN1_TX_IRQHandler ; CAN1 TX + 97 00000090 00000000 DCD CAN1_RX0_IRQHandler ; CAN1 RX0 + 98 00000094 00000000 DCD CAN1_RX1_IRQHandler ; CAN1 RX1 + 99 00000098 00000000 DCD CAN1_SCE_IRQHandler ; CAN1 SCE + 100 0000009C 00000000 DCD EXTI9_5_IRQHandler ; External L + ine[9:5]s + 101 000000A0 00000000 DCD TIM1_BRK_TIM15_IRQHandler ; TIM + 1 Break and TIM15 + 102 000000A4 00000000 DCD TIM1_UP_TIM16_IRQHandler ; TIM1 + Update and TIM16 + 103 000000A8 00000000 DCD TIM1_TRG_COM_TIM17_IRQHandler ; + TIM1 Trigger and C + ommutation and TIM1 + 7 + 104 000000AC 00000000 DCD TIM1_CC_IRQHandler ; TIM1 Captu + re Compare + 105 000000B0 00000000 DCD TIM2_IRQHandler ; TIM2 + 106 000000B4 00000000 DCD TIM3_IRQHandler ; TIM3 + 107 000000B8 00000000 DCD TIM4_IRQHandler ; TIM4 + 108 000000BC 00000000 DCD I2C1_EV_IRQHandler ; I2C1 Event + + 109 000000C0 00000000 DCD I2C1_ER_IRQHandler ; I2C1 Error + + 110 000000C4 00000000 DCD I2C2_EV_IRQHandler ; I2C2 Event + + 111 000000C8 00000000 DCD I2C2_ER_IRQHandler ; I2C2 Error + + 112 000000CC 00000000 DCD SPI1_IRQHandler ; SPI1 + 113 000000D0 00000000 DCD SPI2_IRQHandler ; SPI2 + 114 000000D4 00000000 DCD USART1_IRQHandler ; USART1 + 115 000000D8 00000000 DCD USART2_IRQHandler ; USART2 + 116 000000DC 00000000 DCD USART3_IRQHandler ; USART3 + 117 000000E0 00000000 DCD EXTI15_10_IRQHandler ; External + Line[15:10] + 118 000000E4 00000000 DCD RTC_Alarm_IRQHandler ; RTC Alar + m (A and B) through + EXTI Line + + + +ARM Macro Assembler Page 4 + + + 119 000000E8 00000000 DCD DFSDM1_FLT3_IRQHandler ; DFSDM1 + Filter 3 global In + terrupt + 120 000000EC 00000000 DCD TIM8_BRK_IRQHandler ; TIM8 Brea + k Interrupt + 121 000000F0 00000000 DCD TIM8_UP_IRQHandler ; TIM8 Updat + e Interrupt + 122 000000F4 00000000 DCD TIM8_TRG_COM_IRQHandler ; TIM8 + Trigger and Commuta + tion Interrupt + 123 000000F8 00000000 DCD TIM8_CC_IRQHandler ; TIM8 Captu + re Compare Interrup + t + 124 000000FC 00000000 DCD ADC3_IRQHandler ; ADC3 global + Interrupt + 125 00000100 00000000 DCD FMC_IRQHandler ; FMC + 126 00000104 00000000 DCD SDMMC1_IRQHandler ; SDMMC1 + 127 00000108 00000000 DCD TIM5_IRQHandler ; TIM5 + 128 0000010C 00000000 DCD SPI3_IRQHandler ; SPI3 + 129 00000110 00000000 DCD UART4_IRQHandler ; UART4 + 130 00000114 00000000 DCD UART5_IRQHandler ; UART5 + 131 00000118 00000000 DCD TIM6_DAC_IRQHandler ; TIM6 and + DAC1&2 underrun err + ors + 132 0000011C 00000000 DCD TIM7_IRQHandler ; TIM7 + 133 00000120 00000000 DCD DMA2_Channel1_IRQHandler + ; DMA2 Channel 1 + 134 00000124 00000000 DCD DMA2_Channel2_IRQHandler + ; DMA2 Channel 2 + 135 00000128 00000000 DCD DMA2_Channel3_IRQHandler + ; DMA2 Channel 3 + 136 0000012C 00000000 DCD DMA2_Channel4_IRQHandler + ; DMA2 Channel 4 + 137 00000130 00000000 DCD DMA2_Channel5_IRQHandler + ; DMA2 Channel 5 + 138 00000134 00000000 DCD DFSDM1_FLT0_IRQHandler ; DFSDM1 + Filter 0 global In + terrupt + 139 00000138 00000000 DCD DFSDM1_FLT1_IRQHandler ; DFSDM1 + Filter 1 global In + terrupt + 140 0000013C 00000000 DCD DFSDM1_FLT2_IRQHandler ; DFSDM1 + Filter 2 global In + terrupt + 141 00000140 00000000 DCD COMP_IRQHandler + ; COMP Interrupt + 142 00000144 00000000 DCD LPTIM1_IRQHandler + ; LP TIM1 interrupt + + 143 00000148 00000000 DCD LPTIM2_IRQHandler + ; LP TIM2 interrupt + + 144 0000014C 00000000 DCD OTG_FS_IRQHandler ; USB OTG FS + 145 00000150 00000000 DCD DMA2_Channel6_IRQHandler + ; DMA2 Channel 6 + 146 00000154 00000000 DCD DMA2_Channel7_IRQHandler + ; DMA2 Channel 7 + 147 00000158 00000000 DCD LPUART1_IRQHandler ; LP UART1 i + nterrupt + + + +ARM Macro Assembler Page 5 + + + 148 0000015C 00000000 DCD QUADSPI_IRQHandler ; Quad SPI g + lobal interrupt + 149 00000160 00000000 DCD I2C3_EV_IRQHandler ; I2C3 event + + 150 00000164 00000000 DCD I2C3_ER_IRQHandler ; I2C3 error + + 151 00000168 00000000 DCD SAI1_IRQHandler ; Serial Audio + Interface 1 global + interrupt + 152 0000016C 00000000 DCD SAI2_IRQHandler ; Serial Audio + Interface 2 global + interrupt + 153 00000170 00000000 DCD SWPMI1_IRQHandler ; Serial Wire + Interface 1 global + interrupt + 154 00000174 00000000 DCD TSC_IRQHandler ; Touch Sense Co + ntroller global int + errupt + 155 00000178 00000000 DCD LCD_IRQHandler ; LCD global int + errupt + 156 0000017C 00000000 DCD 0 ; Reserved + + 157 00000180 00000000 DCD RNG_IRQHandler ; RNG global int + errupt + 158 00000184 00000000 DCD FPU_IRQHandler ; FPU + 159 00000188 + 160 00000188 __Vectors_End + 161 00000188 + 162 00000188 00000188 + __Vectors_Size + EQU __Vectors_End - __Vectors + 163 00000188 + 164 00000188 AREA |.text|, CODE, READONLY + 165 00000000 + 166 00000000 ; Reset handler + 167 00000000 Reset_Handler + PROC + 168 00000000 EXPORT Reset_Handler [WEAK +] + 169 00000000 IMPORT SystemInit + 170 00000000 IMPORT __main + 171 00000000 + 172 00000000 4806 LDR R0, =SystemInit + 173 00000002 4780 BLX R0 + 174 00000004 4806 LDR R0, =__main + 175 00000006 4700 BX R0 + 176 00000008 ENDP + 177 00000008 + 178 00000008 ; Dummy Exception Handlers (infinite loops which can be + modified) + 179 00000008 + 180 00000008 NMI_Handler + PROC + 181 00000008 EXPORT NMI_Handler [WEA +K] + 182 00000008 E7FE B . + 183 0000000A ENDP + 185 0000000A HardFault_Handler + PROC + + + +ARM Macro Assembler Page 6 + + + 186 0000000A EXPORT HardFault_Handler [WEA +K] + 187 0000000A E7FE B . + 188 0000000C ENDP + 190 0000000C MemManage_Handler + PROC + 191 0000000C EXPORT MemManage_Handler [WEA +K] + 192 0000000C E7FE B . + 193 0000000E ENDP + 195 0000000E BusFault_Handler + PROC + 196 0000000E EXPORT BusFault_Handler [WEA +K] + 197 0000000E E7FE B . + 198 00000010 ENDP + 200 00000010 UsageFault_Handler + PROC + 201 00000010 EXPORT UsageFault_Handler [WEA +K] + 202 00000010 E7FE B . + 203 00000012 ENDP + 204 00000012 SVC_Handler + PROC + 205 00000012 EXPORT SVC_Handler [WEA +K] + 206 00000012 E7FE B . + 207 00000014 ENDP + 209 00000014 DebugMon_Handler + PROC + 210 00000014 EXPORT DebugMon_Handler [WEA +K] + 211 00000014 E7FE B . + 212 00000016 ENDP + 213 00000016 PendSV_Handler + PROC + 214 00000016 EXPORT PendSV_Handler [WEA +K] + 215 00000016 E7FE B . + 216 00000018 ENDP + 217 00000018 SysTick_Handler + PROC + 218 00000018 EXPORT SysTick_Handler [WEA +K] + 219 00000018 E7FE B . + 220 0000001A ENDP + 221 0000001A + 222 0000001A Default_Handler + PROC + 223 0000001A + 224 0000001A EXPORT WWDG_IRQHandler + [WEAK] + 225 0000001A EXPORT PVD_PVM_IRQHandler + [WEAK] + 226 0000001A EXPORT TAMP_STAMP_IRQHandler + [WEAK] + 227 0000001A EXPORT RTC_WKUP_IRQHandler + [WEAK] + 228 0000001A EXPORT FLASH_IRQHandler + + + +ARM Macro Assembler Page 7 + + + [WEAK] + 229 0000001A EXPORT RCC_IRQHandler + [WEAK] + 230 0000001A EXPORT EXTI0_IRQHandler + [WEAK] + 231 0000001A EXPORT EXTI1_IRQHandler + [WEAK] + 232 0000001A EXPORT EXTI2_IRQHandler + [WEAK] + 233 0000001A EXPORT EXTI3_IRQHandler + [WEAK] + 234 0000001A EXPORT EXTI4_IRQHandler + [WEAK] + 235 0000001A EXPORT DMA1_Channel1_IRQHandler + [WEAK] + 236 0000001A EXPORT DMA1_Channel2_IRQHandler + [WEAK] + 237 0000001A EXPORT DMA1_Channel3_IRQHandler + [WEAK] + 238 0000001A EXPORT DMA1_Channel4_IRQHandler + [WEAK] + 239 0000001A EXPORT DMA1_Channel5_IRQHandler + [WEAK] + 240 0000001A EXPORT DMA1_Channel6_IRQHandler + [WEAK] + 241 0000001A EXPORT DMA1_Channel7_IRQHandler + [WEAK] + 242 0000001A EXPORT ADC1_2_IRQHandler + [WEAK] + 243 0000001A EXPORT CAN1_TX_IRQHandler + [WEAK] + 244 0000001A EXPORT CAN1_RX0_IRQHandler + [WEAK] + 245 0000001A EXPORT CAN1_RX1_IRQHandler + [WEAK] + 246 0000001A EXPORT CAN1_SCE_IRQHandler + [WEAK] + 247 0000001A EXPORT EXTI9_5_IRQHandler + [WEAK] + 248 0000001A EXPORT TIM1_BRK_TIM15_IRQHandler + [WEAK] + 249 0000001A EXPORT TIM1_UP_TIM16_IRQHandler + [WEAK] + 250 0000001A EXPORT TIM1_TRG_COM_TIM17_IRQHandler + [WEAK] + 251 0000001A EXPORT TIM1_CC_IRQHandler + [WEAK] + 252 0000001A EXPORT TIM2_IRQHandler + [WEAK] + 253 0000001A EXPORT TIM3_IRQHandler + [WEAK] + 254 0000001A EXPORT TIM4_IRQHandler + [WEAK] + 255 0000001A EXPORT I2C1_EV_IRQHandler + [WEAK] + 256 0000001A EXPORT I2C1_ER_IRQHandler + [WEAK] + 257 0000001A EXPORT I2C2_EV_IRQHandler + [WEAK] + + + +ARM Macro Assembler Page 8 + + + 258 0000001A EXPORT I2C2_ER_IRQHandler + [WEAK] + 259 0000001A EXPORT SPI1_IRQHandler + [WEAK] + 260 0000001A EXPORT SPI2_IRQHandler + [WEAK] + 261 0000001A EXPORT USART1_IRQHandler + [WEAK] + 262 0000001A EXPORT USART2_IRQHandler + [WEAK] + 263 0000001A EXPORT USART3_IRQHandler + [WEAK] + 264 0000001A EXPORT EXTI15_10_IRQHandler + [WEAK] + 265 0000001A EXPORT RTC_Alarm_IRQHandler + [WEAK] + 266 0000001A EXPORT DFSDM1_FLT3_IRQHandler + [WEAK] + 267 0000001A EXPORT TIM8_BRK_IRQHandler + [WEAK] + 268 0000001A EXPORT TIM8_UP_IRQHandler + [WEAK] + 269 0000001A EXPORT TIM8_TRG_COM_IRQHandler + [WEAK] + 270 0000001A EXPORT TIM8_CC_IRQHandler + [WEAK] + 271 0000001A EXPORT ADC3_IRQHandler + [WEAK] + 272 0000001A EXPORT FMC_IRQHandler + [WEAK] + 273 0000001A EXPORT SDMMC1_IRQHandler + [WEAK] + 274 0000001A EXPORT TIM5_IRQHandler + [WEAK] + 275 0000001A EXPORT SPI3_IRQHandler + [WEAK] + 276 0000001A EXPORT UART4_IRQHandler + [WEAK] + 277 0000001A EXPORT UART5_IRQHandler + [WEAK] + 278 0000001A EXPORT TIM6_DAC_IRQHandler + [WEAK] + 279 0000001A EXPORT TIM7_IRQHandler + [WEAK] + 280 0000001A EXPORT DMA2_Channel1_IRQHandler + [WEAK] + 281 0000001A EXPORT DMA2_Channel2_IRQHandler + [WEAK] + 282 0000001A EXPORT DMA2_Channel3_IRQHandler + [WEAK] + 283 0000001A EXPORT DMA2_Channel4_IRQHandler + [WEAK] + 284 0000001A EXPORT DMA2_Channel5_IRQHandler + [WEAK] + 285 0000001A EXPORT DFSDM1_FLT0_IRQHandler + [WEAK] + 286 0000001A EXPORT DFSDM1_FLT1_IRQHandler + [WEAK] + 287 0000001A EXPORT DFSDM1_FLT2_IRQHandler + + + +ARM Macro Assembler Page 9 + + + [WEAK] + 288 0000001A EXPORT COMP_IRQHandler + [WEAK] + 289 0000001A EXPORT LPTIM1_IRQHandler + [WEAK] + 290 0000001A EXPORT LPTIM2_IRQHandler + [WEAK] + 291 0000001A EXPORT OTG_FS_IRQHandler + [WEAK] + 292 0000001A EXPORT DMA2_Channel6_IRQHandler + [WEAK] + 293 0000001A EXPORT DMA2_Channel7_IRQHandler + [WEAK] + 294 0000001A EXPORT LPUART1_IRQHandler + [WEAK] + 295 0000001A EXPORT QUADSPI_IRQHandler + [WEAK] + 296 0000001A EXPORT I2C3_EV_IRQHandler + [WEAK] + 297 0000001A EXPORT I2C3_ER_IRQHandler + [WEAK] + 298 0000001A EXPORT SAI1_IRQHandler + [WEAK] + 299 0000001A EXPORT SAI2_IRQHandler + [WEAK] + 300 0000001A EXPORT SWPMI1_IRQHandler + [WEAK] + 301 0000001A EXPORT TSC_IRQHandler + [WEAK] + 302 0000001A EXPORT LCD_IRQHandler + [WEAK] + 303 0000001A EXPORT RNG_IRQHandler + [WEAK] + 304 0000001A EXPORT FPU_IRQHandler + [WEAK] + 305 0000001A + 306 0000001A WWDG_IRQHandler + 307 0000001A PVD_PVM_IRQHandler + 308 0000001A TAMP_STAMP_IRQHandler + 309 0000001A RTC_WKUP_IRQHandler + 310 0000001A FLASH_IRQHandler + 311 0000001A RCC_IRQHandler + 312 0000001A EXTI0_IRQHandler + 313 0000001A EXTI1_IRQHandler + 314 0000001A EXTI2_IRQHandler + 315 0000001A EXTI3_IRQHandler + 316 0000001A EXTI4_IRQHandler + 317 0000001A DMA1_Channel1_IRQHandler + 318 0000001A DMA1_Channel2_IRQHandler + 319 0000001A DMA1_Channel3_IRQHandler + 320 0000001A DMA1_Channel4_IRQHandler + 321 0000001A DMA1_Channel5_IRQHandler + 322 0000001A DMA1_Channel6_IRQHandler + 323 0000001A DMA1_Channel7_IRQHandler + 324 0000001A ADC1_2_IRQHandler + 325 0000001A CAN1_TX_IRQHandler + 326 0000001A CAN1_RX0_IRQHandler + 327 0000001A CAN1_RX1_IRQHandler + 328 0000001A CAN1_SCE_IRQHandler + + + +ARM Macro Assembler Page 10 + + + 329 0000001A EXTI9_5_IRQHandler + 330 0000001A TIM1_BRK_TIM15_IRQHandler + 331 0000001A TIM1_UP_TIM16_IRQHandler + 332 0000001A TIM1_TRG_COM_TIM17_IRQHandler + 333 0000001A TIM1_CC_IRQHandler + 334 0000001A TIM2_IRQHandler + 335 0000001A TIM3_IRQHandler + 336 0000001A TIM4_IRQHandler + 337 0000001A I2C1_EV_IRQHandler + 338 0000001A I2C1_ER_IRQHandler + 339 0000001A I2C2_EV_IRQHandler + 340 0000001A I2C2_ER_IRQHandler + 341 0000001A SPI1_IRQHandler + 342 0000001A SPI2_IRQHandler + 343 0000001A USART1_IRQHandler + 344 0000001A USART2_IRQHandler + 345 0000001A USART3_IRQHandler + 346 0000001A EXTI15_10_IRQHandler + 347 0000001A RTC_Alarm_IRQHandler + 348 0000001A DFSDM1_FLT3_IRQHandler + 349 0000001A TIM8_BRK_IRQHandler + 350 0000001A TIM8_UP_IRQHandler + 351 0000001A TIM8_TRG_COM_IRQHandler + 352 0000001A TIM8_CC_IRQHandler + 353 0000001A ADC3_IRQHandler + 354 0000001A FMC_IRQHandler + 355 0000001A SDMMC1_IRQHandler + 356 0000001A TIM5_IRQHandler + 357 0000001A SPI3_IRQHandler + 358 0000001A UART4_IRQHandler + 359 0000001A UART5_IRQHandler + 360 0000001A TIM6_DAC_IRQHandler + 361 0000001A TIM7_IRQHandler + 362 0000001A DMA2_Channel1_IRQHandler + 363 0000001A DMA2_Channel2_IRQHandler + 364 0000001A DMA2_Channel3_IRQHandler + 365 0000001A DMA2_Channel4_IRQHandler + 366 0000001A DMA2_Channel5_IRQHandler + 367 0000001A DFSDM1_FLT0_IRQHandler + 368 0000001A DFSDM1_FLT1_IRQHandler + 369 0000001A DFSDM1_FLT2_IRQHandler + 370 0000001A COMP_IRQHandler + 371 0000001A LPTIM1_IRQHandler + 372 0000001A LPTIM2_IRQHandler + 373 0000001A OTG_FS_IRQHandler + 374 0000001A DMA2_Channel6_IRQHandler + 375 0000001A DMA2_Channel7_IRQHandler + 376 0000001A LPUART1_IRQHandler + 377 0000001A QUADSPI_IRQHandler + 378 0000001A I2C3_EV_IRQHandler + 379 0000001A I2C3_ER_IRQHandler + 380 0000001A SAI1_IRQHandler + 381 0000001A SAI2_IRQHandler + 382 0000001A SWPMI1_IRQHandler + 383 0000001A TSC_IRQHandler + 384 0000001A LCD_IRQHandler + 385 0000001A RNG_IRQHandler + 386 0000001A FPU_IRQHandler + 387 0000001A + + + +ARM Macro Assembler Page 11 + + + 388 0000001A E7FE B . + 389 0000001C + 390 0000001C ENDP + 391 0000001C + 392 0000001C ALIGN + 393 0000001C + 394 0000001C ;******************************************************* + ************************ + 395 0000001C ; User Stack and Heap initialization + 396 0000001C ;******************************************************* + ************************ + 397 0000001C IF :DEF:__MICROLIB + 398 0000001C + 399 0000001C EXPORT __initial_sp + 400 0000001C EXPORT __heap_base + 401 0000001C EXPORT __heap_limit + 402 0000001C + 403 0000001C ELSE + 418 ENDIF + 419 0000001C + 420 0000001C END + 00000000 + 00000000 +Command Line: --debug --xref --diag_suppress=9931 --cpu=Cortex-M4 --apcs=interw +ork --depend=controller-v2\startup_stm32l476xx.d -ocontroller-v2\startup_stm32l +476xx.o -I.\RTE\_controller-v2 -IS:\software\MDK\ARM\Packs\ARM\CMSIS\5.9.0\CMSI +S\Core\Include -IS:\software\MDK\ARM\Packs\Keil\STM32L4xx_DFP\2.6.2\Drivers\CMS +IS\Device\ST\STM32L4xx\Include --predefine="__MICROLIB SETA 1" --predefine="__U +VISION_VERSION SETA 538" --predefine="_RTE_ SETA 1" --predefine="STM32L476xx SE +TA 1" --predefine="_RTE_ SETA 1" --list=startup_stm32l476xx.lst startup_stm32l4 +76xx.s + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +STACK 00000000 + +Symbol: STACK + Definitions + At line 33 in file startup_stm32l476xx.s + Uses + None +Comment: STACK unused +Stack_Mem 00000000 + +Symbol: Stack_Mem + Definitions + At line 34 in file startup_stm32l476xx.s + Uses + None +Comment: Stack_Mem unused +__initial_sp 00001000 + +Symbol: __initial_sp + Definitions + At line 35 in file startup_stm32l476xx.s + Uses + At line 59 in file startup_stm32l476xx.s + At line 399 in file startup_stm32l476xx.s + +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +HEAP 00000000 + +Symbol: HEAP + Definitions + At line 44 in file startup_stm32l476xx.s + Uses + None +Comment: HEAP unused +Heap_Mem 00000000 + +Symbol: Heap_Mem + Definitions + At line 46 in file startup_stm32l476xx.s + Uses + None +Comment: Heap_Mem unused +__heap_base 00000000 + +Symbol: __heap_base + Definitions + At line 45 in file startup_stm32l476xx.s + Uses + At line 400 in file startup_stm32l476xx.s +Comment: __heap_base used once +__heap_limit 00000800 + +Symbol: __heap_limit + Definitions + At line 47 in file startup_stm32l476xx.s + Uses + At line 401 in file startup_stm32l476xx.s +Comment: __heap_limit used once +4 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +RESET 00000000 + +Symbol: RESET + Definitions + At line 54 in file startup_stm32l476xx.s + Uses + None +Comment: RESET unused +__Vectors 00000000 + +Symbol: __Vectors + Definitions + At line 59 in file startup_stm32l476xx.s + Uses + At line 55 in file startup_stm32l476xx.s + At line 162 in file startup_stm32l476xx.s + +__Vectors_End 00000188 + +Symbol: __Vectors_End + Definitions + At line 160 in file startup_stm32l476xx.s + Uses + At line 56 in file startup_stm32l476xx.s + At line 162 in file startup_stm32l476xx.s + +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Relocatable symbols + +.text 00000000 + +Symbol: .text + Definitions + At line 164 in file startup_stm32l476xx.s + Uses + None +Comment: .text unused +ADC1_2_IRQHandler 0000001A + +Symbol: ADC1_2_IRQHandler + Definitions + At line 324 in file startup_stm32l476xx.s + Uses + At line 95 in file startup_stm32l476xx.s + At line 242 in file startup_stm32l476xx.s + +ADC3_IRQHandler 0000001A + +Symbol: ADC3_IRQHandler + Definitions + At line 353 in file startup_stm32l476xx.s + Uses + At line 124 in file startup_stm32l476xx.s + At line 271 in file startup_stm32l476xx.s + +BusFault_Handler 0000000E + +Symbol: BusFault_Handler + Definitions + At line 195 in file startup_stm32l476xx.s + Uses + At line 64 in file startup_stm32l476xx.s + At line 196 in file startup_stm32l476xx.s + +CAN1_RX0_IRQHandler 0000001A + +Symbol: CAN1_RX0_IRQHandler + Definitions + At line 326 in file startup_stm32l476xx.s + Uses + At line 97 in file startup_stm32l476xx.s + At line 244 in file startup_stm32l476xx.s + +CAN1_RX1_IRQHandler 0000001A + +Symbol: CAN1_RX1_IRQHandler + Definitions + At line 327 in file startup_stm32l476xx.s + Uses + At line 98 in file startup_stm32l476xx.s + At line 245 in file startup_stm32l476xx.s + +CAN1_SCE_IRQHandler 0000001A + +Symbol: CAN1_SCE_IRQHandler + Definitions + At line 328 in file startup_stm32l476xx.s + Uses + + + +ARM Macro Assembler Page 2 Alphabetic symbol ordering +Relocatable symbols + + At line 99 in file startup_stm32l476xx.s + At line 246 in file startup_stm32l476xx.s + +CAN1_TX_IRQHandler 0000001A + +Symbol: CAN1_TX_IRQHandler + Definitions + At line 325 in file startup_stm32l476xx.s + Uses + At line 96 in file startup_stm32l476xx.s + At line 243 in file startup_stm32l476xx.s + +COMP_IRQHandler 0000001A + +Symbol: COMP_IRQHandler + Definitions + At line 370 in file startup_stm32l476xx.s + Uses + At line 141 in file startup_stm32l476xx.s + At line 288 in file startup_stm32l476xx.s + +DFSDM1_FLT0_IRQHandler 0000001A + +Symbol: DFSDM1_FLT0_IRQHandler + Definitions + At line 367 in file startup_stm32l476xx.s + Uses + At line 138 in file startup_stm32l476xx.s + At line 285 in file startup_stm32l476xx.s + +DFSDM1_FLT1_IRQHandler 0000001A + +Symbol: DFSDM1_FLT1_IRQHandler + Definitions + At line 368 in file startup_stm32l476xx.s + Uses + At line 139 in file startup_stm32l476xx.s + At line 286 in file startup_stm32l476xx.s + +DFSDM1_FLT2_IRQHandler 0000001A + +Symbol: DFSDM1_FLT2_IRQHandler + Definitions + At line 369 in file startup_stm32l476xx.s + Uses + At line 140 in file startup_stm32l476xx.s + At line 287 in file startup_stm32l476xx.s + +DFSDM1_FLT3_IRQHandler 0000001A + +Symbol: DFSDM1_FLT3_IRQHandler + Definitions + At line 348 in file startup_stm32l476xx.s + Uses + At line 119 in file startup_stm32l476xx.s + At line 266 in file startup_stm32l476xx.s + +DMA1_Channel1_IRQHandler 0000001A + + + + +ARM Macro Assembler Page 3 Alphabetic symbol ordering +Relocatable symbols + +Symbol: DMA1_Channel1_IRQHandler + Definitions + At line 317 in file startup_stm32l476xx.s + Uses + At line 88 in file startup_stm32l476xx.s + At line 235 in file startup_stm32l476xx.s + +DMA1_Channel2_IRQHandler 0000001A + +Symbol: DMA1_Channel2_IRQHandler + Definitions + At line 318 in file startup_stm32l476xx.s + Uses + At line 89 in file startup_stm32l476xx.s + At line 236 in file startup_stm32l476xx.s + +DMA1_Channel3_IRQHandler 0000001A + +Symbol: DMA1_Channel3_IRQHandler + Definitions + At line 319 in file startup_stm32l476xx.s + Uses + At line 90 in file startup_stm32l476xx.s + At line 237 in file startup_stm32l476xx.s + +DMA1_Channel4_IRQHandler 0000001A + +Symbol: DMA1_Channel4_IRQHandler + Definitions + At line 320 in file startup_stm32l476xx.s + Uses + At line 91 in file startup_stm32l476xx.s + At line 238 in file startup_stm32l476xx.s + +DMA1_Channel5_IRQHandler 0000001A + +Symbol: DMA1_Channel5_IRQHandler + Definitions + At line 321 in file startup_stm32l476xx.s + Uses + At line 92 in file startup_stm32l476xx.s + At line 239 in file startup_stm32l476xx.s + +DMA1_Channel6_IRQHandler 0000001A + +Symbol: DMA1_Channel6_IRQHandler + Definitions + At line 322 in file startup_stm32l476xx.s + Uses + At line 93 in file startup_stm32l476xx.s + At line 240 in file startup_stm32l476xx.s + +DMA1_Channel7_IRQHandler 0000001A + +Symbol: DMA1_Channel7_IRQHandler + Definitions + At line 323 in file startup_stm32l476xx.s + Uses + At line 94 in file startup_stm32l476xx.s + + + +ARM Macro Assembler Page 4 Alphabetic symbol ordering +Relocatable symbols + + At line 241 in file startup_stm32l476xx.s + +DMA2_Channel1_IRQHandler 0000001A + +Symbol: DMA2_Channel1_IRQHandler + Definitions + At line 362 in file startup_stm32l476xx.s + Uses + At line 133 in file startup_stm32l476xx.s + At line 280 in file startup_stm32l476xx.s + +DMA2_Channel2_IRQHandler 0000001A + +Symbol: DMA2_Channel2_IRQHandler + Definitions + At line 363 in file startup_stm32l476xx.s + Uses + At line 134 in file startup_stm32l476xx.s + At line 281 in file startup_stm32l476xx.s + +DMA2_Channel3_IRQHandler 0000001A + +Symbol: DMA2_Channel3_IRQHandler + Definitions + At line 364 in file startup_stm32l476xx.s + Uses + At line 135 in file startup_stm32l476xx.s + At line 282 in file startup_stm32l476xx.s + +DMA2_Channel4_IRQHandler 0000001A + +Symbol: DMA2_Channel4_IRQHandler + Definitions + At line 365 in file startup_stm32l476xx.s + Uses + At line 136 in file startup_stm32l476xx.s + At line 283 in file startup_stm32l476xx.s + +DMA2_Channel5_IRQHandler 0000001A + +Symbol: DMA2_Channel5_IRQHandler + Definitions + At line 366 in file startup_stm32l476xx.s + Uses + At line 137 in file startup_stm32l476xx.s + At line 284 in file startup_stm32l476xx.s + +DMA2_Channel6_IRQHandler 0000001A + +Symbol: DMA2_Channel6_IRQHandler + Definitions + At line 374 in file startup_stm32l476xx.s + Uses + At line 145 in file startup_stm32l476xx.s + At line 292 in file startup_stm32l476xx.s + +DMA2_Channel7_IRQHandler 0000001A + +Symbol: DMA2_Channel7_IRQHandler + + + +ARM Macro Assembler Page 5 Alphabetic symbol ordering +Relocatable symbols + + Definitions + At line 375 in file startup_stm32l476xx.s + Uses + At line 146 in file startup_stm32l476xx.s + At line 293 in file startup_stm32l476xx.s + +DebugMon_Handler 00000014 + +Symbol: DebugMon_Handler + Definitions + At line 209 in file startup_stm32l476xx.s + Uses + At line 71 in file startup_stm32l476xx.s + At line 210 in file startup_stm32l476xx.s + +Default_Handler 0000001A + +Symbol: Default_Handler + Definitions + At line 222 in file startup_stm32l476xx.s + Uses + None +Comment: Default_Handler unused +EXTI0_IRQHandler 0000001A + +Symbol: EXTI0_IRQHandler + Definitions + At line 312 in file startup_stm32l476xx.s + Uses + At line 83 in file startup_stm32l476xx.s + At line 230 in file startup_stm32l476xx.s + +EXTI15_10_IRQHandler 0000001A + +Symbol: EXTI15_10_IRQHandler + Definitions + At line 346 in file startup_stm32l476xx.s + Uses + At line 117 in file startup_stm32l476xx.s + At line 264 in file startup_stm32l476xx.s + +EXTI1_IRQHandler 0000001A + +Symbol: EXTI1_IRQHandler + Definitions + At line 313 in file startup_stm32l476xx.s + Uses + At line 84 in file startup_stm32l476xx.s + At line 231 in file startup_stm32l476xx.s + +EXTI2_IRQHandler 0000001A + +Symbol: EXTI2_IRQHandler + Definitions + At line 314 in file startup_stm32l476xx.s + Uses + At line 85 in file startup_stm32l476xx.s + At line 232 in file startup_stm32l476xx.s + + + + +ARM Macro Assembler Page 6 Alphabetic symbol ordering +Relocatable symbols + +EXTI3_IRQHandler 0000001A + +Symbol: EXTI3_IRQHandler + Definitions + At line 315 in file startup_stm32l476xx.s + Uses + At line 86 in file startup_stm32l476xx.s + At line 233 in file startup_stm32l476xx.s + +EXTI4_IRQHandler 0000001A + +Symbol: EXTI4_IRQHandler + Definitions + At line 316 in file startup_stm32l476xx.s + Uses + At line 87 in file startup_stm32l476xx.s + At line 234 in file startup_stm32l476xx.s + +EXTI9_5_IRQHandler 0000001A + +Symbol: EXTI9_5_IRQHandler + Definitions + At line 329 in file startup_stm32l476xx.s + Uses + At line 100 in file startup_stm32l476xx.s + At line 247 in file startup_stm32l476xx.s + +FLASH_IRQHandler 0000001A + +Symbol: FLASH_IRQHandler + Definitions + At line 310 in file startup_stm32l476xx.s + Uses + At line 81 in file startup_stm32l476xx.s + At line 228 in file startup_stm32l476xx.s + +FMC_IRQHandler 0000001A + +Symbol: FMC_IRQHandler + Definitions + At line 354 in file startup_stm32l476xx.s + Uses + At line 125 in file startup_stm32l476xx.s + At line 272 in file startup_stm32l476xx.s + +FPU_IRQHandler 0000001A + +Symbol: FPU_IRQHandler + Definitions + At line 386 in file startup_stm32l476xx.s + Uses + At line 158 in file startup_stm32l476xx.s + At line 304 in file startup_stm32l476xx.s + +HardFault_Handler 0000000A + +Symbol: HardFault_Handler + Definitions + At line 185 in file startup_stm32l476xx.s + + + +ARM Macro Assembler Page 7 Alphabetic symbol ordering +Relocatable symbols + + Uses + At line 62 in file startup_stm32l476xx.s + At line 186 in file startup_stm32l476xx.s + +I2C1_ER_IRQHandler 0000001A + +Symbol: I2C1_ER_IRQHandler + Definitions + At line 338 in file startup_stm32l476xx.s + Uses + At line 109 in file startup_stm32l476xx.s + At line 256 in file startup_stm32l476xx.s + +I2C1_EV_IRQHandler 0000001A + +Symbol: I2C1_EV_IRQHandler + Definitions + At line 337 in file startup_stm32l476xx.s + Uses + At line 108 in file startup_stm32l476xx.s + At line 255 in file startup_stm32l476xx.s + +I2C2_ER_IRQHandler 0000001A + +Symbol: I2C2_ER_IRQHandler + Definitions + At line 340 in file startup_stm32l476xx.s + Uses + At line 111 in file startup_stm32l476xx.s + At line 258 in file startup_stm32l476xx.s + +I2C2_EV_IRQHandler 0000001A + +Symbol: I2C2_EV_IRQHandler + Definitions + At line 339 in file startup_stm32l476xx.s + Uses + At line 110 in file startup_stm32l476xx.s + At line 257 in file startup_stm32l476xx.s + +I2C3_ER_IRQHandler 0000001A + +Symbol: I2C3_ER_IRQHandler + Definitions + At line 379 in file startup_stm32l476xx.s + Uses + At line 150 in file startup_stm32l476xx.s + At line 297 in file startup_stm32l476xx.s + +I2C3_EV_IRQHandler 0000001A + +Symbol: I2C3_EV_IRQHandler + Definitions + At line 378 in file startup_stm32l476xx.s + Uses + At line 149 in file startup_stm32l476xx.s + At line 296 in file startup_stm32l476xx.s + +LCD_IRQHandler 0000001A + + + +ARM Macro Assembler Page 8 Alphabetic symbol ordering +Relocatable symbols + + +Symbol: LCD_IRQHandler + Definitions + At line 384 in file startup_stm32l476xx.s + Uses + At line 155 in file startup_stm32l476xx.s + At line 302 in file startup_stm32l476xx.s + +LPTIM1_IRQHandler 0000001A + +Symbol: LPTIM1_IRQHandler + Definitions + At line 371 in file startup_stm32l476xx.s + Uses + At line 142 in file startup_stm32l476xx.s + At line 289 in file startup_stm32l476xx.s + +LPTIM2_IRQHandler 0000001A + +Symbol: LPTIM2_IRQHandler + Definitions + At line 372 in file startup_stm32l476xx.s + Uses + At line 143 in file startup_stm32l476xx.s + At line 290 in file startup_stm32l476xx.s + +LPUART1_IRQHandler 0000001A + +Symbol: LPUART1_IRQHandler + Definitions + At line 376 in file startup_stm32l476xx.s + Uses + At line 147 in file startup_stm32l476xx.s + At line 294 in file startup_stm32l476xx.s + +MemManage_Handler 0000000C + +Symbol: MemManage_Handler + Definitions + At line 190 in file startup_stm32l476xx.s + Uses + At line 63 in file startup_stm32l476xx.s + At line 191 in file startup_stm32l476xx.s + +NMI_Handler 00000008 + +Symbol: NMI_Handler + Definitions + At line 180 in file startup_stm32l476xx.s + Uses + At line 61 in file startup_stm32l476xx.s + At line 181 in file startup_stm32l476xx.s + +OTG_FS_IRQHandler 0000001A + +Symbol: OTG_FS_IRQHandler + Definitions + At line 373 in file startup_stm32l476xx.s + Uses + + + +ARM Macro Assembler Page 9 Alphabetic symbol ordering +Relocatable symbols + + At line 144 in file startup_stm32l476xx.s + At line 291 in file startup_stm32l476xx.s + +PVD_PVM_IRQHandler 0000001A + +Symbol: PVD_PVM_IRQHandler + Definitions + At line 307 in file startup_stm32l476xx.s + Uses + At line 78 in file startup_stm32l476xx.s + At line 225 in file startup_stm32l476xx.s + +PendSV_Handler 00000016 + +Symbol: PendSV_Handler + Definitions + At line 213 in file startup_stm32l476xx.s + Uses + At line 73 in file startup_stm32l476xx.s + At line 214 in file startup_stm32l476xx.s + +QUADSPI_IRQHandler 0000001A + +Symbol: QUADSPI_IRQHandler + Definitions + At line 377 in file startup_stm32l476xx.s + Uses + At line 148 in file startup_stm32l476xx.s + At line 295 in file startup_stm32l476xx.s + +RCC_IRQHandler 0000001A + +Symbol: RCC_IRQHandler + Definitions + At line 311 in file startup_stm32l476xx.s + Uses + At line 82 in file startup_stm32l476xx.s + At line 229 in file startup_stm32l476xx.s + +RNG_IRQHandler 0000001A + +Symbol: RNG_IRQHandler + Definitions + At line 385 in file startup_stm32l476xx.s + Uses + At line 157 in file startup_stm32l476xx.s + At line 303 in file startup_stm32l476xx.s + +RTC_Alarm_IRQHandler 0000001A + +Symbol: RTC_Alarm_IRQHandler + Definitions + At line 347 in file startup_stm32l476xx.s + Uses + At line 118 in file startup_stm32l476xx.s + At line 265 in file startup_stm32l476xx.s + +RTC_WKUP_IRQHandler 0000001A + + + + +ARM Macro Assembler Page 10 Alphabetic symbol ordering +Relocatable symbols + +Symbol: RTC_WKUP_IRQHandler + Definitions + At line 309 in file startup_stm32l476xx.s + Uses + At line 80 in file startup_stm32l476xx.s + At line 227 in file startup_stm32l476xx.s + +Reset_Handler 00000000 + +Symbol: Reset_Handler + Definitions + At line 167 in file startup_stm32l476xx.s + Uses + At line 60 in file startup_stm32l476xx.s + At line 168 in file startup_stm32l476xx.s + +SAI1_IRQHandler 0000001A + +Symbol: SAI1_IRQHandler + Definitions + At line 380 in file startup_stm32l476xx.s + Uses + At line 151 in file startup_stm32l476xx.s + At line 298 in file startup_stm32l476xx.s + +SAI2_IRQHandler 0000001A + +Symbol: SAI2_IRQHandler + Definitions + At line 381 in file startup_stm32l476xx.s + Uses + At line 152 in file startup_stm32l476xx.s + At line 299 in file startup_stm32l476xx.s + +SDMMC1_IRQHandler 0000001A + +Symbol: SDMMC1_IRQHandler + Definitions + At line 355 in file startup_stm32l476xx.s + Uses + At line 126 in file startup_stm32l476xx.s + At line 273 in file startup_stm32l476xx.s + +SPI1_IRQHandler 0000001A + +Symbol: SPI1_IRQHandler + Definitions + At line 341 in file startup_stm32l476xx.s + Uses + At line 112 in file startup_stm32l476xx.s + At line 259 in file startup_stm32l476xx.s + +SPI2_IRQHandler 0000001A + +Symbol: SPI2_IRQHandler + Definitions + At line 342 in file startup_stm32l476xx.s + Uses + At line 113 in file startup_stm32l476xx.s + + + +ARM Macro Assembler Page 11 Alphabetic symbol ordering +Relocatable symbols + + At line 260 in file startup_stm32l476xx.s + +SPI3_IRQHandler 0000001A + +Symbol: SPI3_IRQHandler + Definitions + At line 357 in file startup_stm32l476xx.s + Uses + At line 128 in file startup_stm32l476xx.s + At line 275 in file startup_stm32l476xx.s + +SVC_Handler 00000012 + +Symbol: SVC_Handler + Definitions + At line 204 in file startup_stm32l476xx.s + Uses + At line 70 in file startup_stm32l476xx.s + At line 205 in file startup_stm32l476xx.s + +SWPMI1_IRQHandler 0000001A + +Symbol: SWPMI1_IRQHandler + Definitions + At line 382 in file startup_stm32l476xx.s + Uses + At line 153 in file startup_stm32l476xx.s + At line 300 in file startup_stm32l476xx.s + +SysTick_Handler 00000018 + +Symbol: SysTick_Handler + Definitions + At line 217 in file startup_stm32l476xx.s + Uses + At line 74 in file startup_stm32l476xx.s + At line 218 in file startup_stm32l476xx.s + +TAMP_STAMP_IRQHandler 0000001A + +Symbol: TAMP_STAMP_IRQHandler + Definitions + At line 308 in file startup_stm32l476xx.s + Uses + At line 79 in file startup_stm32l476xx.s + At line 226 in file startup_stm32l476xx.s + +TIM1_BRK_TIM15_IRQHandler 0000001A + +Symbol: TIM1_BRK_TIM15_IRQHandler + Definitions + At line 330 in file startup_stm32l476xx.s + Uses + At line 101 in file startup_stm32l476xx.s + At line 248 in file startup_stm32l476xx.s + +TIM1_CC_IRQHandler 0000001A + +Symbol: TIM1_CC_IRQHandler + + + +ARM Macro Assembler Page 12 Alphabetic symbol ordering +Relocatable symbols + + Definitions + At line 333 in file startup_stm32l476xx.s + Uses + At line 104 in file startup_stm32l476xx.s + At line 251 in file startup_stm32l476xx.s + +TIM1_TRG_COM_TIM17_IRQHandler 0000001A + +Symbol: TIM1_TRG_COM_TIM17_IRQHandler + Definitions + At line 332 in file startup_stm32l476xx.s + Uses + At line 103 in file startup_stm32l476xx.s + At line 250 in file startup_stm32l476xx.s + +TIM1_UP_TIM16_IRQHandler 0000001A + +Symbol: TIM1_UP_TIM16_IRQHandler + Definitions + At line 331 in file startup_stm32l476xx.s + Uses + At line 102 in file startup_stm32l476xx.s + At line 249 in file startup_stm32l476xx.s + +TIM2_IRQHandler 0000001A + +Symbol: TIM2_IRQHandler + Definitions + At line 334 in file startup_stm32l476xx.s + Uses + At line 105 in file startup_stm32l476xx.s + At line 252 in file startup_stm32l476xx.s + +TIM3_IRQHandler 0000001A + +Symbol: TIM3_IRQHandler + Definitions + At line 335 in file startup_stm32l476xx.s + Uses + At line 106 in file startup_stm32l476xx.s + At line 253 in file startup_stm32l476xx.s + +TIM4_IRQHandler 0000001A + +Symbol: TIM4_IRQHandler + Definitions + At line 336 in file startup_stm32l476xx.s + Uses + At line 107 in file startup_stm32l476xx.s + At line 254 in file startup_stm32l476xx.s + +TIM5_IRQHandler 0000001A + +Symbol: TIM5_IRQHandler + Definitions + At line 356 in file startup_stm32l476xx.s + Uses + At line 127 in file startup_stm32l476xx.s + At line 274 in file startup_stm32l476xx.s + + + +ARM Macro Assembler Page 13 Alphabetic symbol ordering +Relocatable symbols + + +TIM6_DAC_IRQHandler 0000001A + +Symbol: TIM6_DAC_IRQHandler + Definitions + At line 360 in file startup_stm32l476xx.s + Uses + At line 131 in file startup_stm32l476xx.s + At line 278 in file startup_stm32l476xx.s + +TIM7_IRQHandler 0000001A + +Symbol: TIM7_IRQHandler + Definitions + At line 361 in file startup_stm32l476xx.s + Uses + At line 132 in file startup_stm32l476xx.s + At line 279 in file startup_stm32l476xx.s + +TIM8_BRK_IRQHandler 0000001A + +Symbol: TIM8_BRK_IRQHandler + Definitions + At line 349 in file startup_stm32l476xx.s + Uses + At line 120 in file startup_stm32l476xx.s + At line 267 in file startup_stm32l476xx.s + +TIM8_CC_IRQHandler 0000001A + +Symbol: TIM8_CC_IRQHandler + Definitions + At line 352 in file startup_stm32l476xx.s + Uses + At line 123 in file startup_stm32l476xx.s + At line 270 in file startup_stm32l476xx.s + +TIM8_TRG_COM_IRQHandler 0000001A + +Symbol: TIM8_TRG_COM_IRQHandler + Definitions + At line 351 in file startup_stm32l476xx.s + Uses + At line 122 in file startup_stm32l476xx.s + At line 269 in file startup_stm32l476xx.s + +TIM8_UP_IRQHandler 0000001A + +Symbol: TIM8_UP_IRQHandler + Definitions + At line 350 in file startup_stm32l476xx.s + Uses + At line 121 in file startup_stm32l476xx.s + At line 268 in file startup_stm32l476xx.s + +TSC_IRQHandler 0000001A + +Symbol: TSC_IRQHandler + Definitions + + + +ARM Macro Assembler Page 14 Alphabetic symbol ordering +Relocatable symbols + + At line 383 in file startup_stm32l476xx.s + Uses + At line 154 in file startup_stm32l476xx.s + At line 301 in file startup_stm32l476xx.s + +UART4_IRQHandler 0000001A + +Symbol: UART4_IRQHandler + Definitions + At line 358 in file startup_stm32l476xx.s + Uses + At line 129 in file startup_stm32l476xx.s + At line 276 in file startup_stm32l476xx.s + +UART5_IRQHandler 0000001A + +Symbol: UART5_IRQHandler + Definitions + At line 359 in file startup_stm32l476xx.s + Uses + At line 130 in file startup_stm32l476xx.s + At line 277 in file startup_stm32l476xx.s + +USART1_IRQHandler 0000001A + +Symbol: USART1_IRQHandler + Definitions + At line 343 in file startup_stm32l476xx.s + Uses + At line 114 in file startup_stm32l476xx.s + At line 261 in file startup_stm32l476xx.s + +USART2_IRQHandler 0000001A + +Symbol: USART2_IRQHandler + Definitions + At line 344 in file startup_stm32l476xx.s + Uses + At line 115 in file startup_stm32l476xx.s + At line 262 in file startup_stm32l476xx.s + +USART3_IRQHandler 0000001A + +Symbol: USART3_IRQHandler + Definitions + At line 345 in file startup_stm32l476xx.s + Uses + At line 116 in file startup_stm32l476xx.s + At line 263 in file startup_stm32l476xx.s + +UsageFault_Handler 00000010 + +Symbol: UsageFault_Handler + Definitions + At line 200 in file startup_stm32l476xx.s + Uses + At line 65 in file startup_stm32l476xx.s + At line 201 in file startup_stm32l476xx.s + + + + +ARM Macro Assembler Page 15 Alphabetic symbol ordering +Relocatable symbols + +WWDG_IRQHandler 0000001A + +Symbol: WWDG_IRQHandler + Definitions + At line 306 in file startup_stm32l476xx.s + Uses + At line 77 in file startup_stm32l476xx.s + At line 224 in file startup_stm32l476xx.s + +93 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +Absolute symbols + +Heap_Size 00000800 + +Symbol: Heap_Size + Definitions + At line 42 in file startup_stm32l476xx.s + Uses + At line 46 in file startup_stm32l476xx.s +Comment: Heap_Size used once +Stack_Size 00001000 + +Symbol: Stack_Size + Definitions + At line 31 in file startup_stm32l476xx.s + Uses + At line 34 in file startup_stm32l476xx.s +Comment: Stack_Size used once +__Vectors_Size 00000188 + +Symbol: __Vectors_Size + Definitions + At line 162 in file startup_stm32l476xx.s + Uses + At line 57 in file startup_stm32l476xx.s +Comment: __Vectors_Size used once +3 symbols + + + +ARM Macro Assembler Page 1 Alphabetic symbol ordering +External symbols + +SystemInit 00000000 + +Symbol: SystemInit + Definitions + At line 169 in file startup_stm32l476xx.s + Uses + At line 172 in file startup_stm32l476xx.s +Comment: SystemInit used once +__main 00000000 + +Symbol: __main + Definitions + At line 170 in file startup_stm32l476xx.s + Uses + At line 174 in file startup_stm32l476xx.s +Comment: __main used once +2 symbols +444 symbols in table diff --git a/User/application/inc/mode_pwmp_hd.h b/User/application/inc/mode_pwmp_hd.h index a69483e..ae14d51 100644 --- a/User/application/inc/mode_pwmp_hd.h +++ b/User/application/inc/mode_pwmp_hd.h @@ -1,59 +1,108 @@ #ifndef __MODE_PWMP_HD_H__ #define __MODE_PWMP_HD_H__ #include "main.h" +#include "filter.h" -#define MODE_DEFAULT_AUTOLOAD 99 // 预分频系数 -#define WAIT_COUNT_MAX 10 // 蓝牙等待最大次数 - -#define VIP_H_EN_HD 1 // 高电压输出开关 -///////////////////////////////////////*算法整定部分宏定义BEGIN*//////////////////////////////////////// - -#define TIME_CYCLE 0.01f // 定义时间周期:10ms +/*********************************** 宏定义 ***********************************/ #define FSM_WAIT(st) BIT_SET(st, BIT7) #define FSM_IS_WAIT(st) (st & BIT7) -#define DIFF_ADC_MAX 10U -///////////////////////////////////////*算法整定部分宏定义END*/////////////////////////////////////////// +#define EXECUTE_PLAN EXECUTE_PLAN_1 // 执行方案 +#define CON_MAX 4095 // 驱动最大值 +#define CON_MIN 0 // 驱动最小值 -#define EXECUTE_PLAN EXECUTE_PLAN_1 - -/*----------------------------------------*/ +/************************************ 枚举 ************************************/ +// 模式任务 typedef enum { - PWMP_HD_PROCESS_CONTROL, - PWMP_HD_PROCESS_ADJUST, - PWMP_HD_PROCESS_TEST, - PWMP_HD_PROCESS_STOP, -} mode_pwmp_hd_process_state_e; // 处理状态 + MINOR_PROCESS_CONTROL, // 控制 + MINOR_PROCESS_ADJUST, // 整定 + MINOR_PROCESS_TEST, // 测试 + MINOR_PROCESS_STOP, // 停止 +} mode_minor_process_state_e; -/*需要存储的变量*/ +// 算法方案 +typedef enum +{ + EXECUTE_PLAN_1, + EXECUTE_PLAN_2, + EXECUTE_PLAN_3, + EXECUTE_PLAN_4, +} execute_plan_minor_e; + +// 执行标志 +typedef enum +{ + EXECUTE_NONE = 0, // 不执行输出 + EXECUTE_OUT = 1, // 执行输出 +} execute_e; + +// 整定状态 +typedef enum +{ + ADJUST_DISABLE, // 整定禁用 + ADJUST_ONGING, // 整定进行中 + ADJUST_OK, // 整定成功 + +} minor_adjust_state_e; + +// 整定步骤 +typedef enum +{ + MINOR_ADJUST_IDEL, + MINOR_ADJUST_OVER, + +} minor_adjust_step_e; + +/*********************************** 结构体 ***********************************/ +// 滤波器 typedef struct { - uint8_t tuned_flag; // 是否整定过 1:整定过 0:未整定过 - uint8_t tuned_state; // 自整定结果 + lpf_window_t *handle; + uint16_t value; - uint16_t startup_value; // 阀位启动值 - uint16_t arr_diff; // 控制区间 - uint16_t ad_diff; // 磁条区间 - uint16_t pwmp_min; // 控制最小值 - uint16_t pwmp_max; // 控制最大值 - uint16_t pwmp_min_origin;// 整定控制最小值 - uint16_t pwmp_max_origin;// 整定控制最大值 - uint16_t trip_0; // 磁条0位置AD - uint16_t trip_100; // 词条100位置AD - uint16_t trip_min0; // 小回路行程0位置AD - uint16_t trip_min100; // 小回路行程100位置AD - uint16_t current0; // 电流最小值 - uint16_t current100; // 电流最大值 - uint16_t all_open_time; // 全开时间 - uint16_t all_close_time; // 全关时间 - uint16_t prov_flag; // 磁条安装的正反:倒装:0 正装:1 - uint16_t valve_type; // 阀门正反行程:气开:ATO 气关:ATC - float32 kp; - float32 ki; - float32 kd; +} minor_filter_t; + +// 执行器 +typedef struct +{ + execute_e code; // 执行标志 + uint16_t dac; // 输出值 +} execute_rsp_t; + +// 存储数据 +typedef struct +{ } mode_pwmp_hd_storage_data_t; +typedef union +{ + uint8_t data[128]; + mode_pwmp_hd_storage_data_t storage; + +} mode_pwmp_hd_params_u; + +// 测试任务 +typedef struct +{ + uint16_t output; + uint16_t travel_adc; + uint16_t minor_adc; + float32 drive_current; + +} minor_test_t; + +// 整定任务 +typedef struct +{ + BOOL enable; // 整定使能 + minor_adjust_step_e step; // 当前整定步骤 + minor_adjust_step_e next_step; // 下个整定步骤 + minor_adjust_step_e execute_step; // 执行整定步骤 + +} minor_adjust_t; + +// 控制任务 typedef struct { __IO uint32_t enter_count; // 用于100ms蓝牙输出计时器 @@ -61,217 +110,30 @@ typedef struct float32 ctrl_feedback; // 反馈值 float32 real_error; // 实际误差 uint16_t current_adc; // 当前ADC值 -} mode_pwmp_hd_control_t; -/*滤波处理*/ +} minor_control_t; + +// 小回路模式句柄 typedef struct { - lpf_t actual_lpf; - lpf_t target_lpf; - lpf_window_t *handle; -} mode_pwmp_hd_filter_t; + uint8_t process_state; // 当前任务 + uint8_t adjust_state; // 整定状态 + minor_filter_t target_lpf; // 目标滤波器 + minor_filter_t actual_lpf; // 实际滤波器 + execute_rsp_t execute; // 执行器 + minor_test_t test; // 测试任务 + minor_adjust_t adjust; // 整定任务 + minor_control_t control; // 控制任务 + mode_pwmp_hd_params_u *save; // 存储数据 + void (*params_save_cb)(void); // 存储函数 +} mode_minor_t; -typedef union -{ - uint8_t data[128]; - // 自定义数据结构 - mode_pwmp_hd_storage_data_t storage; -} mode_pwmp_hd_params_u; +/*********************************** 外部声明 ***********************************/ +extern mode_minor_t *mode_minor; -typedef struct -{ - uint8_t lcd_adjust_state; // LCD自整定流程状态 - float32 duty_percent; // 占空比 - float32 current_electric; // 电流 +void mode_minor_init(uint16_t positioner_model, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void)); +void mode_minor_dinit(void); +void mode_minor_process(void); +void minor_process_state_set(mode_minor_process_state_e state); - uint8_t auto_tune_state; // 自整定状态 0:未整定 1:整定中 2:整定完成 3:整定失败 - uint16_t wait_count_max; // 等待次数最大值 - uint16_t arr_default; // 默认值array,推动值 - uint8_t process_state; // 处理状态 - uint8_t adjust_state; // 整定状态 - uint16_t output; // 输出值 - uint16_t current_adc; // 当前位置反馈的AD值 - uint32_t count; // 计数 - - mode_pwmp_hd_control_t control; - mode_pwmp_hd_filter_t filter; - mode_pwmp_hd_params_u *pwmp_save; - void (*params_save_cb)(void); -} mode_pwmp_hd_t; - -/////////////////////////////////////////*共用部分BEGIN*//////////////////////////////////////////////// - -typedef enum -{ - PWMP_HD_ADJUST_IDEL, - PWMP_HD_ADJUST_ROUGH_POSITION0, // 粗调位置0 - PWMP_HD_ADJUST_ACCURATE_POSITION0, // 精调位置0 - PWMP_HD_ADJUST_ROUGH_POSITION100, // 粗调位置100 - PWMP_HD_ADJUST_ACCURATE_POSITION100, // 精调位置100 - PWMP_HD_ADJUST_ALL_CLOSE_TIME, // 全关时间 - PWMP_HD_ADJUST_ALL_OPEN_TIME, // 全开时间 - PWMP_HD_ADJUST_CALCULATE, // 阀门参数计算 - PWMP_HD_ADJUST_PID_CALCULATE, // PID参数计算 - PWMP_HD_ADJUST_PID_TUNING, // PID参数自整定过程(整定得到K、T、L) - PWMP_HD_ADJUST_SAVE, // 存储变量 - PWMP_HD_ADJUST_BLEEDING, // 在整定状态中放气 - PWMP_HD_ADJUST_BLEEDING_POSITION0, // 放气位置0 - PWMP_HD_ADJUST_STOP, - PWMP_HD_ADJUST_FAIL, // 整定失败 - PWMP_HD_ADJUST_TEST, - PWMP_HD_ADJUST_BLEEDING_TIMER, - PWMP_HD_ADJUST_AERATE_TIMER, - PWMP_HD_ADJUST_TUNING, -} mode_pwmp_hd_adjust_state_e; // 整定状态 - -#define PWMP_HD_ADJUST_STEP LCD_ADJUST_STOP // 整定步骤 - -typedef enum -{ - // 自整定结果 0:未整定 1:整定中 2:整定完成 3:整定失败 - PWMP_HD_ADJUST_RESULT_IDEL = 0, - PWMP_HD_ADJUST_RESULT_TUNING, - PWMP_HD_ADJUST_RESULT_SUCCESS, - PWMP_HD_ADJUST_RESULT_FAIL, -} mode_pwmp_hd_adjust_result_e; // 整定结果 - -typedef struct -{ - mode_pwmp_hd_adjust_state_e adjust_state; - - volatile uint16_t wait_count; - volatile uint16_t psb_adc; - volatile uint16_t last_adc; - uint8_t adc_count; - BOOL preheat; - - BOOL adc_0_100_flag; // 判断0-100移动过程中ad值是增大还是减少,TRUE 增大,FALSE 减小 - uint16_t adc_record_0; // 记录放气时阀门最小位置ad值 - uint16_t adc_record_1; // 记录放气时阀门最小位置ad值 - uint16_t adc_record_2; // 记录充气时阀门最大位置ad值 - - uint16_t arr_record_0; // 最低位置阀门的ad值 - uint16_t arr_record_1; // 最小推动阀门的ad值 - uint16_t arr_record_2; // 最大位置阀门的ad值 - - uint32_t all_open_time; // 全开时间 - uint32_t all_open_time_full; // 信号为最大输出时的全开时间 - uint32_t all_close_time; // 全关时间 - BOOL all_close_time_flag; - uint32_t tmp_time; // 临时用来记录全开全关/整定时间 - - /*输出值*/ - uint16_t arr_default; // 默认计数器(推动计数值) - volatile uint16_t arr_current; // 当前推动阀门的计数器 - volatile uint16_t arr_last; // 上一次计数器值 -} pwmp_hd_adjust_t; - -/////////////////////////////////////////*共用部分END*////////////////////////////////////////////////// - -/////////////////////////////////////////*PID参数自整定部分BEGIN*//////////////////////////////////////// -/*PID整定方法*/ -typedef enum -{ - PID_AUTOTUNE_WAY_ZN = 1, - PID_AUTOTUNE_WAY_CC, -} pid_autotune_way_e; - -/*阶跃信号大小*/ -typedef enum -{ - FULL_TRIP = 1, - HALF_TRIP, - SMALL_TRIP, -} step_signal_value; - -/*PID整定过程数据*/ -typedef struct -{ - float32 pre_actual; // 前一次的行程 - float32 cur_actual; // 当前的行程 - float32 adjust_tmp_actual; // 临时行程 - float32 actual_error; // 行程的误差 - float32 step_signal; // 阶跃信号 - float32 step_signal_delt; // 阶跃信号差值 - float32 ouput_signal_delta; // 输出信号差值 - float32 input_range; // 输入范围 - float32 output_range; // 输出范围 - float32 input_scale; // 输入比例 - float32 output_scale; // 输出比例 - float32 slope; // 变化率 - float32 slope_Max; // 最大变化率 - float32 actual_slope_Max; // 最大变化率时的行程 - uint32_t pid_autotune_time_origin; // PID自整定初始时间 - uint32_t time_slope_Max; // 最大变化率时的时间节点 - uint32_t time_Runing; // 自整定程序运行的总时间 - float32 actual_stable; // 稳定时的阀位 - float32 k; // 切线斜率 - float32 b; // 切线截距 -} pid_auto_process_data; - -/*PID参数自整定主体结构体*/ -typedef struct PID_AUTOTUNE_HD -{ - uint8_t autotune_way; // 整定的方式 - uint8_t signal_value; // 阶跃信号的大小 - float32 k_hd; // 增益 - float32 t_hd; // 时间常数 - float32 l_hd; // 延时时间 - float32 p_auto_hd; // 整定输出的P参数 - float32 i_auto_hd; // 整定输出的I参数 - float32 d_auto_hd; // 整定输出的D参数 - float32 ti_auto_hd; // 整定得到的积分时间 - float32 td_auto_hd; // 整定得到的微分时间 - pid_auto_process_data data; // 过程数据 - lpf_t actual_auto_lpf; // 滤波后的行程 -} pid_autotune_hd_t; - -/////////////////////////////////////////*PID参数自整定部分END*//////////////////////////////////////// - -/////////////////////////////////////////*控制算法BEGIN*//////////////////////////////////////// -typedef enum -{ - EXECUTE_PLAN_1, - EXECUTE_PLAN_2, - EXECUTE_PLAN_3, - EXECUTE_PLAN_4, -} execute_plan_hd_e; - -/// 操作标志 -typedef enum -{ - EXECUTE_HD_NONE = 0, ///< 不执行任何操作 - EXECUTE_HD_OUT = 1, ///< 执行输出 -} execute_hd_e; - -/// 返回内容 -typedef struct -{ - execute_hd_e code; ///< 操作标志 - uint16_t dac; ///< DAC值 -} execute_rsp_hd_t; -/////////////////////////////////////////*控制算法END*//////////////////////////////////////// - -void mode_pwmp_hd_init(uint16_t positioner_model, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void)); -void mode_pwmp_hd_dinit(void); -void mode_pwmp_hd_process(void); -void pwmp_hd_process_state_set(mode_pwmp_hd_process_state_e state); -// extern void pwmp_control_update(filter_e type); -extern mode_pwmp_hd_t *mode_pwmp_hd; #endif // __MODE_PWMP_HD_H__ - -/* 控制范围 -* 实验室大阀(气关): static int16_t mode_pwmp->pwmp_save->storage.pwmp_min = 613; - static int16_t mode_pwmp->pwmp_save->storage.pwmp_max = 900; - - 实验台中型阀(气开): static int16_t mode_pwmp->pwmp_save->storage.pwmp_min = 1100; - static int16_t mode_pwmp->pwmp_save->storage.pwmp_max = 2000; -*/ - -/*位置传感器区间 -实验室大阀(60mm,气关): uDevice.TravelVol100 = 1547; - uDevice.TravelVol0 = 2520; - -流量实验室中型阀(40mm,气开): uDevice.TravelVol100 = 1583; - uDevice.TravelVol0 = 2506; -*/ diff --git a/User/application/inc/pdctrl.h b/User/application/inc/pdctrl.h index 9cc0672..442c0fe 100644 --- a/User/application/inc/pdctrl.h +++ b/User/application/inc/pdctrl.h @@ -27,7 +27,7 @@ typedef enum PDCTRL_DAC = 1, // DAC输出模式 PDCTRL_PWM = 2, // PWM输出模式 PDCTRL_PWMP = 3, // PWM占空比模式 - PDCTRL_PWMP_HD = 4, // PWM占空比模式 + PDCTRL_MINOR = 4, // PWM占空比模式 } pdctrl_mode_e; typedef struct diff --git a/User/application/src/mode.c b/User/application/src/mode.c index bb39de2..9dff7f4 100644 --- a/User/application/src/mode.c +++ b/User/application/src/mode.c @@ -172,9 +172,9 @@ void alog_control_module(void) { mode_pwmp_process(); } - else if (uDevice.SpecControlOutputMode == PDCTRL_PWMP_HD) + else if (uDevice.SpecControlOutputMode == PDCTRL_MINOR) { - mode_pwmp_hd_process(); + mode_minor_process(); } else { @@ -205,8 +205,8 @@ void mode_adjust_start(void) case PDCTRL_PWMP: break; - case PDCTRL_PWMP_HD: - pwmp_hd_process_state_set(PWMP_HD_PROCESS_ADJUST); + case PDCTRL_MINOR: + minor_process_state_set(MINOR_PROCESS_ADJUST); break; default: break; @@ -228,8 +228,8 @@ void mode_adjust_stop(void) break; case PDCTRL_PWMP: break; - case PDCTRL_PWMP_HD: - pwmp_hd_process_state_set(PWMP_HD_PROCESS_STOP); + case PDCTRL_MINOR: + minor_process_state_set(MINOR_PROCESS_STOP); break; default: break; @@ -390,19 +390,8 @@ void mode_adjust_data_get(mode_adjust_data_t *data) { break; } - case PDCTRL_PWMP_HD: + case PDCTRL_MINOR: { - data->pos0 = mode_params.mode_pwmp_hd_params.storage.trip_0; ///< 位置0 ad - data->pos100 = mode_params.mode_pwmp_hd_params.storage.trip_100; ///< 位置100 ad - data->pot0 = mode_params.mode_pwmp_hd_params.storage.pwmp_min; ///< 位置0 输出 - data->pot100 = mode_params.mode_pwmp_hd_params.storage.pwmp_max; ///< 位置100 输出 - data->current0 = mode_params.mode_pwmp_hd_params.storage.current0; ///< 位置0 电流(毫安,放大100倍, 0.01ma=1) - data->current100 = mode_params.mode_pwmp_hd_params.storage.current100; ///< 位置100 电流(毫安,放大100倍,0.01ma=1) - data->open_time = mode_params.mode_pwmp_hd_params.storage.all_open_time; ///< 全开时间(秒) - data->close_time = mode_params.mode_pwmp_hd_params.storage.all_close_time; ///< 全关时间(秒) - data->kp = mode_params.mode_pwmp_hd_params.storage.kp; ///< pid 比例系数 - data->ki = mode_params.mode_pwmp_hd_params.storage.ki; ///< pid 积分系数 - data->kd = mode_params.mode_pwmp_hd_params.storage.kd; ///< pid 微分系数 break; } default: @@ -422,7 +411,7 @@ void mode_init(void) mode_dac_dinit(); mode_pwm_dinit(); mode_pwmp_dinit(); - mode_pwmp_hd_dinit(); + mode_minor_dinit(); if (uDevice.SpecControlOutputMode == PDCTRL_DAC) { @@ -433,10 +422,10 @@ void mode_init(void) else if (uDevice.SpecControlOutputMode == PDCTRL_PWMP) { } - else if (uDevice.SpecControlOutputMode == PDCTRL_PWMP_HD) + else if (uDevice.SpecControlOutputMode == PDCTRL_MINOR) { - pdctrl_init(PDCTRL_PWMP_HD); - mode_pwmp_hd_init(uDevice.positioner_model, &mode_params.mode_pwmp_hd_params, mode_params_save_cb); + pdctrl_init(PDCTRL_MINOR); + mode_minor_init(uDevice.positioner_model, &mode_params.mode_pwmp_hd_params, mode_params_save_cb); } else { diff --git a/User/application/src/mode_pwmp_hd.c b/User/application/src/mode_pwmp_hd.c index 1487a20..33e00f3 100644 --- a/User/application/src/mode_pwmp_hd.c +++ b/User/application/src/mode_pwmp_hd.c @@ -1,212 +1,30 @@ #include #include -#include "sys.h" -#include "dacs.h" -#include "board.h" -#include "../inc/mode_pwmp_hd.h" -#include "delay.h" -#include "at_hc24.h" -#include "entity.h" -#include "eeprom_m95.h" -#include "pid.h" -#include "filter.h" #include #include +#include "mode_pwmp_hd.h" +#include "mode.h" +#include "entity.h" +#include "board.h" #include "pdctrl.h" -#include "app.h" -#include "data_type_def.h" +#include "pid.h" +#include "convert.h" +#include "at_hc24.h" -#define ACTUAL_FILTER 0 +mode_minor_t *mode_minor; -mode_pwmp_hd_t *mode_pwmp_hd; -pwmp_hd_adjust_t *mode_pwmp_hd_adjust; -pid_autotune_hd_t *pid_autotune_hd; -execute_rsp_hd_t rsp; // 执行结果 +static execute_rsp_t *execute_dac_plan1(void); // 执行方案1 +static execute_rsp_t *execute_dac_plan2(void); // 执行方案2 +static execute_rsp_t *execute_dac_plan3(void); // 执行方案3 +static execute_rsp_t *execute_dac_plan4(void); // 执行方案4 -static execute_rsp_hd_t *execute_dac_plan1(void); // 执行方案1 -static execute_rsp_hd_t *execute_dac_plan2(void); // 执行方案2 -static execute_rsp_hd_t *execute_dac_plan3(void); // 执行方案3 -static execute_rsp_hd_t *execute_dac_plan4(void); // 执行方案4 -static uint8_t execute_run_count = 0; // 执行计数 - -/*程序状态设置*/ -void pwmp_hd_process_state_set(mode_pwmp_hd_process_state_e state) -{ - if (mode_pwmp_hd->process_state == state && mode_pwmp_hd->adjust_state == PWMP_HD_PROCESS_ADJUST) - { - mode_pwmp_hd->process_state = PWMP_HD_PROCESS_STOP; - } - else - { - mode_pwmp_hd->process_state = state; - switch (state) - { - case PWMP_HD_PROCESS_ADJUST: - mode_pwmp_hd->adjust_state = PWMP_HD_ADJUST_IDEL; - break; - default: - break; - } - } -} - -/*行程更新*/ -static void pwmp_control_update(filter_e type) -{ - mode_pwmp_hd_control_t *p = &mode_pwmp_hd->control; - actual_travel = get_actual_travel(type); - actual_travel = actual_travel_deal(actual_travel); - pid_actual = get_pid_travel(actual_travel); - - if (mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST) - { - p->ctrl_target = p->ctrl_target; - } - else - { - p->ctrl_target = lpf_window_update(mode_pwmp_hd->filter.handle, pid_target); - } -#if ACTUAL_FILTER == 1 - if (fabs(p->real_error) < 0.5) - { - p->ctrl_feedback = lpf_window_update(mode_pwmp_hd->filter.handle, pid_actual); - } - else - { - p->ctrl_feedback = pid_actual; - lpf_window_reset(mode_pwmp_hd->filter.handle); - } -#else - p->ctrl_feedback = pid_actual; -#endif - p->real_error = p->ctrl_target - p->ctrl_feedback; - p->current_adc = adc_raw[ADC_PSB_CHANNEL]; -} - -/*PID参数获取*/ -static float32 get_pwmp_hd_control_kp(void) -{ - if (mode_pwmp_hd->pwmp_save->storage.kp < 2) - { - return mode_pwmp_hd->pwmp_save->storage.kp * 10; - } - else - { - return mode_pwmp_hd->pwmp_save->storage.kp; - } -} - -static float32 get_pwmp_hd_control_ki(void) -{ - return mode_pwmp_hd->pwmp_save->storage.ki < 0.001 ? mode_pwmp_hd->pwmp_save->storage.ki * 10 : 0.018; -} - -static float32 get_pwmp_hd_control_kd(void) -{ - return mode_pwmp_hd->pwmp_save->storage.kd < 0.01 ? mode_pwmp_hd->pwmp_save->storage.kd : 0.005; -} - -/*将自己结构体变量中的参数保存到公共参数中*/ -static void pwmp_public_params_update() -{ - uDevice.TravelVol0 = mode_pwmp_hd->pwmp_save->storage.trip_0; - uDevice.TravelVol100 = mode_pwmp_hd->pwmp_save->storage.trip_100; - uDevice.DAC_Min = mode_pwmp_hd->pwmp_save->storage.pwmp_min; - uDevice.DAC_Max = mode_pwmp_hd->pwmp_save->storage.pwmp_max; - uDevice.MinorLoopVol0_Val = mode_pwmp_hd->pwmp_save->storage.trip_min0; - uDevice.MinorLoopVol100_Val = mode_pwmp_hd->pwmp_save->storage.trip_min100; - uDevice.APID_KP = mode_pwmp_hd->pwmp_save->storage.kp; - uDevice.APID_TI = mode_pwmp_hd->pwmp_save->storage.ki; - uDevice.APID_TD = mode_pwmp_hd->pwmp_save->storage.kd; - uDevice.ProcessChange_Flag = mode_pwmp_hd->pwmp_save->storage.prov_flag; - uDevice.eAirAction = mode_pwmp_hd->pwmp_save->storage.valve_type; -} - -/*程序反初始化*/ -void mode_pwmp_hd_dinit(void) -{ - if (mode_pwmp_hd != NULL) - { - pwmp_hd_process_state_set(PWMP_HD_PROCESS_STOP); - osel_mem_free(mode_pwmp_hd); - mode_pwmp_hd = NULL; - } -} - -/** - * @brief 是否完成了算法整定校验 - * @param {uint8_t} mode - * @return {*} - * @note - */ -BOOL pwmp_hd_algorithm_calibrated_status(void) -{ - return mode_pwmp_hd->pwmp_save->storage.tuned_flag == 1 && mode_pwmp_hd->pwmp_save->storage.tuned_state == LCD_ADJUST_RESULT_OK; -} - -/** - * @brief 获取整定结果 - * @return {*} - * @note - */ -uint8_t pwmp_hd_process_adjust_result_get(void) -{ - return mode_pwmp_hd->pwmp_save->storage.tuned_state; -} - -/** - * @brief 是否正在整定 - * @return {*} - * @note - */ -BOOL pwmp_hd_process_is_adjust(void) -{ - return mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST; -} - -/** - * @brief 获取整定状态 - * @return {*} - * @note - */ -uint8_t pwmp_hd_process_adjust_state_get(void) -{ - return mode_pwmp_hd->lcd_adjust_state; -} - -// 在进入PID控制区域不要绘图 -BOOL pwmp_hd_process_idel(void) -{ - if (mode_pwmp_hd->process_state == PWM_PROCESS_CONTROL) - { - // return fabsf(mode_pwmp_hd->control.real_error) <= get_dead_zone() || - // mode_pwmp_hd->control.stable_flag == TRUE - // ? TRUE - // : FALSE; - return TRUE; - } - else - { - return TRUE; - } -} -//////////////////////////////*控制BEGIN*////////////////////////////////////////////////////// - -/** - * @brief 算法方案初始化 - * @param {execute_plan_hd_e} plan - * @return {*} - * @note - */ -void execute_pid_init(execute_plan_hd_e plan) +/*********************************** 控制任务 ***********************************/ +// 算法方案初始化 +void minor_pid_init(execute_plan_minor_e plan) { switch (plan) { - // HD:位置式PID算法 case EXECUTE_PLAN_1: - _pid.type = PID_TYPE_CUSTOM_HANGDIAN; - pid_constructor(&_pid); - _pid.pid_u.hd.set_ctrl_prm_position(&_pid.pid_u.hd, get_pwmp_hd_control_kp(), get_pwmp_hd_control_ki(), get_pwmp_hd_control_kd()); break; case EXECUTE_PLAN_2: @@ -221,1186 +39,189 @@ void execute_pid_init(execute_plan_hd_e plan) } } -/** - * @brief 算法方案执行 - * @param {execute_plan_hd_e} plan - * @return {*} - * @note - */ -execute_rsp_hd_t *execute_dac(execute_plan_hd_e plan) +// 算法方案执行 +void execute_dac(execute_plan_minor_e plan) { switch (plan) { case EXECUTE_PLAN_1: - return execute_dac_plan1(); // 位置式PID + execute_dac_plan1(); case EXECUTE_PLAN_2: - return execute_dac_plan2(); + execute_dac_plan2(); case EXECUTE_PLAN_3: - return execute_dac_plan3(); + execute_dac_plan3(); case EXECUTE_PLAN_4: - return execute_dac_plan4(); + execute_dac_plan4(); default: - rsp.code = EXECUTE_HD_NONE; - return &rsp; + mode_minor->execute.code = EXECUTE_NONE; } } -static execute_rsp_hd_t *execute_dac_plan1() -{ - static float32 index_min = 0; // 加权系数,为了修正排气快的问题 - static float32 index_max = 0; - static float32 Control_diff; - Control_diff = mode_pwmp_hd->pwmp_save->storage.pwmp_max - mode_pwmp_hd->pwmp_save->storage.pwmp_min; - float32 out = 0.0; - - // 杭电:输出限幅的参数设置 - _pid.pid_u.hd.set_out_prm_position(&_pid.pid_u.hd, 100, 0); - - out = _pid.pid_u.hd.pid_position(&_pid.pid_u.hd, mode_pwmp_hd->control.real_error); - out = out / 100; // 对PID输出结果进行归一化处理 - out *= (mode_pwmp_hd->pwmp_save->storage.pwmp_max + Control_diff * index_max) - (mode_pwmp_hd->pwmp_save->storage.pwmp_min - Control_diff * index_min); // 映射实际控制器的范围 - out += mode_pwmp_hd->pwmp_save->storage.pwmp_min - Control_diff * index_min; // 对输出结果进行偏移处理 - - rsp.code = EXECUTE_HD_OUT; - rsp.dac = (uint32_t)out; - - /// 在执行了十次之后若系统认为稳定进入以下程序进行微调 - if (execute_run_count >= 10) - { - if (actual_travel < target_travel) - { - if (fabs(mode_pwmp_hd->control.real_error) < 1) - { - rsp.dac += (fabs(mode_pwmp_hd->control.real_error) * 30); - } - else if (fabs(mode_pwmp_hd->control.real_error) < 5) - { - rsp.dac += (fabs(mode_pwmp_hd->control.real_error) * 10); - } - else - { - execute_run_count = 0; - } - } - if (target_travel <= actual_travel) - { - // 若进入死区范围,那么停止计数,停止微调 - if (fabs(mode_pwmp_hd->control.real_error) <= 0.5) - { - execute_run_count = 0; - } - else - { - if (fabs(mode_pwmp_hd->control.real_error) < 1) - { - rsp.dac += -(fabs(mode_pwmp_hd->control.real_error) * 30); - } - else if (fabs(mode_pwmp_hd->control.real_error) < 5) - { - rsp.dac += -(fabs(mode_pwmp_hd->control.real_error) * 10); - } - else - { - execute_run_count = 0; - } - execute_run_count = 2; - } - } - } - else - { - execute_run_count++; - } - return &rsp; -} - -/// -/// -/// -/// -/// - -static execute_rsp_hd_t *execute_dac_plan2(void) +// 执行方案1 +static execute_rsp_t *execute_dac_plan1(void) { return 0; } -/// -/// -/// -/// - -static execute_rsp_hd_t *execute_dac_plan3() +// 执行方案2 +static execute_rsp_t *execute_dac_plan2(void) { return 0; } -/// -/// -/// -/// -static execute_rsp_hd_t *execute_dac_plan4() +// 执行方案3 +static execute_rsp_t *execute_dac_plan3(void) { return 0; } -//////////////////////////////*控制END*////////////////////////////////////////////////////// -//////////////////////////////*整定相关函数BEGIN*////////////////////////////////////////////////////// -/*PID自整定方法*/ -static void pid_autotune_way_set(pid_autotune_way_e state) +// 执行方案4 +static execute_rsp_t *execute_dac_plan4(void) { - pid_autotune_hd->autotune_way = state; + return 0; } -/*判断阀门状态:移动、停止、停止但仍在等待*/ -static valve_position_change_e pwmp_adjust_hd_valve_position_change(uint8_t *state, uint8_t next_state, uint8_t diff_adc_max) +// 控制进程 +static void mode_minor_control(void) { - uint16_t diff_adc = 0; - // uint16_t adc = get_actual_travel_adc(); - uint16_t adc = get_actual_travel_adc(); - pid_autotune_hd->data.adjust_tmp_actual = adc; - - if (mode_pwmp_hd_adjust->psb_adc != adc) - { - diff_adc = ABS(mode_pwmp_hd_adjust->psb_adc - adc); - } - - if (diff_adc > diff_adc_max) - { - // 位置还在改变,继续等待 - mode_pwmp_hd_adjust->psb_adc = adc; - return POSITION_CHANGE; - } - else - { - // 位置不变 - if (mode_pwmp_hd_adjust->wait_count == 0) - { - // 等待次数也到了,位置不再发生变化,可以切换下一个状态 - *state = next_state; - return POSITION_NO_CHANGE_FOREVER; - } - else - { // 当位置不变的时候才开始等待 - mode_pwmp_hd_adjust->wait_count--; - return POSITION_NO_CHANGE; - } - } } -/*获得切线的横坐标(时间) -输入:actual_in为纵坐标,表示阀位的行程 -*/ -static float32 get_time_tangent(float actual_in) +/*********************************** 整定任务 ***********************************/ +// 同步整定参数 +static void minor_public_params_update(void) { - return (actual_in - pid_autotune_hd->data.b) / pid_autotune_hd->data.k; } -//////////////////////////////*整定相关函数END*///////////////////////////////////////////////////////// - -//////////////////////////////////*状态机模式BEGIN*///////////////////////////////////////////////////// -/*整定等待状态*/ -static void pwmp_adjust_hd_idle(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) +// 启动整定 +static void minor_adjust_start(void) { - if (!FSM_IS_WAIT(*state)) - { - sys_millis_reset(); - osel_memset((uint8_t *)&mode_pwmp_hd->pwmp_save->storage, 0, sizeof(mode_pwmp_hd_storage_data_t)); - mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_ING; - /*为指针开辟存储空间*/ - if (mode_pwmp_hd_adjust == NULL) - { - mode_pwmp_hd_adjust = osel_mem_alloc(sizeof(pwmp_hd_adjust_t)); - DBG_ASSERT(mode_pwmp_hd_adjust != NULL __DBG_LINE); - } - osel_memset((uint8_t *)mode_pwmp_hd_adjust, 0, sizeof(pwmp_hd_adjust_t)); - - if (pid_autotune_hd == NULL) - { - pid_autotune_hd = (pid_autotune_hd_t *)osel_mem_alloc(sizeof(pid_autotune_hd_t)); - } - osel_memset((uint8_t *)pid_autotune_hd, 0, sizeof(pid_autotune_hd_t)); - - /*输出初始化*/ - mode_pwmp_hd_adjust->arr_default = mode_pwmp_hd->arr_default; - mode_pwmp_hd_adjust->arr_current = 0; - - mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; - FSM_WAIT(mode_pwmp_hd_adjust->adjust_state); // 等放气完毕就可以切入到else里面了 - *state = PWMP_HD_ADJUST_BLEEDING; - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: - // 位置不再改变,记录此时阀门位置AD值 - mode_pwmp_hd_adjust->adc_record_1 = pid_autotune_hd->data.adjust_tmp_actual; - mode_pwmp_hd_adjust->adc_record_0 = pid_autotune_hd->data.adjust_tmp_actual; - break; - case POSITION_CHANGE: - *state = PWMP_HD_ADJUST_IDEL; - // 将等待时间设置为1s - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 10; - break; - default: - break; - } - } + // 设置整定阶段 + mode_minor->adjust.step = MINOR_ADJUST_IDEL; + // 使能整定 + mode_minor->adjust.enable = TRUE; + // 初始化整定状态 + mode_minor->adjust_state = ADJUST_ONGING; } -/*整定粗调0*/ -static void pwmp_adjust_hd_rough_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) +// 停止整定 +static void minor_adjust_stop(void) { - uint16_t current_adc = 0; - if (!FSM_IS_WAIT(*state)) - { - // 以10%增加,提高DAC输出,找到能推动阀门的最小值 - mode_pwmp_hd_adjust->arr_current = 100; - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 20; - mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; - FSM_WAIT(*state); // 设置等待状态 - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - - current_adc = pid_autotune_hd->data.adjust_tmp_actual; - if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) >= DIFF_ADC_MAX) // 阀位发生改变 - { - if (mode_pwmp_hd_adjust->arr_last > 4000) - { - // 整定失败:位置反馈错误 - *state = PWMP_HD_ADJUST_FAIL; - } - else - { - /*得到一个粗略的,小于启动量的值*/ - mode_pwmp_hd_adjust->arr_record_1 = mode_pwmp_hd_adjust->arr_last > 1000 ? mode_pwmp_hd_adjust->arr_last * 0.9 : mode_pwmp_hd_adjust->arr_last; - /*判断位置反馈磁条是正装还是反装*/ - mode_pwmp_hd_adjust->adc_0_100_flag = mode_pwmp_hd_adjust->adc_record_0 < current_adc ? TRUE : FALSE; - } - *state = next_state; - } - else // 阀位未发生变化:继续增大输出 - { - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: // 位置不再改变 - { - - if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) <= DIFF_ADC_MAX) - { - // 没有发生变化 - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - if (mode_pwmp_hd_adjust->arr_last < 1000) - { - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.05; - } - else - { - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current * 1.02; - } - /*若输出信号为最大值时认定为整定错误*/ - if (mode_pwmp_hd_adjust->arr_current > 4000) - { - // 整定失败:位置反馈错误 - *state = PWMP_HD_ADJUST_FAIL; - return; - } - - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40; - *state = PWMP_HD_ADJUST_ROUGH_POSITION0; - FSM_WAIT(*state); // 设置等待状态 - } - else - { - DBG_ASSERT(FALSE __DBG_LINE); - } - break; - } - case POSITION_CHANGE: - DBG_ASSERT(FALSE __DBG_LINE); - break; - case POSITION_NO_CHANGE: - { - break; - } - default: - break; - } - } - } + // 输出最小值 + pdctrl_out(CON_MIN); + // 清除整定任务 + osel_memset((uint8_t *)&mode_minor->adjust, 0, sizeof(minor_adjust_t)); + // 切换控制状态 + minor_process_state_set(MINOR_PROCESS_CONTROL); } -/*放气值(0信号)的整定*/ -static void pwmp_adjust_hd_bleeding_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) +// 整定进程 +static void mode_minor_adjust(void) { - BOOL flag = FALSE; - mode_pwmp_hd_adjust->psb_adc = get_actual_travel_adc(); - if (!FSM_IS_WAIT(*state)) + uint8_t ts = 0; + + if (mode_minor->adjust.enable != TRUE) { - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - mode_pwmp_hd_adjust->last_adc = mode_pwmp_hd_adjust->psb_adc; - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 2; - FSM_WAIT(*state); // 设置等待状态 + minor_adjust_start(); } - else - { - // if (mode_pwmp_hd_adjust->adc_0_100_flag) - // { - // if (mode_pwmp_hd_adjust->psb_adc <= mode_pwmp_hd_adjust->last_adc) - // { - // if (ABS(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->last_adc) > DIFF_ADC_MAX) - // { - // mode_pwmp_hd_adjust->arr_record_0 = mode_pwmp_hd_adjust->arr_last + DIFF_ADC_MAX; - // flag = TRUE; - // } - // } - // } - // else - // { - // if (mode_pwmp_hd_adjust->psb_adc >= mode_pwmp_hd_adjust->last_adc) - // { - // if (ABS(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->last_adc) > DIFF_ADC_MAX) - // { - // mode_pwmp_hd_adjust->arr_record_0 = mode_pwmp_hd_adjust->arr_last + DIFF_ADC_MAX; - // flag = TRUE; - // } - // } - // } - if (ABS(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->adc_record_1) < 6) - { - mode_pwmp_hd_adjust->arr_record_0 = mode_pwmp_hd_adjust->arr_current; - flag = TRUE; - } - - if (flag == TRUE) - { - mode_pwmp_hd_adjust->arr_record_2 = 4095; // 给定最大值输出 - *state = next_state; - pdctrl_out(0); // 这里要先放气5秒然后计算全开时间 - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; - } - else - { - mode_pwmp_hd_adjust->wait_count--; - if (flag == FALSE && mode_pwmp_hd_adjust->wait_count == 0) - { - uint16_t last = mode_pwmp_hd_adjust->arr_last; - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - mode_pwmp_hd_adjust->arr_current = last - 4; - - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - if (ABS(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->last_adc) > 6) - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 10; - } - else - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 30; - } - - mode_pwmp_hd_adjust->last_adc = mode_pwmp_hd_adjust->psb_adc; - } - } - } -} - -// /*启动值细调*/ -// static void pwmp_adjust_hd_accurate_position0(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -// { -// uint16_t current_adc = 0; -// if (!FSM_IS_WAIT(*state)) -// { -// mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_1; -// mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; -// mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; -// FSM_WAIT(mode_pwmp_hd_adjust->adjust_state); -// *state = PWMP_HD_ADJUST_BLEEDING; -// } -// else -// { -// valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - -// current_adc = pid_autotune_hd->data.adjust_tmp_actual; -// /*执行器发生动作*/ -// if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) >= DIFF_ADC_MAX) -// { -// mode_pwmp_hd_adjust->arr_record_1 = mode_pwmp_hd_adjust->arr_last; -// mode_pwmp_hd_adjust->arr_record_2 = 4095; // 给定最大值输出 -// *state = next_state; -// pdctrl_out(0); // 这里要先放气5秒然后计算全开时间 -// mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; -// } -// else -// { -// switch (s) -// { -// case POSITION_NO_CHANGE_FOREVER: // 位置不再改变 -// { -// /*若执行器在0位置*/ -// if (ABS(current_adc - mode_pwmp_hd_adjust->adc_record_1) <= DIFF_ADC_MAX) -// { -// // 阀位没有发生变化,以每6增大信号输出 -// mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; -// mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current + 6; -// pdctrl_out(mode_pwmp_hd_adjust->arr_current); -// mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 30; -// *state = PWMP_HD_ADJUST_ACCURATE_POSITION0; -// FSM_WAIT(*state); // 设置等待状态 -// } -// else -// { -// DBG_ASSERT(FALSE __DBG_LINE); -// } -// break; -// } -// case POSITION_CHANGE: -// DBG_ASSERT(FALSE __DBG_LINE); -// break; -// default: -// break; -// } -// } -// } -// } - -/*粗略整定得到满位置adc位置反馈*/ -static void pwmp_adjust_hd_rough_position100(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - uint16_t current_adc = 0; - // 找最大推动值arr - if (!FSM_IS_WAIT(*state)) - { - /*上一步赋值的count*/ - if (mode_pwmp_hd_adjust->wait_count-- > 0) - { - // 等待放气完毕 - return; - } - - sys_millis_reset(); - mode_pwmp_hd_adjust->all_open_time_full = sys_millis(); // 记录全开起始时间 - mode_pwmp_hd_adjust->tmp_time = 0; - - pdctrl_out(mode_pwmp_hd_adjust->arr_record_2); // 以最大值进行输出 - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; // 等待时间设置为5s - mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; - FSM_WAIT(*state); // 设置等待状态 - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - current_adc = pid_autotune_hd->data.adjust_tmp_actual; - - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: - // 位置不再改变,记录此时阀门位置AD值 - mode_pwmp_hd_adjust->adc_record_2 = current_adc; - mode_pwmp_hd_adjust->all_open_time_full = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time_full; - break; - case POSITION_CHANGE: - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; - mode_pwmp_hd_adjust->tmp_time = 0; - break; - case POSITION_NO_CHANGE: - if (mode_pwmp_hd_adjust->tmp_time == 0) - { - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - } - break; - default: - break; - } - } -} - -/*精调冲顶值*/ -static void pwmp_adjust_hd_accurate_position100(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - if (!FSM_IS_WAIT(*state)) - { - mode_pwmp_hd_adjust->all_close_time_flag = TRUE; - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_1; // 初始值为前一步整定出的最小启动值 - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; - mode_pwmp_hd_adjust->preheat = TRUE; - FSM_WAIT(mode_pwmp_hd_adjust->adjust_state); // 等放气完毕就可以切入到else里面了 - *state = PWMP_HD_ADJUST_BLEEDING; - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - mode_pwmp_hd_adjust->psb_adc = pid_autotune_hd->data.adjust_tmp_actual; - - /*当前反馈AD值与最大位置AD值的差值*/ - uint16_t adc_diff = ABS(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->adc_record_2); - - if (mode_pwmp_hd_adjust->arr_current == 0 && mode_pwmp_hd_adjust->preheat == TRUE) - { - // 放气完毕会进入到这里 - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_1 + 20; - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 30; - return; - } - - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: // 位置不再改变 - { - if (adc_diff <= 10) - { - *state = next_state; - mode_pwmp_hd_adjust->arr_record_2 = mode_pwmp_hd_adjust->arr_current; - } - else - { - uint8_t offset = 0; - - /*每次增大的信号值*/ - offset = 3; - - /*若快到顶时等待10s,否则等待1s*/ - if (adc_diff < 20) - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 100; - } - else - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 20; - } - - mode_pwmp_hd_adjust->last_adc = mode_pwmp_hd_adjust->psb_adc; - mode_pwmp_hd_adjust->arr_last = mode_pwmp_hd_adjust->arr_current; - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_current + offset; - - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - *state = PWMP_HD_ADJUST_ACCURATE_POSITION100; - FSM_WAIT(*state); // 设置等待状态 - } - - break; - } - case POSITION_CHANGE: - if (adc_diff < 20) - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 100; - } - else - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 20; - } - - break; - default: - break; - } - } -} - -/*计算控制的全关时间:以ATO类型角度命名*/ -static void pwmp_adjust_hd_all_close_time(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - if (!FSM_IS_WAIT(*state)) - { - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_0 - 100; // 此处的输入信号大小根据实际控制的最小值来设定 - - /*记录起始的全开时间*/ - sys_millis_reset(); - mode_pwmp_hd_adjust->all_close_time = sys_millis(); - mode_pwmp_hd_adjust->tmp_time = 0; - - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - FSM_WAIT(*state); // 设置等待状态 - } - else - { - mode_pwmp_hd_adjust->psb_adc = get_actual_travel_adc(); - if (abs(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->adc_record_0) < DIFF_ADC_MAX) - { - if (uDevice.eAirAction == ATO) // 若调节阀为气开阀 - { - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - mode_pwmp_hd_adjust->all_close_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_close_time; - } - else // 若调节阀为气关阀 - { - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - mode_pwmp_hd_adjust->all_open_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_close_time; - } - *state = next_state; - } - } -} - -/*计算控制的全开时间*/ -static void pwmp_adjust_hd_all_open_time(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - if (!FSM_IS_WAIT(*state)) - { - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_record_2 + 100; // 此处的输入信号大小根据实际控制的最大值来设定 - - /*记录起始的全开时间*/ - sys_millis_reset(); - mode_pwmp_hd_adjust->all_open_time = sys_millis(); - mode_pwmp_hd_adjust->tmp_time = 0; - - pdctrl_out(mode_pwmp_hd_adjust->arr_current); - FSM_WAIT(*state); // 设置等待状态 - } - else - { - mode_pwmp_hd_adjust->psb_adc = get_actual_travel_adc(); - if (abs(mode_pwmp_hd_adjust->psb_adc - mode_pwmp_hd_adjust->adc_record_2) < DIFF_ADC_MAX) - { - if (uDevice.eAirAction == ATO) - { - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - mode_pwmp_hd_adjust->all_open_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time; - } - else - { - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - mode_pwmp_hd_adjust->all_close_time = mode_pwmp_hd_adjust->tmp_time - mode_pwmp_hd_adjust->all_open_time; - } - *state = next_state; - } - } -} - -/*计算阀门自整定参数*/ -static void pwmp_adjust_hd_calculate(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - if (!FSM_IS_WAIT(*state)) - { - /*行程上下限*/ - mode_pwmp_hd->pwmp_save->storage.trip_0 = mode_pwmp_hd_adjust->adc_record_0; - mode_pwmp_hd->pwmp_save->storage.trip_100 = mode_pwmp_hd_adjust->adc_record_2; - mode_pwmp_hd->pwmp_save->storage.ad_diff = ABS(mode_pwmp_hd->pwmp_save->storage.trip_0 - mode_pwmp_hd->pwmp_save->storage.trip_100); - - /*控制区间*/ - mode_pwmp_hd->pwmp_save->storage.pwmp_max_origin = mode_pwmp_hd_adjust->arr_record_2; - mode_pwmp_hd->pwmp_save->storage.pwmp_min_origin = mode_pwmp_hd_adjust->arr_record_0; - mode_pwmp_hd->pwmp_save->storage.arr_diff = ABS(mode_pwmp_hd_adjust->arr_record_2 - mode_pwmp_hd_adjust->arr_record_0); - mode_pwmp_hd->pwmp_save->storage.pwmp_max = mode_pwmp_hd_adjust->arr_record_2 + (mode_pwmp_hd->pwmp_save->storage.arr_diff * 0.2); - mode_pwmp_hd->pwmp_save->storage.pwmp_min = mode_pwmp_hd_adjust->arr_record_0 - (mode_pwmp_hd->pwmp_save->storage.arr_diff * 0.2); - - /*启动值*/ - mode_pwmp_hd->pwmp_save->storage.startup_value = mode_pwmp_hd_adjust->adc_record_1; - - /*全开及全关时间*/ - mode_pwmp_hd->pwmp_save->storage.all_open_time = mode_pwmp_hd_adjust->all_open_time; - mode_pwmp_hd->pwmp_save->storage.all_close_time = mode_pwmp_hd_adjust->all_close_time; - /*判断调节阀类型(气开/气关),对最低行程和最高行程进行标定*/ - if (uDevice.eAirAction == ATO) - { - mode_pwmp_hd->pwmp_save->storage.trip_100 = mode_pwmp_hd->pwmp_save->storage.trip_100; - mode_pwmp_hd->pwmp_save->storage.trip_0 = mode_pwmp_hd->pwmp_save->storage.trip_0; - } - else - { - uint16_t tmp = mode_pwmp_hd->pwmp_save->storage.trip_100; - mode_pwmp_hd->pwmp_save->storage.trip_100 = mode_pwmp_hd->pwmp_save->storage.trip_0; - mode_pwmp_hd->pwmp_save->storage.trip_0 = tmp; - } - - // 保存安装方向 - if (mode_pwmp_hd->pwmp_save->storage.trip_100 > mode_pwmp_hd->pwmp_save->storage.trip_0) // 上大下小,正装 - { - uDevice.ProcessChange_Flag = 1; - } - else // 充气,ADC减小,正装 - { - uDevice.ProcessChange_Flag = 0; - } - - uDevice.TravelVol0 = mode_pwmp_hd->pwmp_save->storage.trip_0; - uDevice.TravelVol100 = mode_pwmp_hd->pwmp_save->storage.trip_100; - uDevice.DAC_Min = mode_pwmp_hd->pwmp_save->storage.pwmp_min; - uDevice.DAC_Max = mode_pwmp_hd->pwmp_save->storage.pwmp_max; - calib_parapos_perent(); - - mode_pwmp_hd_adjust->adjust_state = (mode_pwmp_hd_adjust_state_e)*state; - FSM_WAIT(mode_pwmp_hd_adjust->adjust_state); // 等放气完毕就可以切入到else里面了 - *state = PWMP_HD_ADJUST_BLEEDING; - } - else - { - *state = next_state; - } -} -/*排气状态*/ -static void pwmp_adjust_hd_bleeding(uint8_t *state) -{ - if (!FSM_IS_WAIT(*state)) - { - mode_pwmp_hd_adjust->arr_current = mode_pwmp_hd_adjust->arr_default; - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 80; - pdctrl_out(0); - FSM_WAIT(*state); // 设置等待状态 - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, mode_pwmp_hd_adjust->adjust_state, DIFF_ADC_MAX); - mode_pwmp_hd_adjust->psb_adc = mode_pwmp_hd_adjust->psb_adc; - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; // 排气状态结束后在跳转后的状态中等待5s - mode_pwmp_hd_adjust->arr_current = 0; - // if (mode_pwmp_hd_adjust->psb_adc != mode_pwmp_hd_adjust->adc_record_1) - // { - // mode_pwmp_hd_adjust->adc_record_1 = mode_pwmp_hd_adjust->psb_adc; - // mode_pwmp_hd->pwmp_save->storage.trip_0 = mode_pwmp_hd_adjust->psb_adc; - // } - break; - case POSITION_CHANGE: - if (mode_pwmp_hd_adjust->adc_record_0 == 0) - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 80; - } - else - { - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 50; - } - mode_pwmp_hd_adjust->tmp_time = 0; - break; - case POSITION_NO_CHANGE: - break; - default: - *state = PWMP_HD_ADJUST_STOP; - break; - } - } -} - -/*停止模式*/ -static void pwmp_adjust_hd_stop(uint8_t *state) -{ - if (mode_pwmp_hd_adjust != NULL) - { - osel_mem_free(mode_pwmp_hd_adjust); - mode_pwmp_hd_adjust = NULL; - } - *state = PWMP_HD_ADJUST_IDEL; - if (mode_pwmp_hd->auto_tune_state == PWMP_HD_ADJUST_RESULT_TUNING) - { - mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_IDEL; - } - // 整定结束,将模式设置为控制模式 - pwmp_hd_process_state_set(PWMP_HD_PROCESS_CONTROL); -} - -/*整定错误状态*/ -static void pwmp_adjust_hd_fail(uint8_t *state) -{ - if (mode_pwmp_hd_adjust->arr_record_1 == 0) - { - // 阀位反馈错误 - } - // 反馈结果(整定错误) - mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_FAIL; -} - -/*PID参数整定模式*/ -// 通过整定获得K、T、L(tao) -int s_watch; -static void pwmp_adjust_hd_PID_tuning(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - if (!FSM_IS_WAIT(*state)) - { - /*记录运行时间*/ - sys_millis_reset(); - pid_autotune_hd->data.pid_autotune_time_origin = sys_millis(); // 记录整定起始时间 - mode_pwmp_hd_adjust->tmp_time = 0; - /*整定方法选择*/ - pid_autotune_way_set(PID_AUTOTUNE_WAY_ZN); - /*阶跃信号设置*/ - pid_autotune_hd->data.step_signal = mode_pwmp_hd_adjust->arr_record_2; - pdctrl_out(pid_autotune_hd->data.step_signal); - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40; // 等待四秒 - FSM_WAIT(*state); // 设置等待状态 - } - else - { - valve_position_change_e s = pwmp_adjust_hd_valve_position_change(state, next_state, DIFF_ADC_MAX); - s_watch = s; - /*获取实时行程*/ - pid_autotune_hd->data.cur_actual = pid_autotune_hd->data.adjust_tmp_actual; - /*计算变化率*/ - pid_autotune_hd->data.actual_error = pid_autotune_hd->data.cur_actual - pid_autotune_hd->data.pre_actual; - if (pid_autotune_hd->data.actual_error > 1000) - { - pid_autotune_hd->data.slope = 0; - } - else - { - pid_autotune_hd->data.slope = pid_autotune_hd->data.actual_error / TIME_CYCLE; - } - /*记录下变化率最大点值及行程坐标、时间*/ - if (pid_autotune_hd->data.slope > pid_autotune_hd->data.slope_Max) - { - pid_autotune_hd->data.slope_Max = pid_autotune_hd->data.slope; - pid_autotune_hd->data.actual_slope_Max = pid_autotune_hd->data.cur_actual; - mode_pwmp_hd_adjust->tmp_time = sys_millis(); - pid_autotune_hd->data.time_slope_Max = mode_pwmp_hd_adjust->tmp_time - pid_autotune_hd->data.pid_autotune_time_origin; - } - /*保存前一次的行程*/ - pid_autotune_hd->data.pre_actual = pid_autotune_hd->data.cur_actual; - /*只有当阀位大于前端*/ - if (pid_autotune_hd->data.cur_actual > 2) - { - switch (s) - { - case POSITION_NO_CHANGE_FOREVER: - /*获取稳定时的行程*/ - pid_autotune_hd->data.actual_stable = pid_autotune_hd->data.cur_actual; - /*计算切线的k和b*/ - pid_autotune_hd->data.k = pid_autotune_hd->data.slope_Max; - pid_autotune_hd->data.b = pid_autotune_hd->data.actual_slope_Max - (pid_autotune_hd->data.k * pid_autotune_hd->data.time_slope_Max); - /*求得滞后时间L*/ - pid_autotune_hd->l_hd = get_time_tangent(0); - /*求得时间系数T*/ - pid_autotune_hd->t_hd = get_time_tangent(pid_autotune_hd->data.actual_stable) - pid_autotune_hd->l_hd; - /*K的计算*/ - pid_autotune_hd->k_hd = ((pid_autotune_hd->data.actual_stable) / (mode_pwmp_hd_adjust->adc_record_2 - mode_pwmp_hd_adjust->adc_record_0)) / ((pid_autotune_hd->data.step_signal) / (mode_pwmp_hd_adjust->arr_record_2 - mode_pwmp_hd_adjust->arr_record_0)); - - *state = next_state; - break; - case POSITION_CHANGE: - mode_pwmp_hd_adjust->wait_count = mode_pwmp_hd->wait_count_max * 40; - break; - case POSITION_NO_CHANGE: - break; - default: - *state = PWMP_HD_ADJUST_STOP; - break; - } - } - } -} - -/*参数计算模式*/ -static void pwmp_adjust_hd_pid_calculate(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - switch (pid_autotune_hd->autotune_way) - { - case PID_AUTOTUNE_WAY_ZN: - if ((pid_autotune_hd->l_hd / pid_autotune_hd->t_hd) <= 0.2) - { - pid_autotune_hd->p_auto_hd = (pid_autotune_hd->t_hd / (0.85 * pid_autotune_hd->l_hd * pid_autotune_hd->k_hd)); - pid_autotune_hd->ti_auto_hd = 2 * pid_autotune_hd->l_hd; - pid_autotune_hd->td_auto_hd = 0.5 * pid_autotune_hd->l_hd; - } - else if ((pid_autotune_hd->l_hd / pid_autotune_hd->t_hd) > 0.2) - { - pid_autotune_hd->p_auto_hd = ((1 / pid_autotune_hd->k_hd) * (pid_autotune_hd->l_hd / pid_autotune_hd->t_hd) + 0.6) / (2.6 * (pid_autotune_hd->l_hd / pid_autotune_hd->t_hd) - 0.08); - pid_autotune_hd->ti_auto_hd = 0.18 * pid_autotune_hd->t_hd + 0.19 * pid_autotune_hd->l_hd; - pid_autotune_hd->td_auto_hd = 0.25 * pid_autotune_hd->ti_auto_hd; - } - pid_autotune_hd->i_auto_hd = pid_autotune_hd->p_auto_hd / pid_autotune_hd->ti_auto_hd; - pid_autotune_hd->d_auto_hd = (pid_autotune_hd->td_auto_hd * pid_autotune_hd->p_auto_hd) / pid_autotune_hd->t_hd; - break; - case PID_AUTOTUNE_WAY_CC: - /*Kp、Ti、Td的求取*/ - pid_autotune_hd->p_auto_hd = ((pid_autotune_hd->t_hd / (pid_autotune_hd->k_hd * pid_autotune_hd->l_hd)) * (4 / 3 + (pid_autotune_hd->l_hd / (pid_autotune_hd->t_hd * 4)))); - pid_autotune_hd->ti_auto_hd = pid_autotune_hd->l_hd * ((32 + 6 * (pid_autotune_hd->l_hd / pid_autotune_hd->t_hd)) / (13 + 8 * (pid_autotune_hd->l_hd / pid_autotune_hd->l_hd))); - pid_autotune_hd->td_auto_hd = (4 * pid_autotune_hd->l_hd) / (11 + 2 * (pid_autotune_hd->l_hd / pid_autotune_hd->t_hd)); - /*Ki、Kd的求取*/ - pid_autotune_hd->i_auto_hd = pid_autotune_hd->p_auto_hd / pid_autotune_hd->ti_auto_hd; - pid_autotune_hd->d_auto_hd = (pid_autotune_hd->td_auto_hd * pid_autotune_hd->p_auto_hd) / pid_autotune_hd->t_hd; - break; - default: - break; - } - mode_pwmp_hd->pwmp_save->storage.kp = fabs(pid_autotune_hd->p_auto_hd); - mode_pwmp_hd->pwmp_save->storage.ki = fabs(pid_autotune_hd->i_auto_hd); - mode_pwmp_hd->pwmp_save->storage.kd = fabs(pid_autotune_hd->d_auto_hd); - *state = next_state; // 将状态切换 -} - -/**/ - -/*参数保存模式*/ -static void pwmp_adjust_hd_save(uint8_t *state, mode_pwmp_hd_adjust_state_e next_state) -{ - *state = next_state; - if (mode_pwmp_hd->pwmp_save->storage.tuned_state == LCD_ADJUST_RESULT_ING) - { - mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_OK; - mode_pwmp_hd->auto_tune_state = PWMP_HD_ADJUST_RESULT_SUCCESS; - mode_pwmp_hd->pwmp_save->storage.tuned_flag = 1; - pwmp_public_params_update(); - } - else - { - mode_pwmp_hd->pwmp_save->storage.tuned_state = LCD_ADJUST_RESULT_FAIL; - mode_pwmp_hd->pwmp_save->storage.tuned_flag = 0; - } - mode_pwmp_hd->params_save_cb(); -} - -//////////////////////////////////*状态机模式END*////////////////////////////////////////////////////// - -//////////////////////////////*整定程序入口BEGIN*////////////////////////////////////////////////////// - -void pwmp_adjust(uint8_t *state) -{ - uint8_t ts = *state; - BIT_CLR(ts, BIT7); // 高位清零 - switch (ts) - { - case PWMP_HD_ADJUST_ROUGH_POSITION0: - pwmp_adjust_hd_rough_position0(state, PWMP_HD_ADJUST_BLEEDING_POSITION0); - break; - case PWMP_HD_ADJUST_BLEEDING_POSITION0: - pwmp_adjust_hd_bleeding_position0(state, PWMP_HD_ADJUST_ROUGH_POSITION100); - break; - // case PWMP_HD_ADJUST_ACCURATE_POSITION0: - // pwmp_adjust_hd_accurate_position0(state, PWMP_HD_ADJUST_ROUGH_POSITION100); - // break; - case PWMP_HD_ADJUST_ROUGH_POSITION100: - pwmp_adjust_hd_rough_position100(state, PWMP_HD_ADJUST_ACCURATE_POSITION100); - break; - case PWMP_HD_ADJUST_ACCURATE_POSITION100: - pwmp_adjust_hd_accurate_position100(state, PWMP_HD_ADJUST_ALL_CLOSE_TIME); - break; - case PWMP_HD_ADJUST_ALL_CLOSE_TIME: - pwmp_adjust_hd_all_close_time(state, PWMP_HD_ADJUST_ALL_OPEN_TIME); - break; - case PWMP_HD_ADJUST_ALL_OPEN_TIME: - pwmp_adjust_hd_all_open_time(state, PWMP_HD_ADJUST_CALCULATE); - break; - case PWMP_HD_ADJUST_CALCULATE: - pwmp_adjust_hd_calculate(state, PWMP_HD_ADJUST_PID_TUNING); - break; - case PWMP_HD_ADJUST_PID_TUNING: - pwmp_adjust_hd_PID_tuning(state, PWMP_HD_ADJUST_PID_CALCULATE); - break; - case PWMP_HD_ADJUST_PID_CALCULATE: - pwmp_adjust_hd_pid_calculate(state, PWMP_HD_ADJUST_SAVE); - break; - case PWMP_HD_ADJUST_SAVE: - pwmp_adjust_hd_save(state, PWMP_HD_ADJUST_STOP); - break; - case PWMP_HD_ADJUST_BLEEDING: - pwmp_adjust_hd_bleeding(state); - break; - case PWMP_HD_ADJUST_IDEL: - pwmp_adjust_hd_idle(state, PWMP_HD_ADJUST_ROUGH_POSITION0); - break; - case PWMP_HD_ADJUST_STOP: - pwmp_adjust_hd_stop(state); - break; - case PWMP_HD_ADJUST_FAIL: - pwmp_adjust_hd_fail(state); - pwmp_adjust_hd_stop(state); - break; - default: - pwmp_adjust_hd_stop(state); - break; - } + ts = mode_minor->adjust.execute_step; + BIT_CLR(ts, BIT7); switch (ts) { - case PWMP_HD_ADJUST_IDEL: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_IDEL; - break; - case PWMP_HD_ADJUST_ROUGH_POSITION0: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION0; - break; - case PWMP_HD_ADJUST_ACCURATE_POSITION0: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION0; - break; - case PWMP_HD_ADJUST_ROUGH_POSITION100: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION100; - break; - case PWMP_HD_ADJUST_ACCURATE_POSITION100: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_POSITION100; - break; - case PWMP_HD_ADJUST_BLEEDING_TIMER: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TIMER; - break; - case PWMP_HD_ADJUST_AERATE_TIMER: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TIMER; - break; - case PWMP_HD_ADJUST_TUNING: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_TUNING; - break; - case PWMP_HD_ADJUST_SAVE: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_SAVE; - break; - case PWMP_HD_ADJUST_STOP: - mode_pwmp_hd->lcd_adjust_state = LCD_ADJUST_STOP; - break; default: + minor_adjust_stop(); break; } } -//////////////////////////////*整定程序入口END*////////////////////////////////////////////////////// -//////////////////////////////*入口BEGIN*////////////////////////////////////////////////////// -void mode_pwmp_hd_process(void) +/*********************************** 停止任务 ***********************************/ +static void mode_minor_stop(void) { - mode_pwmp_hd_control_t *p = &mode_pwmp_hd->control; - execute_rsp_hd_t *execute_res; - p->enter_count++; - if (p->enter_count % WAIT_COUNT_MAX == 0) // 100ms输出一次 - { - if (BIT_IS_SET(hc_24_state, BIT2)) - { - // 蓝牙输出 - char ble_data[128]; - uint8_t ble_len = 0; - osel_memset((uint8_t *)ble_data, 0, 128); - // sprintf(ble_data, "%f,%f,%f,%d,%f\r\n", pid_target, show_actual, p->real_error, mode_pwm->output, loop_current); - if (mode_pwmp_hd->process_state == PWMP_HD_PROCESS_ADJUST) - { - sprintf(ble_data, "%f,%f,%f,%f\r\n", mode_pwmp_hd->control.ctrl_target, mode_pwmp_hd->control.ctrl_feedback, mode_pwmp_hd->control.real_error, loop_current); - } - else - { - sprintf(ble_data, "%f,%f,%f\r\n", mode_pwmp_hd->control.ctrl_feedback, mode_pwmp_hd->control.ctrl_target, mode_pwmp_hd->control.real_error); - } - ble_len = osel_mstrlen((unsigned char *)ble_data); - if (ble_len != 0) - { - h24_bluetooth_output_dbg((uint8_t *)ble_data, ble_len); - } + minor_adjust_stop(); +} - // 蓝牙输出 - } - p->enter_count = 0; +/*********************************** 模式管理 ***********************************/ +// 设置任务 +void minor_process_state_set(mode_minor_process_state_e state) +{ + if (mode_minor->process_state == state) + { + return; } + // 如果当前正在整定,切换任务前要求停止整定 + if (mode_minor->process_state == MINOR_PROCESS_ADJUST) + { + minor_adjust_stop(); + } + // 切换任务 + mode_minor->process_state = state; +} - switch (mode_pwmp_hd->process_state) +// 模式进程 +void mode_minor_process(void) +{ + switch (mode_minor->process_state) { - case PWMP_HD_PROCESS_CONTROL: - { - pwmp_control_update(FILTER_MEDIAN); - if (loop_current >= LOOP_CURRENT_MIN) - { - if (loop_current < 4.5) - { - pdctrl_out(0); // HD:此处后续需要将填入的数值换成整定出来的全排值(快速) - } - else if (loop_current > 19.5) - { - pdctrl_out(4095); // HD:此处后续需要将填入的数值换成整定出来的冲顶值(快速) - } - else if (loop_current >= 4.5 && loop_current <= 19.5) - { - execute_res = execute_dac(EXECUTE_PLAN); // PID计算结果经过执行器处理 - if (execute_res->code == EXECUTE_HD_OUT) // 执行DAC输出 - { - pdctrl_out(execute_res->dac); - } - } - } - else - { - pdctrl_out(0); - } + case MINOR_PROCESS_CONTROL: + mode_minor_control(); break; - } - case PWMP_HD_PROCESS_ADJUST: - pwmp_adjust((uint8_t *)&mode_pwmp_hd->adjust_state); + case MINOR_PROCESS_ADJUST: + mode_minor_adjust(); break; - case PWMP_HD_PROCESS_STOP: - { - // TODO 完成停止自整定,并释放资源 + case MINOR_PROCESS_STOP: + mode_minor_stop(); break; - } - case PWMP_HD_PROCESS_TEST: + case MINOR_PROCESS_TEST: { - pdctrl_out(mode_pwmp_hd->output); - mode_pwmp_hd->current_adc = get_actual_travel_adc(); - mode_pwmp_hd->duty_percent = ((float32)mode_pwmp_hd->output / (float32)OUT_MAX) * 100; - mode_pwmp_hd->current_electric = ip2current(); + pdctrl_out(mode_minor->test.output); + mode_minor->test.travel_adc = adc_result_median(ADCS_1, ADC_PSB_CHANNEL); + mode_minor->test.minor_adc = adc_result_median(ADCS_1, ADC_IPSB_CHANNEL); + mode_minor->test.drive_current = ip2current(); break; } default: break; } } -//////////////////////////////*入口END*////////////////////////////////////////////////////// -/*程序初始化*/ -void mode_pwmp_hd_init(uint16_t positioner_model, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void)) +// 模式初始化 +void mode_minor_init(uint16_t positioner_model, mode_pwmp_hd_params_u *params, void (*params_save_cb)(void)) { - DBG_ASSERT(params != NULL __DBG_LINE); // 断言检查 + DBG_ASSERT(params != NULL __DBG_LINE); DBG_ASSERT(params_save_cb != NULL __DBG_LINE); - /*大电流输出使能开关*/ -#if VIP_H_EN_HD == 1 + + // 使能大电流 VIP_H_EN_ENABLE(); -#endif - /*为指针开辟存储空间*/ - if (mode_pwmp_hd == NULL) + // 分配空间 + if (mode_minor == NULL) { - mode_pwmp_hd = (mode_pwmp_hd_t *)osel_mem_alloc(sizeof(mode_pwmp_hd_t)); + mode_minor = (mode_minor_t *)osel_mem_alloc(sizeof(mode_minor_t)); + } + osel_memset((uint8_t *)mode_minor, 0, sizeof(mode_minor_t)); + // 初始化滤波器 + mode_minor->target_lpf.handle = lpf_window_init(20); + mode_minor->actual_lpf.handle = lpf_window_init(20); + // 初始化控制器 + minor_pid_init(EXECUTE_PLAN); + // 绑定存储参数 + mode_minor->save = params; + mode_minor->params_save_cb = params_save_cb; + // 保存模式参数 + mode_minor->params_save_cb(); + // 更新公共参数 + minor_public_params_update(); + // 初始化任务 + minor_process_state_set(MINOR_PROCESS_CONTROL); +} + +// 模式反初始化 +void mode_minor_dinit(void) +{ + if (mode_minor != NULL) + { + minor_process_state_set(MINOR_PROCESS_STOP); + osel_mem_free(mode_minor); + mode_minor = NULL; } - osel_memset((uint8_t *)mode_pwmp_hd, 0, sizeof(mode_pwmp_hd_t)); - /*滤波初始化*/ - mode_pwmp_hd->filter.handle = lpf_window_init(20); - /*绑定要保存的参数与函数*/ - mode_pwmp_hd->pwmp_save = params; - mode_pwmp_hd->params_save_cb = params_save_cb; - /*设定PWMP方式的工作模式*/ - pwmp_hd_process_state_set(PWMP_HD_PROCESS_CONTROL); - /*PID初始化*/ - execute_pid_init(EXECUTE_PLAN); - /*计数最大值*/ - mode_pwmp_hd->wait_count_max = 100 / ((MODE_DEFAULT_AUTOLOAD + 1) * 0.1); // (=10,每减一消耗10ms,总消耗时间100ms) -#if 0 // 手动控制接口 - /*临时参数设置(后续整定)*/ - mode_pwmp_hd->pwmp_save->storage.trip_0 = 2579; - mode_pwmp_hd->pwmp_save->storage.trip_100 = 1727; -#if VIP_H_EN_HD == 1 - // /*大电流输出模式控制范围(fisher)*/ - // mode_pwmp_hd->pwmp_save->storage.pwmp_min = 500; - // mode_pwmp_hd->pwmp_save->storage.pwmp_max = 925; - /*大电流输出模式控制范围(自制)*/ - mode_pwmp_hd->pwmp_save->storage.pwmp_min = 518; - mode_pwmp_hd->pwmp_save->storage.pwmp_max = 716; -#else - /*小电流输出模式控制范围*/ - mode_pwmp_hd->pwmp_save->storage.pwmp_min = 1025; - mode_pwmp_hd->pwmp_save->storage.pwmp_max = 2050; -#endif - mode_pwmp_hd->pwmp_save->storage.valve_type = ATO; // 气开阀 -#if INTEGRAL_SEPARATION == 1 -#if 1 - // mode_pwmp_hd->pwmp_save->storage.kp = 5; - // mode_pwmp_hd->pwmp_save->storage.ki = 0.02; - // mode_pwmp_hd->pwmp_save->storage.kd = 0.005; - mode_pwmp_hd->pwmp_save->storage.kp = 0.9; - mode_pwmp_hd->pwmp_save->storage.ki = 0.02; - mode_pwmp_hd->pwmp_save->storage.kd = 0.005; -#else - mode_pwmp_hd->pwmp_save->storage.kp = 7.5882; - mode_pwmp_hd->pwmp_save->storage.ki = 0.1339; - mode_pwmp_hd->pwmp_save->storage.kd = 0.01; -#endif -#else - mode_pwmp_hd->pwmp_save->storage.kp = 4.1332; - mode_pwmp_hd->pwmp_save->storage.ki = 0.5619; - mode_pwmp_hd->pwmp_save->storage.kd = 0.5504; -#endif - -#endif - /*保存参数*/ - mode_pwmp_hd->params_save_cb(); - - /*更新公共参数*/ - pwmp_public_params_update(); - calib_parapos_perent(); } diff --git a/User/application/src/params.c b/User/application/src/params.c index 134bfcf..1ff6c24 100644 --- a/User/application/src/params.c +++ b/User/application/src/params.c @@ -134,7 +134,7 @@ void params_restart(void) // 阀门类型 uDevice.eAirAction = ATO; // 定位器控制输出模式 - uDevice.SpecControlOutputMode = PDCTRL_PWMP_HD; + uDevice.SpecControlOutputMode = PDCTRL_MINOR; // 行程类型, 直行程/角行程 uDevice.eTravelType = TRAVEL_TYPE_STRAIGHT; // 行程范围,直行程:0, 16mm、25mm、40mm、60mm、100mm、130mm、160mm、200mm diff --git a/User/application/src/pdctrl.c b/User/application/src/pdctrl.c index 8ea1a1c..bc0e191 100644 --- a/User/application/src/pdctrl.c +++ b/User/application/src/pdctrl.c @@ -73,7 +73,7 @@ void pdctrl_init(pdctrl_mode_e mode) { pwm_init(); } - else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD) + else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_MINOR) { pwmp_init(); } @@ -99,7 +99,7 @@ void pdctrl_stop(void) { pwm_dinit(); } - else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD) + else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_MINOR) { pwmp_dinit(); } @@ -125,7 +125,7 @@ void pdctrl_run(void) { pwm_init(); } - else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD) + else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_MINOR) { pwmp_init(); } @@ -250,7 +250,7 @@ void pdctrl_out(uint16_t out) { pdctrl_pwm_set_arr(out); } - else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_PWMP_HD) + else if (out_mode == PDCTRL_PWMP || out_mode == PDCTRL_MINOR) { #if PDCTRL_PWMP_CHINNEL == LL_TIM_CHANNEL_CH4 PWM_SET_DUTY(PDCTRL_PWMP_TIM, 4, out);