Code to read the ADXL355 values using the EV COG4050.

Dependencies:   ADXL355

Files at this revision

API Documentation at this revision

Comitter:
RGurav
Date:
Wed Aug 15 11:52:56 2018 +0000
Commit message:
Code to read values of the ADXL355 using the EV-COG4050

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
ADXL355.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Wed Aug 15 11:52:56 2018 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADXL355.lib	Wed Aug 15 11:52:56 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/RGurav/code/ADXL355/#1b8d65be0eef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Wed Aug 15 11:52:56 2018 +0000
@@ -0,0 +1,18 @@
+
+
+Following is the connection between EV-COG4050 and ADXL355 using the COG expander baord.
+
+ADXL35x on the EV-GEAR-EXPANDER1Z
+CONNECTION DIAGRAM through P4 PMOD_SP1
+
+SIGNAL_NAME     PIN NUM     EVAL-ADXL35xZ
+SPI1_CS0        PMOD-P4 1   P2 2
+SPI1_MOSI       PMOD-P4 2   P2 6
+SPI1_MISO       PMOD-P4 3   P2 5
+SPI1_CLK        PMOD-P4 4   P2 4
+GND             PMOD-P4 5   P1 5
+FT_EXT_VDD_OUT  PMOD-P4 6   P1 1
+FT_EXT_VDD_OUT  PMOD-P4 12  P1 3
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 15 11:52:56 2018 +0000
@@ -0,0 +1,75 @@
+/*
+Created on: 15/08/2018
+Author: Rohan Gurav
+        Valeria Toffoli
+Code: Use the following code to read the ADXL355 values connected to the SPI channel 
+      of the EV-COG4050-Expander board port0. Check the readme.md for connection info  
+
+*/
+#include "mbed.h"
+#include <inttypes.h>
+#include "ADXL355.h"
+//#include "ADXRS290.h"
+
+Serial pc(USBTX, USBRX);
+
+ADXL355 accl(SPI1_CS0, SPI1_MOSI, SPI1_MISO, SPI1_SCLK);    // PMOD port
+//ADXRS290 gyro(SPI0_CS2, SPI0_MOSI, SPI0_MISO, SPI0_SCLK);   // PMOD port
+
+    
+int main()
+{
+    pc.baud(9600);
+    pc.printf("SPI ADXL355 and ADXL357 Demo\r\n");
+    pc.printf("GET device ID\r\n");
+   
+    accl.reset();
+    uint8_t d; 
+    
+    d=accl.read_reg(accl.DEVID_AD);
+    pc.printf("AD id = %x \r\n",d);
+    
+    d=accl.read_reg(accl.DEVID_MST);
+    pc.printf("MEMS id = %x \r\n",d);
+    
+    d=accl.read_reg(accl.PARTID);
+    pc.printf("device id = %x \r\n",d);
+    
+    d=accl.read_reg(accl.REVID);
+    pc.printf("revision id = %x \r\n",d);
+    
+    pc.printf("GET device data [x, y, z, t] \r\n");
+    accl.set_power_ctl_reg(accl.MEASUREMENT);
+    
+    d=accl.read_reg(accl.POWER_CTL);
+    pc.printf("power control on measurement mode = %x \r\n",d);
+    
+    float x, y,z;
+    float t;
+    
+    /*The following part is used to perform 2's complemient and then display the data*/
+    for(int i=0; i<50; i++) 
+    {
+        x = accl.convert(accl.scanx())*accl.axis355_sens;
+        y = accl.convert(accl.scany())*accl.axis355_sens;
+        z = accl.convert(accl.scanz())*accl.axis355_sens;
+        t = 25+float(accl.scant()-1852)/(-9.05);
+    
+        pc.printf("%f \t %f \t %f  \t %f \r\n" , x,y,z,t);
+        wait(0.1);
+    }
+    
+/*-------------------------------------------------------------    
+    // The following code will display the Raw data of the Axes 
+     while(1) 
+    {
+        x = accl.scanx();
+        y = accl.scany();
+        z = accl.scanz();
+        t = accl.scant();
+        pc.printf("%u \t %u \t %u \t %u \r\n" , x,y,z,t);
+        wait(1.0);
+    }
+----------------------------------------------------------------*/
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Aug 15 11:52:56 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#485bdeee150e2bc8ed75e27d936060fb63a7a7d1