2Chx3dof Magnetrometer supported M-Series Random Sequence Generator Servo Control
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
Diff: main.cpp
- Branch:
- MPU-9250-MagSensServo
- Revision:
- 9:b32312aacbba
- Parent:
- 8:07c3cb01a5b6
- Child:
- 10:f5a805d998d6
--- a/main.cpp Tue Feb 02 17:12:57 2021 +0000 +++ b/main.cpp Tue Feb 02 17:24:02 2021 +0000 @@ -88,7 +88,8 @@ Mseries m; // M-series update flag -int m_flag = 0; +#define M_TERM 100; +int m_cnt = M_TERM; #define BINARY_MODE 0 #define ASCII_MODE 1 @@ -196,9 +197,17 @@ void eventFunc(void) { int t_ms = timer.read_ms() - 5; // initial call takes 5ms - - - + + // when M-series counter overflow occurs + if(--m_cnt < 0) { + m.update(); + if(m.get()) + pwm_.pulsewidth_us(KST_SERVO_USEC_MIN); + else + pwm_.pulsewidth_us(KST_SERVO_USEC_90); + m_cnt = M_TERM; + } + // limitation on sending bytes at 921600bps - 92bits(under 100us/sample) // requirement : 1kHz sampling // = 921.5 bits/sample @@ -237,7 +246,7 @@ case ASCII_MODE: printf("%ld,",smpl_cnt++); printf("%1.3f,",t_ms/1000.0f); - printf("%d,",m.update()); + printf("%d,",m.get()); 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]);