[MOD]: Fixed BUG, UART Print short data function

This commit is contained in:
but0n 2016-09-27 15:31:19 +08:00
parent a8d4637b4e
commit 1e2bad9a9e
3 changed files with 13 additions and 8 deletions

View File

@ -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)

View File

@ -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');

View File

@ -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)