louis VERZELLESI / Mbed 2 deprecated TP1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
louisverzellesi
Date:
Sun Nov 18 14:16:29 2018 +0000
Commit message:
1

Changed in this revision

Q1PARTIE2.cpp Show annotated file Show diff for this revision Revisions of this file
Q1PARTIE3.cpp Show annotated file Show diff for this revision Revisions of this file
Q1Q2.cpp Show annotated file Show diff for this revision Revisions of this file
Q2PARTIE2.cpp Show annotated file Show diff for this revision Revisions of this file
Q3.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q1PARTIE2.cpp	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,50 @@
+// LSM9DS91 Demo
+
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+// refresh time. set to 500 for part 2 and 50 for part 4
+#define REFRESH_TIME_MS 1000
+
+// Verify that the pin assignments below match your breadboard
+LSM9DS1 imu(p9, p10);
+Serial pc(USBTX, USBRX);
+LocalFileSystem local("local");
+DigitalOut myled(LED1);
+int i;
+float j;
+//Init Serial port and LSM9DS1 chip
+void setup()
+{
+    // Use the begin() function to initialize the LSM9DS0 library.
+    // You can either call it with no parameters (the easy way):
+    uint16_t status = imu.begin();
+
+    //Make sure communication is working
+    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
+    pc.printf("Should be 0x683D\r\n");
+}
+
+int main()
+{
+    FILE *fp = fopen("/local/mesures.csv", "w");
+    
+    setup();  //Setup sensor and Serial
+    pc.printf("------ LSM9DS1 Demo -----------\r\n");
+
+    while (true)
+    {
+        for (i=0;i<=99;i=i++){
+        
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        fprintf(fp,"%d;%2f; %2f; %2f;%2f; %2f; %2f;%2f; %2f; %2f\r\n", i,imu.ax, imu.ay, imu.az,imu.gx, imu.gy, imu.gz,imu.mx, imu.my, imu.mz);
+        myled = 1;
+        wait_ms(0.1);
+        }
+        myled = 0;
+        
+        fclose(fp); 
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q1PARTIE3.cpp	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,53 @@
+// LSM9DS91 Demo
+
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+// refresh time. set to 500 for part 2 and 50 for part 4
+#define REFRESH_TIME_MS 1000
+
+// Verify that the pin assignments below match your breadboard
+LSM9DS1 imu(p9, p10);
+Serial pc(USBTX, USBRX);
+LocalFileSystem local("local");
+DigitalOut myled(LED1);
+int i;
+float j;
+float g;
+float sina;
+float angleroulis;
+float angletanguage;
+float sinb;
+float theta;
+//Init Serial port and LSM9DS1 chip
+void setup()
+{
+    // Use the begin() function to initialize the LSM9DS0 library.
+    // You can either call it with no parameters (the easy way):
+    uint16_t status = imu.begin();
+
+    //Make sure communication is working
+    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
+    pc.printf("Should be 0x683D\r\n");
+}
+
+int main()
+{
+    
+    setup();  //Setup sensor and Serial
+    pc.printf("------ LSM9DS1 Demo -----------\r\n");
+
+    while (true)
+    {
+        myled = 1;
+        for (i=0;i<=99;i=i++){
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        theta = atan(imu.my/imu.mx)*(180/3.1416);
+        pc.printf ("theta= %f\n\r",theta);
+        myled = 1;
+        wait_ms(0.8);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q1Q2.cpp	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,48 @@
+  pc.printf("G: %2f, %2f, %2f\r\n", imu.gx, imu.gy, imu.gz);
+
+        imu.readMag();
+        
+        pc.printf("M: %2f, %2f, %2f\r\n\r\n", imu.mx, imu.my, imu.mz);
+       
+        wait_// LSM9DS91 Demo
+
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+// refresh time. set to 500 for part 2 and 50 for part 4
+#define REFRESH_TIME_MS 1000
+
+// Verify that the pin assignments below match your breadboard
+LSM9DS1 imu(p9, p10);
+
+Serial pc(USBTX, USBRX);
+
+//Init Serial port and LSM9DS1 chip
+void setup()
+{
+    // Use the begin() function to initialize the LSM9DS0 library.
+    // You can either call it with no parameters (the easy way):
+    uint16_t status = imu.begin();
+
+    //Make sure communication is working
+    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
+    pc.printf("Should be 0x683D\r\n");
+}
+
+int main()
+{
+    setup();  //Setup sensor and Serial
+    pc.printf("------ LSM9DS1 Demo -----------\r\n");
+
+    while (true)
+    {
+        
+        imu.readAccel();
+    
+        pc.printf("A: %2f, %2f, %2f\r\n", imu.ax, imu.ay, imu.az);
+
+        imu.readGyro();
+ms(REFRESH_TIME_MS);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q2PARTIE2.cpp	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,58 @@
+// LSM9DS91 Demo
+
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+// refresh time. set to 500 for part 2 and 50 for part 4
+#define REFRESH_TIME_MS 1000
+
+// Verify that the pin assignments below match your breadboard
+LSM9DS1 imu(p9, p10);
+Serial pc(USBTX, USBRX);
+LocalFileSystem local("local");
+DigitalOut myled(LED1);
+int i;
+float j;
+float g;
+float sina;
+float angleroulis;
+float angletanguage;
+float sinb;
+//Init Serial port and LSM9DS1 chip
+void setup()
+{
+    // Use the begin() function to initialize the LSM9DS0 library.
+    // You can either call it with no parameters (the easy way):
+    uint16_t status = imu.begin();
+
+    //Make sure communication is working
+    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
+    pc.printf("Should be 0x683D\r\n");
+}
+
+int main()
+{
+    
+    setup();  //Setup sensor and Serial
+    pc.printf("------ LSM9DS1 Demo -----------\r\n");
+
+    while (true)
+    {
+        for (i=0;i<=99;i=i++){
+        
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        g = sqrt((imu.ax)*(imu.ax)+(imu.ay)*(imu.ay)+(imu.az)*(imu.az));
+        sina = (-1*imu.ay)/g;
+        angleroulis = asin(sina)*(180/3.1416);
+        sinb= imu.ax/g;
+        angletanguage = asin(sinb)*(180/3.1416);
+        pc.printf ("anglea= %f;angleb= %f\n\r",angleroulis,angletanguage);
+        myled = 1;
+        wait_ms(0.5);
+        }
+        myled = 0;
+       
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Q3.cpp	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,50 @@
+// LSM9DS91 Demo
+
+#include "mbed.h"
+#include "LSM9DS1.h"
+
+// refresh time. set to 500 for part 2 and 50 for part 4
+#define REFRESH_TIME_MS 1000
+
+// Verify that the pin assignments below match your breadboard
+LSM9DS1 imu(p9, p10);
+Serial pc(USBTX, USBRX);
+LocalFileSystem local("local");
+DigitalOut myled(LED1);
+int i;
+float j;
+//Init Serial port and LSM9DS1 chip
+void setup()
+{
+    // Use the begin() function to initialize the LSM9DS0 library.
+    // You can either call it with no parameters (the easy way):
+    uint16_t status = imu.begin();
+
+    //Make sure communication is working
+    pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status);
+    pc.printf("Should be 0x683D\r\n");
+}
+
+int main()
+{
+    FILE *fp = fopen("/local/mesures.csv", "w");
+    
+    setup();  //Setup sensor and Serial
+    pc.printf("------ LSM9DS1 Demo -----------\r\n");
+
+    while (true)
+    {
+        for (i=0;i<=99;i=i++){
+        
+        imu.readAccel();
+        imu.readGyro();
+        imu.readMag();
+        fprintf(fp,"%d;%2f; %2f; %2f;%2f; %2f; %2f;%2f; %2f; %2f\r\n", i,imu.ax, imu.ay, imu.az,imu.gx, imu.gy, imu.gz,imu.mx, imu.my, imu.mz);
+        myled = 1;
+        wait_ms(0.1);
+        }
+        myled = 0;
+        
+        fclose(fp); 
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 18 14:16:29 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file