final cup

Dependencies:   HMC6352 PID mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

00001 
00002 
00003 #define RATE    0.052
00004 #define Long    1.0
00005 #define ENTER   0
00006 #define EXIT    1
00007 #define MOT_NUM 4
00008 #define MOTDRIVER_WAIT  300 //ms
00009 #define BAUD_RATE       115200
00010 #define BAUD_RATE2      19200
00011 #define BUT_WAIT        0.3 //s
00012 #define ON      1
00013 #define OFF     0
00014 
00015 #define PING_ERROR  0xFFFF
00016 
00017 #define MOT1    1.0
00018 #define MOT2    1.0
00019 #define MOT3    1.0
00020 #define MOT4    1.0
00021 
00022 #define OUT_LIMIT   20.0
00023 #define MAX_POW     100
00024 #define MIN_POW     -100
00025 
00026 DigitalOut led1(LED1); 
00027 DigitalOut led2(LED2);
00028 DigitalOut led3(LED3);
00029 DigitalOut led4(LED4);
00030 BusOut mbedleds(LED4,LED3,LED2,LED1); 
00031 HMC6352 compass(p9, p10);
00032 Serial driver(p28, p27); // tx, rx 
00033 Serial device2(p13, p14);  // tx, rx
00034 Serial pc(USBTX, USBRX); // tx, rx 
00035 DigitalIn StartButton(p21);
00036 DigitalIn CalibEnterButton(p22);
00037 DigitalIn CalibExitButton(p23);
00038 DigitalIn EEPROMButton(p24);
00039 PID pid(0.60, 0.0, 0.010, RATE);      //battery is low power version 30.0 0.58 1.0 0.015    battery is high power version   30.0 0.42, 1.0, 0.013   power is low but perfect 20.0 0.45, 0.0, 0.010
00040 Ticker pidUpdata;
00041 Timer timer1;
00042 Timer Ctimer;
00043 LocalFileSystem local("local");  // マウントポイントを定義(ディレクトリパスになる)
00044 
00045 enum{
00046     HOME_WAIT,
00047     DIFFENCE,
00048     WARNING,
00049     HOLD,
00050 };
00051 
00052 
00053 double standTu = 0;
00054 int speed[MOT_NUM] = {0};
00055 uint8_t hold_flag = 0;
00056 uint8_t state = HOME_WAIT;
00057 
00058 float inputPID = 180.0;
00059 static double standard;
00060 float compassPID = 0.0;
00061 
00062 extern int diff;
00063 
00064 extern string StringFIN;
00065 
00066 extern uint8_t direction;
00067 extern uint8_t Distance;
00068 extern uint8_t IR_found;
00069 
00070 extern void PidUpdata(void);
00071 extern void array(int,int,int,int);
00072 
00073 extern void dev_rx(void);
00074 extern void dev_tx(void);
00075 
00076 extern uint16_t ultrasonicVal[4];
00077 
00078 #define FRONT_SONIC ultrasonicVal[0]
00079 #define BACK_SONIC  ultrasonicVal[2]
00080 #define RIGHT_SONIC ultrasonicVal[1]
00081 #define LEFT_SONIC  ultrasonicVal[3]    
00082 
00083