aaaaa

Dependencies:   HMC6352 PID QEI Servo mbed

Committer:
yusuke_robocup
Date:
Mon Sep 30 09:01:37 2013 +0000
Revision:
0:1be472d79ae9
PIDsync

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yusuke_robocup 0:1be472d79ae9 1 #define RATE 0.1
yusuke_robocup 0:1be472d79ae9 2 #define MINIMUM -1440
yusuke_robocup 0:1be472d79ae9 3 #define MAXIMUM 1440
yusuke_robocup 0:1be472d79ae9 4
yusuke_robocup 0:1be472d79ae9 5 #define PID_CYCLE 0.03 //s
yusuke_robocup 0:1be472d79ae9 6 #define COMPASS_CYCLE 0.1
yusuke_robocup 0:1be472d79ae9 7
yusuke_robocup 0:1be472d79ae9 8 #define P_GAIN 1.2 //0.78 //zensin 1.5
yusuke_robocup 0:1be472d79ae9 9 #define I_GAIN 1000000000.0
yusuke_robocup 0:1be472d79ae9 10 #define D_GAIN 0.0 //0.009
yusuke_robocup 0:1be472d79ae9 11
yusuke_robocup 0:1be472d79ae9 12 #define PID_BIAS 0.0
yusuke_robocup 0:1be472d79ae9 13 #define REFERENCE 0
yusuke_robocup 0:1be472d79ae9 14
yusuke_robocup 0:1be472d79ae9 15 #define OUT_LIMIT 1000
yusuke_robocup 0:1be472d79ae9 16
yusuke_robocup 0:1be472d79ae9 17 extern double ultrasonicValue[4];
yusuke_robocup 0:1be472d79ae9 18 extern uint16_t ultrasonicVal[4];
yusuke_robocup 0:1be472d79ae9 19 extern void Ultrasonic(void);
yusuke_robocup 0:1be472d79ae9 20 Timer timer2;
yusuke_robocup 0:1be472d79ae9 21 Timer ping_t;
yusuke_robocup 0:1be472d79ae9 22
yusuke_robocup 0:1be472d79ae9 23 HMC6352 compass(p28/*sda*/, p27/*scl*/);
yusuke_robocup 0:1be472d79ae9 24 Ticker compassUpdata;
yusuke_robocup 0:1be472d79ae9 25
yusuke_robocup 0:1be472d79ae9 26 PID pid(P_GAIN,I_GAIN,D_GAIN, RATE);
yusuke_robocup 0:1be472d79ae9 27 PID controller(1.0, 0.0, 0.0, RATE);
yusuke_robocup 0:1be472d79ae9 28 Ticker pidUpdata;
yusuke_robocup 0:1be472d79ae9 29
yusuke_robocup 0:1be472d79ae9 30 Servo servoR(p23);
yusuke_robocup 0:1be472d79ae9 31 Servo servoL(p24);
yusuke_robocup 0:1be472d79ae9 32
yusuke_robocup 0:1be472d79ae9 33 DigitalIn swR(p29);
yusuke_robocup 0:1be472d79ae9 34 DigitalIn swL(p30);
yusuke_robocup 0:1be472d79ae9 35
yusuke_robocup 0:1be472d79ae9 36 DigitalOut led1(LED1);
yusuke_robocup 0:1be472d79ae9 37 DigitalOut led2(LED2);
yusuke_robocup 0:1be472d79ae9 38
yusuke_robocup 0:1be472d79ae9 39 QEI wheel1 (p18, p17, NC, 624);
yusuke_robocup 0:1be472d79ae9 40 QEI wheel2 (p8, p7, NC, 624);
yusuke_robocup 0:1be472d79ae9 41
yusuke_robocup 0:1be472d79ae9 42 #define Convert_dekaruto(a) ((a+1000.0)/2.0/1000.0)
yusuke_robocup 0:1be472d79ae9 43 #define CYCLE 705.0
yusuke_robocup 0:1be472d79ae9 44
yusuke_robocup 0:1be472d79ae9 45 enum{
yusuke_robocup 0:1be472d79ae9 46 WAIT,
yusuke_robocup 0:1be472d79ae9 47 STRAIGHT,
yusuke_robocup 0:1be472d79ae9 48 TURN,
yusuke_robocup 0:1be472d79ae9 49 COMP
yusuke_robocup 0:1be472d79ae9 50 };