Browse Source

加入PID算法

master
htujun 3 years ago
parent
commit
3b17c68108
  1. 26
      stm32/HARDWARE/TIMER/timer.c
  2. BIN
      stm32/OBJ/Template.axf
  3. 14
      stm32/OBJ/Template.build_log.htm
  4. 1901
      stm32/OBJ/Template.hex
  5. 1089
      stm32/OBJ/Template.htm
  6. 5
      stm32/OBJ/Template_Target 1.dep
  7. BIN
      stm32/OBJ/adc.o
  8. BIN
      stm32/OBJ/core_cm3.o
  9. BIN
      stm32/OBJ/delay.o
  10. BIN
      stm32/OBJ/encoder.o
  11. BIN
      stm32/OBJ/key.o
  12. BIN
      stm32/OBJ/led.o
  13. BIN
      stm32/OBJ/main.crf
  14. BIN
      stm32/OBJ/main.o
  15. BIN
      stm32/OBJ/misc.o
  16. BIN
      stm32/OBJ/motor.o
  17. BIN
      stm32/OBJ/oled.o
  18. BIN
      stm32/OBJ/startup_stm32f10x_md.o
  19. BIN
      stm32/OBJ/stm32f10x_adc.o
  20. BIN
      stm32/OBJ/stm32f10x_gpio.o
  21. BIN
      stm32/OBJ/stm32f10x_it.o
  22. BIN
      stm32/OBJ/stm32f10x_rcc.o
  23. BIN
      stm32/OBJ/stm32f10x_tim.o
  24. BIN
      stm32/OBJ/stm32f10x_usart.o
  25. BIN
      stm32/OBJ/sys.o
  26. BIN
      stm32/OBJ/system_stm32f10x.o
  27. BIN
      stm32/OBJ/timer.crf
  28. 1
      stm32/OBJ/timer.d
  29. BIN
      stm32/OBJ/timer.o
  30. BIN
      stm32/OBJ/usart.o
  31. BIN
      stm32/OBJ/wifi.o
  32. 44
      stm32/USER/.vscode/c_cpp_properties.json
  33. 2
      stm32/USER/.vscode/keil-assistant.log
  34. 2
      stm32/USER/.vscode/uv4.log
  35. 2
      stm32/USER/.vscode/uv4.log.lock
  36. 980
      stm32/USER/Template.map
  37. 19
      stm32/USER/main.c

26
stm32/HARDWARE/TIMER/timer.c

