Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LSM9DS1 MadgwickAHRS
Revision 0:6c187b735281, committed 2019-04-25
- Comitter:
- 771_8bit
- Date:
- Thu Apr 25 04:04:10 2019 +0000
- Child:
- 1:50b33bd88ea5
- Commit message:
- hello
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM9DS1.lib Thu Apr 25 04:04:10 2019 +0000 @@ -0,0 +1,1 @@ +LSM9DS1#cc9489570dd1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MadgwickAHRS.lib Thu Apr 25 04:04:10 2019 +0000 @@ -0,0 +1,1 @@ +MadgwickAHRS#0f88b99a97ce
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Apr 25 04:04:10 2019 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "LSM9DS1.h"
+#include "MadgwickAHRS.h"
+
+RawSerial pc(USBTX, USBRX);
+
+LSM9DS1 lsm = LSM9DS1(PB_5, PB_4, PB_3,PB_10,PA_8); //mosi,miso,sclk,cs_AG,cs_M
+Ticker AHRS;
+Ticker PRINT;
+DigitalOut myled(LED1);
+Madgwick filter = Madgwick();
+
+void ahrs(){
+ filter.update(lsm.gyro_y, lsm.gyro_x, lsm.gyro_z, lsm.accel_y, lsm.accel_x, lsm.accel_z ,lsm.mag_y, lsm.mag_x, lsm.mag_z);
+}
+
+void print(){
+ printf("roll:%f,pitch:%f,yaw:%f,accel_z:%f,gyro_z:%f,mag_x:%f\r\n", filter.getRoll(),filter.getPitch(),filter.getYaw(),lsm.accel_z, lsm.gyro_z,lsm.mag_x);
+}
+
+int main() {
+ lsm.initSPI();
+ lsm.initAccel(lsm.LSM9DS1_ACCELRANGE_8G); //2,4,8,16
+ lsm.initGyro(lsm.LSM9DS1_GYROSCALE_500DPS); //245,500,2000
+ lsm.initMag(lsm.LSM9DS1_MAGGAIN_4GAUSS); //4,8,12,16
+
+ filter.begin(100); // N Hz
+ AHRS.attach_us(&ahrs, 10000); // N us周期
+
+ PRINT.attach(&print,1);
+
+ while(1){
+ lsm.readGyro();
+ lsm.readAccel();
+ lsm.readMag();
+ wait(0.1);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Apr 25 04:04:10 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file