p kj
/
LPC824-BalanceCar
Microduino
Fork of BalanceCar by
userDef.h@2:99785a1007a4, 2016-06-07 (annotated)
- Committer:
- lixianyu
- Date:
- Tue Jun 07 05:26:03 2016 +0000
- Revision:
- 2:99785a1007a4
- Parent:
- 0:a4d8f5b3c546
Still not work......commit first.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lixianyu | 0:a4d8f5b3c546 | 1 | //#include <arduino.h> |
lixianyu | 0:a4d8f5b3c546 | 2 | |
lixianyu | 0:a4d8f5b3c546 | 3 | //通讯模式 |
lixianyu | 0:a4d8f5b3c546 | 4 | //#define BLE_SoftSerial //软串口模式 |
lixianyu | 0:a4d8f5b3c546 | 5 | #ifndef BLE_SoftSerial //如果没开启软串口,就开硬串口模式 |
lixianyu | 0:a4d8f5b3c546 | 6 | #if defined(__AVR_ATmega32U4__) |
lixianyu | 0:a4d8f5b3c546 | 7 | #define BLE_HardSerial Serial1 |
lixianyu | 0:a4d8f5b3c546 | 8 | #else |
lixianyu | 0:a4d8f5b3c546 | 9 | #define BLE_HardSerial Serial |
lixianyu | 0:a4d8f5b3c546 | 10 | #endif |
lixianyu | 0:a4d8f5b3c546 | 11 | #endif |
lixianyu | 0:a4d8f5b3c546 | 12 | #define BLE_SPEED 9600 //蓝牙接口速度 |
lixianyu | 0:a4d8f5b3c546 | 13 | #define NRF_CHANNEL 70 //nRF通道 |
lixianyu | 0:a4d8f5b3c546 | 14 | #define CHANNEL_THROTTLE 1 //油门通道 |
lixianyu | 0:a4d8f5b3c546 | 15 | #define CHANNEL_STEERING 0 //转向通道 |
lixianyu | 0:a4d8f5b3c546 | 16 | #define SAFE_TIME_OUT 250 //失控保护时间 |
lixianyu | 0:a4d8f5b3c546 | 17 | |
lixianyu | 0:a4d8f5b3c546 | 18 | //角度/速度修正参数 |
lixianyu | 2:99785a1007a4 | 19 | #define ANGLE_FIX -1.3 |
lixianyu | 0:a4d8f5b3c546 | 20 | #define MAX_TARGET_ANGLE 12 //最大目标角度12 |
lixianyu | 0:a4d8f5b3c546 | 21 | #define MAX_SPEED 1200 |
lixianyu | 0:a4d8f5b3c546 | 22 | #define MAX_THROTTLE 512 //最大油门 < 512 |
lixianyu | 0:a4d8f5b3c546 | 23 | #define MAX_STEERING 128 //最大转向 < 256 |
lixianyu | 0:a4d8f5b3c546 | 24 | |
lixianyu | 0:a4d8f5b3c546 | 25 | //姿态传感器安装方向 |
lixianyu | 0:a4d8f5b3c546 | 26 | enum _DIRECTION { |
lixianyu | 0:a4d8f5b3c546 | 27 | YAW = 0, |
lixianyu | 0:a4d8f5b3c546 | 28 | PITCH, |
lixianyu | 0:a4d8f5b3c546 | 29 | ROLL |
lixianyu | 0:a4d8f5b3c546 | 30 | }; |
lixianyu | 0:a4d8f5b3c546 | 31 | #define DIRECTION PITCH |
lixianyu | 0:a4d8f5b3c546 | 32 | |
lixianyu | 0:a4d8f5b3c546 | 33 | //PID整定参数 |
lixianyu | 0:a4d8f5b3c546 | 34 | #define KP_ANG 0.15 // 0.25 |
lixianyu | 0:a4d8f5b3c546 | 35 | #define KI_ANG 0 |
lixianyu | 0:a4d8f5b3c546 | 36 | #define KD_ANG 35 // 30 28 26 |
lixianyu | 0:a4d8f5b3c546 | 37 | #define KP_SPD 0.04 //0.08//0.065 |
lixianyu | 0:a4d8f5b3c546 | 38 | #define KI_SPD 0.02 //0.05 |
lixianyu | 0:a4d8f5b3c546 | 39 | #define KD_SPD 0.0 |
lixianyu | 0:a4d8f5b3c546 | 40 | |
lixianyu | 0:a4d8f5b3c546 | 41 | #define KP_ANG_RAISUP 0.52 |
lixianyu | 0:a4d8f5b3c546 | 42 | #define KI_ANG_RAISUP 0 |
lixianyu | 0:a4d8f5b3c546 | 43 | #define KD_ANG_RAISUP 45 |
lixianyu | 0:a4d8f5b3c546 | 44 | #define KP_SPD_RAISUP 0 |
lixianyu | 0:a4d8f5b3c546 | 45 | #define KI_SPD_RAISUP 0 |
lixianyu | 0:a4d8f5b3c546 | 46 | #define KD_SPD_RAISUP 0 |
lixianyu | 0:a4d8f5b3c546 | 47 | |
lixianyu | 0:a4d8f5b3c546 | 48 | //#define BAT_DETECT 5*84/33.0 |
lixianyu | 0:a4d8f5b3c546 | 49 | |
lixianyu | 0:a4d8f5b3c546 | 50 |