2Chx3dof Magnetrometer supported M-Series Random Sequence Generator Servo Control

Dependencies:   mbed

Sampling Frequency

Sampling Frequency in main.cpp

#define SampleFreq     200   // [Hz]

Auto Stop Setting

Auto-stop Timer 15sec after

    // auto-stop when 15sec after
    if(smpl_cnt>3000){stop_dump();}

The number of 3000 means Sample Count. The number is given by SampleFreq[Hz] * Auto-Stop Time [sec].

M-Series Random Sequence

M-series Random Update Term in main.cpp

// M-series update flag
#define  M_TERM  200;

Unit is sample count.

cf.) 200 equals to 200 [samples] which equals to 1 [second] where SampleFreq = 200 [Hz}.

See above.

M-Series Random Servo Control

Branch:
MPU-9250-MagSensServo
Revision:
8:07c3cb01a5b6
Parent:
7:a711da20a262
Child:
9:b32312aacbba
--- a/main.cpp	Tue Feb 02 15:44:38 2021 +0000
+++ b/main.cpp	Tue Feb 02 17:12:57 2021 +0000
@@ -9,9 +9,12 @@
                 @ Deleted magnet sensor checking
                 @ Set Acc Data Rates, Enable Acc LPF , Bandwidth 218Hz
                 @ Use DLPF set Gyroscope bandwidth 5Hz, temperature bandwidth 5Hz
- * Feb  1, 2021 @Magnetro Meter Ch1 & Ch3,
-                 Servo Motor PWM (p22),
-                 2000DPS, 2G, DLP 5Hz
+ * Feb  1, 2021 @ Magnetro Meter Ch1 & Ch3,
+                @ 2000DPS, 2G, DLP 5Hz
+                @ M-Series Random Sequence Added
+                @ Servo Motor PWM (p22),
+                @ Text Dump is prioritized
+                @ LED Flashing to appeal ERROR State
  *
  * MPU9250 9DoF Sensor (Extended to Ch1 ~ Ch4)
  *
@@ -84,11 +87,14 @@
 // M-Series Random Sequence
 Mseries m;
 
+// M-series update flag
+int  m_flag = 0;
+
 #define BINARY_MODE 0
 #define ASCII_MODE  1
 int send_mode = BINARY_MODE;
 
-#define CSV_TITLE_COLMUN "smpl_cnt,time[sec],accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,\r\n"
+#define CSV_TITLE_COLUMN "smpl_cnt,time[sec],M_stat,accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,accX,accY,accZ,gyroX,gyroY,gyroZ,magX,magY,magZ,\r\n"
 
 
 void servo_test(void)
@@ -191,6 +197,8 @@
 {
     int t_ms = timer.read_ms() - 5; // initial call takes 5ms
     
+    
+    
     // limitation on sending bytes at 921600bps - 92bits(under 100us/sample)
     // requirement : 1kHz sampling
     // = 921.5 bits/sample
@@ -229,6 +237,7 @@
         case ASCII_MODE:
             printf("%ld,",smpl_cnt++);
             printf("%1.3f,",t_ms/1000.0f);
+            printf("%d,",m.update());
             for(int i=0; i<3; i+=2) {
                 for(int j=0; j<3; j++) printf("%1.3f,",imu[i]->accelerometer_data[j]);
                 for(int j=0; j<3; j++) printf("%1.3f,",imu[i]->gyroscope_data[j]);
@@ -277,8 +286,9 @@
                     break;
 
                 case 't':
-                    printf(CSV_TITLE_COLMUN);
+                    printf(CSV_TITLE_COLUMN);
                     smpl_cnt = 0;
+                    m.init();
                     timer.reset();
                     timer.start();
                     send_mode = ASCII_MODE;
@@ -286,7 +296,7 @@
                     break;
 
                 case 'c':
-                    printf(CSV_TITLE_COLMUN);
+                    printf(CSV_TITLE_COLUMN);
                     break;
 
                 case 's':