@ -3,6 +3,7 @@
#include "wifi.h" #include "wifi.h"
#include "math.h" #include "math.h"
#include "encoder.h" #include "encoder.h"
#include "motor.h"
extern char smog_value_buf[7]; extern char smog_value_buf[7];
extern char temp_value_buf[7]; extern char temp_value_buf[7];
@ -11,6 +12,28 @@ extern char beam_value_buf[7];
extern struct UserInfo userInfo; extern struct UserInfo userInfo;
float Velocity_KP_Mode2 = 1.1,Velocity_KI_Mode2=7.7;
void Set_Pwm(int motor)
{
if(motor<0) AIN2=1, AIN1=0;
else AIN2=0,AIN1=1;
PWMA=abs(motor);
}
int Incremental_PI_B_Mode2 (int Encoder,int Target)
{
static int Bias,Pwm,Last_bias;
Bias=Encoder-Target; //计算偏差
Pwm+=Velocity_KP_Mode2*(Bias-Last_bias)+Velocity_KI_Mode2*Bias; //增量式PI控制器
if(Pwm>7200)Pwm=7200;
if(Pwm<-7200)Pwm=-7200;
Last_bias=Bias; //保存上一次偏差
return Pwm; //增量输出
}
void TIM3_Int_Init(u16 arr,u16 psc) void TIM3_Int_Init(u16 arr,u16 psc)
{ {
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
@ -42,9 +65,12 @@ void TIM3_Int_Init(u16 arr,u16 psc)
void TIM3_IRQHandler(void) void TIM3_IRQHandler(void)
{ {
int pwm;
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
{ {
userInfo.currentSpeed = Read_Encoder(2); userInfo.currentSpeed = Read_Encoder(2);
pwm = Incremental_PI_B_Mode2(userInfo.currentSpeed, 10);
Set_Pwm(pwm);
TIM_ClearITPendingBit(TIM3, TIM_IT_Update); TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
} }
} }

BIN
stm32/OBJ/Template.axf

Binary file not shown.

14
stm32/OBJ/Template.build_log.htm

@ -21,18 +21,18 @@ Target DLL: STLink\ST-LINKIII-KEIL_SWO.dll V3.0.1.0
Dialog DLL: TCM.DLL V1.35.1.0 Dialog DLL: TCM.DLL V1.35.1.0
<h2>Project:</h2> <h2>Project:</h2>
e:\ÏîÄ¿\¼æÖ°ÏîÄ¿\MotorPid\stm32\USER\Template.uvprojx e:\ÏîÄ¿\¼æÖ°ÏîÄ¿\20220418-MotorPid\stm32\USER\Template.uvprojx
Project File Date: 04/17/2022 Project File Date: 04/17/2022
<h2>Output:</h2> <h2>Output:</h2>
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin' *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
Build target 'Target 1' Build target 'Target 1'
compiling main.c... compiling timer.c...
main.c(124): warning: #167-D: argument of type "char *" is incompatible with parameter of type "u8 *" ..\HARDWARE\TIMER\timer.c(22): warning: #223-D: function "abs" declared implicitly
OLED_ShowString(0,0, str, 16); PWMA=abs(motor);
main.c: 1 warning, 0 errors ..\HARDWARE\TIMER\timer.c: 1 warning, 0 errors
linking... linking...
Program Size: Code=12642 RO-data=2342 RW-data=404 ZI-data=1340 Program Size: Code=12658 RO-data=2342 RW-data=408 ZI-data=1336
FromELF: creating hex file... FromELF: creating hex file...
"..\OBJ\Template.axf" - 0 Error(s), 1 Warning(s). "..\OBJ\Template.axf" - 0 Error(s), 1 Warning(s).
@ -48,7 +48,7 @@ Package Vendor: Keil
D:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include D:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include
<h2>Collection of Component Files used:</h2> <h2>Collection of Component Files used:</h2>
Build Time Elapsed: 00:00:01 Build Time Elapsed: 00:00:02
</pre> </pre>
</body> </body>
</html> </html>

1901
stm32/OBJ/Template.hex

File diff suppressed because it is too large Load Diff

1089
stm32/OBJ/Template.htm

File diff suppressed because it is too large Load Diff

5
stm32/OBJ/Template_Target 1.dep

@ -1,5 +1,5 @@
Dependencies for Project 'Template', Target 'Target 1': (DO NOT MODIFY !) Dependencies for Project 'Template', Target 'Target 1': (DO NOT MODIFY !)
F (.\main.c)(0x625C3C54)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d) F (.\main.c)(0x625D7FA2)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\main.o --omf_browse ..\obj\main.crf --depend ..\obj\main.d)
I (..\HARDWARE\LED\led.h)(0x62599D88) I (..\HARDWARE\LED\led.h)(0x62599D88)
I (..\SYSTEM\sys\sys.h)(0x6256947A) I (..\SYSTEM\sys\sys.h)(0x6256947A)
I (..\USER\stm32f10x.h)(0x6256947A) I (..\USER\stm32f10x.h)(0x6256947A)
@ -199,7 +199,7 @@ I (..\STM32F10x_FWLib\inc\stm32f10x_usart.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x6256947A) I (..\STM32F10x_FWLib\inc\stm32f10x_wwdg.h)(0x6256947A)
I (..\STM32F10x_FWLib\inc\misc.h)(0x6256947A) I (..\STM32F10x_FWLib\inc\misc.h)(0x6256947A)
I (..\SYSTEM\delay\delay.h)(0x6256947A) I (..\SYSTEM\delay\delay.h)(0x6256947A)
F (..\HARDWARE\TIMER\timer.c)(0x625C3B1D)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\timer.o --omf_browse ..\obj\timer.crf --depend ..\obj\timer.d) F (..\HARDWARE\TIMER\timer.c)(0x625D8359)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\timer.o --omf_browse ..\obj\timer.crf --depend ..\obj\timer.d)
I (..\HARDWARE\TIMER\timer.h)(0x625C2B07) I (..\HARDWARE\TIMER\timer.h)(0x625C2B07)
I (..\SYSTEM\sys\sys.h)(0x6256947A) I (..\SYSTEM\sys\sys.h)(0x6256947A)
I (..\USER\stm32f10x.h)(0x6256947A) I (..\USER\stm32f10x.h)(0x6256947A)
@ -234,6 +234,7 @@ I (..\HARDWARE\LED\led.h)(0x62599D88)
I (..\HARDWARE\ESP8266\wifi.h)(0x6256947A) I (..\HARDWARE\ESP8266\wifi.h)(0x6256947A)
I (D:\Keil_v5\ARM\ARMCC\include\math.h)(0x599ECD2E) I (D:\Keil_v5\ARM\ARMCC\include\math.h)(0x599ECD2E)
I (..\HARDWARE\ENCODER\encoder.h)(0x625C1FA8) I (..\HARDWARE\ENCODER\encoder.h)(0x625C1FA8)
I (..\HARDWARE\MOTOR\motor.h)(0x625C2A2D)
F (..\HARDWARE\OLED\oled.c)(0x625C140B)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\oled.o --omf_browse ..\obj\oled.crf --depend ..\obj\oled.d) F (..\HARDWARE\OLED\oled.c)(0x625C140B)(-c --cpu Cortex-M3 -D__MICROLIB -g -O0 --apcs=interwork -I ..\HARDWARE\LED -I ..\SYSTEM\delay -I ..\SYSTEM\sys -I ..\SYSTEM\usart -I ..\USER -I ..\STM32F10x_FWLib\inc -I ..\CORE -I ..\HARDWARE\ESP8266 -I ..\HARDWARE\DHT11 -I ..\HARDWARE\LCD1602 -I ..\HARDWARE\ADC -I ..\HARDWARE\TIMER -I ..\HARDWARE\DS18B20 -I ..\HARDWARE\cJSON -I ..\HARDWARE\DS1302 -I ..\HARDWARE\LCD -I ..\HARDWARE\OLED -I ..\HARDWARE\MOTOR -I ..\HARDWARE\ENCODER -I ..\HARDWARE\KEY -I.\RTE\_Target_1 -ID:\Keil_v5\ARM\PACK\Keil\STM32F1xx_DFP\2.3.0\Device\Include -ID:\Keil_v5\ARM\CMSIS\Include -D__UVISION_VERSION="525" -DSTM32F10X_MD -DSTM32F10X_MD -DUSE_STDPERIPH_DRIVER -o ..\obj\oled.o --omf_browse ..\obj\oled.crf --depend ..\obj\oled.d)
I (..\HARDWARE\OLED\oled.h)(0x625C140F) I (..\HARDWARE\OLED\oled.h)(0x625C140F)
I (..\SYSTEM\sys\sys.h)(0x6256947A) I (..\SYSTEM\sys\sys.h)(0x6256947A)

