これは MMA7361 3軸アナログ加速度センサ の Nucleo F401RE 用のライブラリです。詳しい説明はLibrary中のReadMe.hに記載しています。文字化けや開けない場合はダウンロードしてみてください。Google Chrome では見れるはずです。
Dependents: Nucleo_L3GD20_MMA7361_Kalman
mma7361.h@5:83a3021f51f8, 2016-09-30 (annotated)
- Committer:
- hirokimineshita
- Date:
- Fri Sep 30 04:44:48 2016 +0000
- Revision:
- 5:83a3021f51f8
- Parent:
- 4:c3d863eb7f91
- Child:
- 6:ca882e5e2686
160930 add doxygen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hirokimineshita | 0:ad6f3a862ed5 | 1 | #ifndef _MMA7361_H_20150129_1716_ |
hirokimineshita | 0:ad6f3a862ed5 | 2 | #define _MMA7361_H_20150129_1716_ |
hirokimineshita | 0:ad6f3a862ed5 | 3 | |
hirokimineshita | 0:ad6f3a862ed5 | 4 | #define def -1 |
hirokimineshita | 0:ad6f3a862ed5 | 5 | #define x_axis 0 |
hirokimineshita | 0:ad6f3a862ed5 | 6 | #define y_axis 1 |
hirokimineshita | 0:ad6f3a862ed5 | 7 | #define z_axis 2 |
hirokimineshita | 0:ad6f3a862ed5 | 8 | #define A00 31356 |
hirokimineshita | 0:ad6f3a862ed5 | 9 | #define A10 34040 |
hirokimineshita | 0:ad6f3a862ed5 | 10 | #define A20 28639 |
hirokimineshita | 0:ad6f3a862ed5 | 11 | #define A01 32717 |
hirokimineshita | 0:ad6f3a862ed5 | 12 | #define A11 33388 |
hirokimineshita | 0:ad6f3a862ed5 | 13 | #define A21 31475 |
hirokimineshita | 0:ad6f3a862ed5 | 14 | #define G00 15633 |
hirokimineshita | 0:ad6f3a862ed5 | 15 | #define G10 15797 |
hirokimineshita | 0:ad6f3a862ed5 | 16 | #define G20 15187 |
hirokimineshita | 0:ad6f3a862ed5 | 17 | #define G01 5416 |
hirokimineshita | 0:ad6f3a862ed5 | 18 | #define G11 3220 |
hirokimineshita | 0:ad6f3a862ed5 | 19 | #define G21 7131 |
hirokimineshita | 0:ad6f3a862ed5 | 20 | #define PI 3.1415926535 |
hirokimineshita | 4:c3d863eb7f91 | 21 | #define THHO 0.0000000001 |
hirokimineshita | 0:ad6f3a862ed5 | 22 | |
hirokimineshita | 5:83a3021f51f8 | 23 | /** This progrum is to be easy to control MMA7361 analog sensor\n |
hirokimineshita | 5:83a3021f51f8 | 24 | * site http://akizukidenshi.com/catalog/g/gM-06725/ |
hirokimineshita | 5:83a3021f51f8 | 25 | */ |
hirokimineshita | 0:ad6f3a862ed5 | 26 | class mma7361{ |
hirokimineshita | 0:ad6f3a862ed5 | 27 | private: |
hirokimineshita | 0:ad6f3a862ed5 | 28 | AnalogIn dx; |
hirokimineshita | 0:ad6f3a862ed5 | 29 | AnalogIn dy; |
hirokimineshita | 0:ad6f3a862ed5 | 30 | AnalogIn dz; |
hirokimineshita | 0:ad6f3a862ed5 | 31 | DigitalOut ST; |
hirokimineshita | 0:ad6f3a862ed5 | 32 | DigitalOut GS; |
hirokimineshita | 0:ad6f3a862ed5 | 33 | Serial pcdev; |
hirokimineshita | 0:ad6f3a862ed5 | 34 | int range; //0 : 1.5G 1 : 6.0G |
hirokimineshita | 5:83a3021f51f8 | 35 | |
hirokimineshita | 5:83a3021f51f8 | 36 | /** matrix |
hirokimineshita | 5:83a3021f51f8 | 37 | * |
hirokimineshita | 5:83a3021f51f8 | 38 | * the matrix which use to calcurate the gravity |
hirokimineshita | 5:83a3021f51f8 | 39 | */ |
hirokimineshita | 0:ad6f3a862ed5 | 40 | int mat[4][3]; |
hirokimineshita | 0:ad6f3a862ed5 | 41 | public: |
hirokimineshita | 5:83a3021f51f8 | 42 | |
hirokimineshita | 5:83a3021f51f8 | 43 | /** constracta |
hirokimineshita | 5:83a3021f51f8 | 44 | * |
hirokimineshita | 5:83a3021f51f8 | 45 | * set all pin number |
hirokimineshita | 5:83a3021f51f8 | 46 | * @param accelx analog pin which conect to x-axis (default = PA_0) |
hirokimineshita | 5:83a3021f51f8 | 47 | * @param accely analog pin which conect to y-axis (default = PA_1) |
hirokimineshita | 5:83a3021f51f8 | 48 | * @param accelz analog pin which conect to z-axis (default = PA_4) |
hirokimineshita | 5:83a3021f51f8 | 49 | * @param set digital pin which conect to ST (default = PH_0) |
hirokimineshita | 5:83a3021f51f8 | 50 | * @param set_range digital pin which conect to GS (default = PH_1) |
hirokimineshita | 5:83a3021f51f8 | 51 | */ |
hirokimineshita | 5:83a3021f51f8 | 52 | mma7361(PinName accelx = PA_0,PinName accely = PA_1,PinName accelz = PA_4,PinName set = PH_0,PinName set_range = PH_1); |
hirokimineshita | 5:83a3021f51f8 | 53 | |
hirokimineshita | 5:83a3021f51f8 | 54 | /** function |
hirokimineshita | 5:83a3021f51f8 | 55 | * |
hirokimineshita | 5:83a3021f51f8 | 56 | * do the calibration, you need to conect terminal (ex.TeraTerm) by USB\n |
hirokimineshita | 5:83a3021f51f8 | 57 | * the serial port is set in this class, but it's private\n |
hirokimineshita | 5:83a3021f51f8 | 58 | * please follow the sentence on the terminal\n |
hirokimineshita | 5:83a3021f51f8 | 59 | * this function set the matrix\n |
hirokimineshita | 5:83a3021f51f8 | 60 | * if you don't want to do this or know the data, you can use set_each_num() or set_num() to set matrix |
hirokimineshita | 5:83a3021f51f8 | 61 | */ |
hirokimineshita | 0:ad6f3a862ed5 | 62 | void calibration(); |
hirokimineshita | 5:83a3021f51f8 | 63 | |
hirokimineshita | 5:83a3021f51f8 | 64 | /** function |
hirokimineshita | 5:83a3021f51f8 | 65 | * |
hirokimineshita | 5:83a3021f51f8 | 66 | * |
hirokimineshita | 5:83a3021f51f8 | 67 | */ |
hirokimineshita | 0:ad6f3a862ed5 | 68 | void set_each_num(int ax_0_0,int ay_0_0,int az_0_0,int ax_1_0,int ay_1_0,int az_1_0,int gx_0_0,int gy_0_0,int gz_0_0,int gx_1_0,int gy_1_0,int gz_1_0,int new_range); |
hirokimineshita | 3:0359af763b6c | 69 | void set_num(int (*new_mat)[3],int new_range); |
hirokimineshita | 0:ad6f3a862ed5 | 70 | void set_range(int new_range); |
hirokimineshita | 0:ad6f3a862ed5 | 71 | void clear_mat(); |
hirokimineshita | 0:ad6f3a862ed5 | 72 | int read_bit(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 73 | int read_bit_0(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 74 | float read_by_g(int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 75 | void low_pass_filter(int *int_bit,int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 76 | void show_mat(); |
hirokimineshita | 0:ad6f3a862ed5 | 77 | float bit_to_g(int bit,int axis); |
hirokimineshita | 0:ad6f3a862ed5 | 78 | void set_1st_bit(int *variable,int axis,float direction_G); |
hirokimineshita | 0:ad6f3a862ed5 | 79 | |
hirokimineshita | 0:ad6f3a862ed5 | 80 | float rotate(int *a_value,int a_axis,int *b_value,int b_axis); |
hirokimineshita | 0:ad6f3a862ed5 | 81 | float rad_to_deg(float rad); |
hirokimineshita | 0:ad6f3a862ed5 | 82 | }; |
hirokimineshita | 0:ad6f3a862ed5 | 83 | |
hirokimineshita | 0:ad6f3a862ed5 | 84 | #endif |