mirror of
https://github.com/avem-labs/Avem.git
synced 2023-09-01 15:18:49 +08:00
[MOD]: Fixed BUG, UART Print short data function
This commit is contained in:
parent
a8d4637b4e
commit
1e2bad9a9e
@ -6,9 +6,15 @@
|
||||
#define MOTOR1 TIM3->CCR2
|
||||
#define MOTOR2 TIM3->CCR1
|
||||
|
||||
#define MOTOR_MAX 27360
|
||||
#define MOTOR_MIN 10080
|
||||
#define MOTOR_SETTING() {motor_PWM_Init(28800,5);MOTOR1 = MOTOR_MAX;delay(3000);MOTOR1 = MOTOR_MIN;delay(8000);}
|
||||
#define MOTOR_MAX (unsigned short)27360
|
||||
#define MOTOR_MIN (unsigned short)10080
|
||||
#define MOTOR_SETTING() {\
|
||||
motor_PWM_Init(28800,5);\
|
||||
MOTOR1 = MOTOR_MAX;\
|
||||
delay(3000);\
|
||||
MOTOR1 = MOTOR_MIN;\
|
||||
delay(8000);\
|
||||
}
|
||||
|
||||
void motor_PWM_Init(unsigned short arr, unsigned short psc); //72MHz / (arr + 1)*(psc + 1)
|
||||
|
||||
|
@ -40,10 +40,10 @@ void uart_showData(short k) {
|
||||
uart_sendData(k<0?'-':'+');
|
||||
if(k<0) k=-k;
|
||||
e = (unsigned char)(k % 10);
|
||||
d = (unsigned char)(k/10) % 10;
|
||||
c = (unsigned char)(k/100) % 10;
|
||||
b = (unsigned char)(k/1000) % 10;
|
||||
a = (unsigned char)(k/10000);
|
||||
d = (unsigned char)(k / 10 % 10);
|
||||
c = (unsigned char)(k / 100 % 10);
|
||||
b = (unsigned char)(k / 1000 % 10);
|
||||
a = (unsigned char)(k / 10000);
|
||||
|
||||
uart_sendData(a+'0');
|
||||
uart_sendData(b+'0');
|
||||
|
@ -32,7 +32,6 @@ void pid(float setPoint, float d) {
|
||||
|
||||
short resu = (short)(g_iErro * K_P + g_sumErro * K_I + d * K_D); //PID输出
|
||||
|
||||
|
||||
if((MOTOR1 + resu) > MOTOR_MAX)
|
||||
MOTOR1 = MOTOR_MAX;
|
||||
else if((MOTOR1 + resu) < MOTOR_MIN)
|
||||
|
Loading…
x
Reference in New Issue
Block a user