BIN
stm32/OBJ/adc.o

Binary file not shown.

BIN
stm32/OBJ/core_cm3.o

Binary file not shown.

BIN
stm32/OBJ/delay.o

Binary file not shown.

BIN
stm32/OBJ/encoder.o

Binary file not shown.

BIN
stm32/OBJ/key.o

Binary file not shown.

BIN
stm32/OBJ/led.o

Binary file not shown.

BIN
stm32/OBJ/main.crf

Binary file not shown.

BIN
stm32/OBJ/main.o

Binary file not shown.

BIN
stm32/OBJ/misc.o

Binary file not shown.

BIN
stm32/OBJ/motor.o

Binary file not shown.

BIN
stm32/OBJ/oled.o

Binary file not shown.

BIN
stm32/OBJ/startup_stm32f10x_md.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_adc.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_gpio.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_it.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_rcc.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_tim.o

Binary file not shown.

BIN
stm32/OBJ/stm32f10x_usart.o

Binary file not shown.

BIN
stm32/OBJ/sys.o

Binary file not shown.

BIN
stm32/OBJ/system_stm32f10x.o

Binary file not shown.

BIN
stm32/OBJ/timer.crf

Binary file not shown.

1
stm32/OBJ/timer.d

@ -34,3 +34,4 @@
..\obj\timer.o: ..\HARDWARE\ESP8266\wifi.h ..\obj\timer.o: ..\HARDWARE\ESP8266\wifi.h
..\obj\timer.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\math.h ..\obj\timer.o: D:\Keil_v5\ARM\ARMCC\Bin\..\include\math.h
..\obj\timer.o: ..\HARDWARE\ENCODER\encoder.h ..\obj\timer.o: ..\HARDWARE\ENCODER\encoder.h
..\obj\timer.o: ..\HARDWARE\MOTOR\motor.h

BIN
stm32/OBJ/timer.o

Binary file not shown.

BIN
stm32/OBJ/usart.o

Binary file not shown.

BIN
stm32/OBJ/wifi.o

Binary file not shown.

44
stm32/USER/.vscode/c_cpp_properties.json vendored

