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:
- 1:3bcd844dd707
- Parent:
- 0:4656a133ed1a
- Child:
- 2:3470f2c07582
diff -r 4656a133ed1a -r 3bcd844dd707 main.cpp --- a/main.cpp Mon Feb 01 17:11:03 2021 +0000 +++ b/main.cpp Tue Feb 02 13:43:21 2021 +0000 @@ -37,6 +37,8 @@ #include "mbed.h" #include "MPU9250.h" +#include "KST_Servo.h" +#include "M-Series.h" /* MPU9250 Library * @@ -64,11 +66,20 @@ int errFlag = 0; //define the mpu9250 object -mpu9250_spi *imu[nCh]; +mpu9250_spi *imu[nCh]; // define SPI object for imu objects -SPI spi1(p5, p6, p7); -SPI spi2(p11, p12, p13); +SPI spi1(p5, p6, p7); +SPI spi2(p11, p12, p13); +// pins already used for SPI Chip selector pin +// p21, p23, p29, p30 + +// Servo Motor Control +PwmOut pwm_(p22); + +// M-Series Random Sequence +Mseries m; + void init(void) { @@ -124,9 +135,21 @@ wait_ms(100); printf("Calibrated Magnetrometer\n"); } - + + + printf("\nHit Key [s] to start. Hit Key [r] to finish.\n"); + + - printf("\nHit Key [s] to start. Hit Key [r] to finish.\n"); + pwm_.period_ms(20); // servo requires a 20ms period + pwm_.pulsewidth_us(KST_SERVO_USEC_MIN); + wait(.5); + + pwm_.period_ms(20); // servo requires a 20ms period + pwm_.pulsewidth_us(KST_SERVO_USEC_90); + wait(.5); + + } void eventFunc(void)