Main Program
Dependencies: mbed AQM1602 HMC6352 PID
setting/def.h@16:6900f47fa0b5, 2016-01-11 (annotated)
- Committer:
- lilac0112_1
- Date:
- Mon Jan 11 17:45:56 2016 +0000
- Revision:
- 16:6900f47fa0b5
- Parent:
- 15:88f2c525caca
- Child:
- 18:97eba56f82e4
type pin number
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lilac0112_1 | 1:f2633c150301 | 1 | #ifndef _DEF_H_ |
lilac0112_1 | 1:f2633c150301 | 2 | #define _DEF_H_ |
lilac0112_1 | 1:f2633c150301 | 3 | |
lilac0112_1 | 1:f2633c150301 | 4 | //BT(BlueTooth) |
lilac0112_1 | 1:f2633c150301 | 5 | #define DATA_NUM 8+2//2byte→KEYCODE(拝啓)とCHECKCODE(敬具) 8byte→やりとりするデータ |
lilac0112_1 | 1:f2633c150301 | 6 | #define TX_KEYCODE 0xAA//あちらのKEYCODE |
lilac0112_1 | 1:f2633c150301 | 7 | #define RX_KEYCODE 0xAA//こちらのKEYCODE |
lilac0112_1 | 1:f2633c150301 | 8 | #define KEY 0//KEYCODEは配列の最初 |
lilac0112_1 | 1:f2633c150301 | 9 | #define CHECK DATA_NUM-1//CHECKCODEは配列の最後 |
lilac0112_1 | 1:f2633c150301 | 10 | |
lilac0112_1 | 4:69fd47e1d296 | 11 | |
lilac0112_1 | 10:3d0714c1ac75 | 12 | //Switch 入力値 |
lilac0112_1 | 16:6900f47fa0b5 | 13 | #define NONE 0 |
lilac0112_1 | 16:6900f47fa0b5 | 14 | #define UP 1 |
lilac0112_1 | 16:6900f47fa0b5 | 15 | #define DOWN 2 |
lilac0112_1 | 16:6900f47fa0b5 | 16 | #define RIGHT 3 |
lilac0112_1 | 16:6900f47fa0b5 | 17 | #define LEFT 4 |
lilac0112_1 | 15:88f2c525caca | 18 | |
lilac0112_1 | 10:3d0714c1ac75 | 19 | //Lcd 設定値 |
lilac0112_1 | 4:69fd47e1d296 | 20 | #define BUFSIZE 10 |
lilac0112_1 | 6:4e83c236ee57 | 21 | #define STATE_NUM_X 0x04 |
lilac0112_1 | 6:4e83c236ee57 | 22 | #define STATE_NUM_Y 0x10 |
lilac0112_1 | 10:3d0714c1ac75 | 23 | //繰り返し割り込み |
lilac0112_1 | 10:3d0714c1ac75 | 24 | #define DUTY_NUM 1 |
lilac0112_1 | 6:4e83c236ee57 | 25 | |
lilac0112_1 | 10:3d0714c1ac75 | 26 | #define DUTY_SW 0 |
lilac0112_1 | 10:3d0714c1ac75 | 27 | #define DUTY_GYRO 1 |
lilac0112_1 | 10:3d0714c1ac75 | 28 | #define DUTY_PING 2 |
lilac0112_1 | 10:3d0714c1ac75 | 29 | #define DUTY_COLOR 3 |
lilac0112_1 | 10:3d0714c1ac75 | 30 | #define DUTY_MOUSE 4 |
lilac0112_1 | 1:f2633c150301 | 31 | |
lilac0112_1 | 13:f8f5bd2f0525 | 32 | //MPU6050関連 |
lilac0112_1 | 13:f8f5bd2f0525 | 33 | //config.h |
lilac0112_1 | 13:f8f5bd2f0525 | 34 | |
lilac0112_1 | 16:6900f47fa0b5 | 35 | /*PID処理*/ |
lilac0112_1 | 16:6900f47fa0b5 | 36 | #define RATE 0.052//52 |
lilac0112_1 | 16:6900f47fa0b5 | 37 | #define PID_BIAS 0.2 |
lilac0112_1 | 16:6900f47fa0b5 | 38 | #define REFERENCE 180.0 |
lilac0112_1 | 16:6900f47fa0b5 | 39 | #define MINIMUM 0.0 |
lilac0112_1 | 16:6900f47fa0b5 | 40 | #define MAXIMUM 359.9 |
lilac0112_1 | 16:6900f47fa0b5 | 41 | #define P_GAIN 1.4//1.4 //0.78 |
lilac0112_1 | 16:6900f47fa0b5 | 42 | #define I_GAIN 0.0 //0.0 |
lilac0112_1 | 16:6900f47fa0b5 | 43 | #define D_GAIN 0.05 //0.009 |
lilac0112_1 | 16:6900f47fa0b5 | 44 | #define OUT_LIMIT 30.0 |
lilac0112_1 | 16:6900f47fa0b5 | 45 | #define MAX_POW 100 |
lilac0112_1 | 16:6900f47fa0b5 | 46 | #define MIN_POW -100 |
lilac0112_1 | 16:6900f47fa0b5 | 47 | #define PID_CYCLE 0.05 //s |
lilac0112_1 | 16:6900f47fa0b5 | 48 | |
lilac0112_1 | 16:6900f47fa0b5 | 49 | //計算 |
lilac0112_1 | 16:6900f47fa0b5 | 50 | #define ROUND(x) ((x > 0) ? (x + 0.5) : (x - 0.5))//x...整数 |
lilac0112_1 | 16:6900f47fa0b5 | 51 | #define PI 3.14159265358979323846 |
lilac0112_1 | 16:6900f47fa0b5 | 52 | #define DEG2RAD(deg) (PI*(deg)/180.0) |
lilac0112_1 | 16:6900f47fa0b5 | 53 | #define RAD2DEG(rad) (180.0(rad)/PI) |
lilac0112_1 | 16:6900f47fa0b5 | 54 | |
lilac0112_1 | 13:f8f5bd2f0525 | 55 | //データ |
lilac0112_1 | 1:f2633c150301 | 56 | typedef struct { |
lilac0112_1 | 1:f2633c150301 | 57 | uint8_t ping[4]; |
lilac0112_1 | 1:f2633c150301 | 58 | uint8_t ir[12]; |
lilac0112_1 | 1:f2633c150301 | 59 | uint8_t irLong[6]; |
lilac0112_1 | 1:f2633c150301 | 60 | uint8_t line[3]; |
lilac0112_1 | 16:6900f47fa0b5 | 61 | int mouse[2];//0...x,1...y//1cm nearlyeq 1000count |
lilac0112_1 | 16:6900f47fa0b5 | 62 | uint16_t gyro, GyroInitialValue, FrontDeg;//0<x<3599 |
lilac0112_1 | 16:6900f47fa0b5 | 63 | double InputPID;//<<gyrosensor |
lilac0112_1 | 16:6900f47fa0b5 | 64 | double OutputPID;//>>motor |
lilac0112_1 | 1:f2633c150301 | 65 | uint8_t color[3]; |
lilac0112_1 | 5:de0f26f533d8 | 66 | uint8_t lcdpoint[2]; |
lilac0112_1 | 10:3d0714c1ac75 | 67 | uint8_t stopflag; |
lilac0112_1 | 1:f2633c150301 | 68 | } Record; |
lilac0112_1 | 1:f2633c150301 | 69 | |
lilac0112_1 | 1:f2633c150301 | 70 | #endif |