@ -3,30 +3,30 @@
{ {
"name": "Target 1", "name": "Target 1",
"includePath": [ "includePath": [
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\LED", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\LED",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\SYSTEM\\delay", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\SYSTEM\\delay",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\SYSTEM\\sys", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\SYSTEM\\sys",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\SYSTEM\\usart", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\SYSTEM\\usart",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\USER", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\USER",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\STM32F10x_FWLib\\inc", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\STM32F10x_FWLib\\inc",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\CORE", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\CORE",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\ESP8266", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\ESP8266",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\DHT11", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\DHT11",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\LCD1602", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\LCD1602",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\ADC", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\ADC",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\TIMER", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\TIMER",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\DS18B20", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\DS18B20",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\cJSON", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\cJSON",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\DS1302", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\DS1302",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\LCD", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\LCD",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\OLED", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\OLED",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\MOTOR", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\MOTOR",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\ENCODER", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\ENCODER",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\HARDWARE\\KEY", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\HARDWARE\\KEY",
"D:\\Keil_v5\\ARM\\ARMCC\\include", "D:\\Keil_v5\\ARM\\ARMCC\\include",
"D:\\Keil_v5\\ARM\\ARMCC\\include\\rw", "D:\\Keil_v5\\ARM\\ARMCC\\include\\rw",
"e:\\项目\\兼职项目\\MotorPid\\stm32\\STM32F10x_FWLib\\src", "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32\\STM32F10x_FWLib\\src",
"e:\\项目\\兼职项目\\MotorPid\\stm32" "e:\\项目\\兼职项目\\20220418-MotorPid\\stm32"
], ],
"defines": [ "defines": [
"STM32F10X_MD", "STM32F10X_MD",

2
stm32/USER/.vscode/keil-assistant.log vendored

@ -20,3 +20,5 @@
[info] Log at : 2022/4/17|21:04:26|GMT+0800 [info] Log at : 2022/4/17|21:04:26|GMT+0800
[info] Log at : 2022/4/18|23:02:10|GMT+0800

2
stm32/USER/.vscode/uv4.log vendored

@ -1,2 +1,2 @@
Load "..\\OBJ\\Template.axf" Load "..\\OBJ\\Template.axf"
Erase Done.Programming Done.Verify OK.Flash Load finished at 00:12:16 Erase Done.Programming Done.Verify OK.Flash Load finished at 23:27:30

2
stm32/USER/.vscode/uv4.log.lock vendored

@ -1 +1 @@
2022/4/18 0:12:17 2022/4/18 23:27:31

980
stm32/USER/Template.map

File diff suppressed because it is too large Load Diff

19
stm32/USER/main.c

@ -1,7 +1,7 @@
/* /*
* @Author: your name * @Author: your name
* @Date: 2022-04-17 21:03:48 * @Date: 2022-04-17 21:03:48
* @LastEditTime: 2022-04-18 00:11:26 * @LastEditTime: 2022-04-18 23:11:30
* @LastEditors: Please set LastEditors * @LastEditors: Please set LastEditors
* @Description: koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: koroFileHeader查看配置 : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: \undefinede:\\\MotorPid\stm32\USER\main.c * @FilePath: \undefinede:\\\MotorPid\stm32\USER\main.c
@ -29,7 +29,6 @@ void Sys_Init(void);
void processingTasks(void); void processingTasks(void);
void OLED_Display(void); void OLED_Display(void);
float Velocity_KP_Mode2=50,Velocity_KI_Mode2=10;
/** /**
* @description: main函数 * @description: main函数
@ -63,17 +62,6 @@ int velocity_PID(int targetSpeed, int currentSpeed){
} }
int Incremental_PI_B_Mode2 (int Encoder,int Target)
{
static int Bias,Pwm,Last_bias;
Bias=Encoder-Target; //计算偏差
Pwm+=Velocity_KP_Mode2*(Bias-Last_bias)+Velocity_KI_Mode2*Bias; //增量式PI控制器
if(Pwm>7200)Pwm=7200;
if(Pwm<-7200)Pwm=-7200;
Last_bias=Bias; //保存上一次偏差
return Pwm; //增量输出
}
/** /**
* @description: * @description:
@ -86,11 +74,6 @@ void processingTasks(void)
// 方向 // 方向
if(userInfo.diversion) AIN1 = 1, AIN1 = 0; if(userInfo.diversion) AIN1 = 1, AIN1 = 0;
else AIN1 = 0, AIN1 = 1; else AIN1 = 0, AIN1 = 1;
//userInfo.currentSpeed = Read_Encoder(2);
key = abs(Incremental_PI_B_Mode2(abs(userInfo.currentSpeed), 20));
PWMA = key;
OLED_ShowNum(0, 4, key,4, 16);
//PWMA = userInfo.pwm_val;
} }
/** /**

Loading…
Cancel
Save