ss

Dependencies:   mbed MPU6050

Files at this revision

API Documentation at this revision

Comitter:
SantiagoE
Date:
Mon Feb 22 19:24:30 2021 +0000
Commit message:
ss

Changed in this revision

MPU6050.lib 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
max6675.cpp Show annotated file Show diff for this revision Revisions of this file
max6675.h Show annotated file Show diff for this revision Revisions of this file
max6675_2.cpp Show annotated file Show diff for this revision Revisions of this file
max6675_2.h 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/MPU6050.lib	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/wisnup/code/MPU6050/#0e23b7f6dccd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,16 @@
+#include "mbed.h"
+#include "max6675.h"
+
+SPI spi (D11, D12, D13); //MOSI, MISO, SCK
+max6675 maxtemp(spi,D10); // CS
+Serial pc(USBTX, USBRX); //Serial USB
+int main(){
+while (1){
+        
+        float temp= maxtemp.read_temp();// lee la variable de temp
+        pc.printf(" \n\rtemperatura: \%5.2F C",temp);// imprime el valor de temp
+        wait(0.7);
+        
+        }
+     
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675.cpp	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,42 @@
+
+#include <mbed.h>
+#include "max6675.h"
+
+max6675::max6675(SPI& _spi, PinName _ncs) : spi(_spi), ncs(_ncs) {
+
+}
+
+float max6675::read_temp() {
+    short value = 0;
+    float temp = 0;
+    
+    uint8_t highByte=0;
+    uint8_t lowByte=0;
+    
+    select();
+    wait(.25); //This delay is needed else it does'nt seem to update the temp
+
+    highByte = spi.write(0);
+    lowByte = spi.write(0);
+    deselect();
+
+
+    if (lowByte & (1<<2)) {
+        error("No Probe");
+    } else {
+        value = (highByte << 5 | lowByte>>3);
+    }
+
+    temp = (value*0.25); // Multiply the value by 0.25 to get temp in ˚C or
+                         //  * (9.0/5.0)) + 32.0;   // Convert value to ˚F (ensure proper floats!)
+
+return temp;
+}
+
+void max6675::select() {
+    ncs = 0;
+}
+
+void max6675::deselect() {
+    ncs = 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675.h	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,25 @@
+#ifndef MAX6675_h
+#define MAX6675_h
+
+#include "mbed.h"
+
+class max6675
+{
+    SPI& spi;
+    DigitalOut ncs;
+  public:
+  
+    max6675(SPI& _spi, PinName _ncs);
+    void select();
+    void deselect();
+    
+    float read_temp();
+  private:
+    PinName _CS_pin;
+    PinName _SO_pin;
+    PinName _SCK_pin;
+    int _units;
+    float _error;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675_2.cpp	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,42 @@
+
+#include <mbed.h>
+#include "max6675_2.h"
+
+max6675_2::max6675_2(SPI& _spi_2, PinName _ncs_2) : spi_2(_spi_2), ncs_2(_ncs_2) {
+
+}
+
+float max6675_2::read_temp_2() {
+    short value_2 = 0;
+    float temp_2 = 0;
+    
+    uint8_t highByte_2=0;
+    uint8_t lowByte_2=0;
+    
+    select_2();
+    wait(.25); //This delay is needed else it does'nt seem to update the temp
+
+    highByte_2 = spi_2.write(0);
+    lowByte_2 = spi_2.write(0);
+    deselect_2();
+
+
+    if (lowByte_2 & (1<<2)) {
+        error("No Probe");
+    } else {
+        value_2 = (highByte_2 << 5 | lowByte_2>>3);
+    }
+
+    temp_2 = (value_2*0.25); // Multiply the value by 0.25 to get temp in ˚C or
+                         //  * (9.0/5.0)) + 32.0;   // Convert value to ˚F (ensure proper floats!)
+
+return temp_2;
+}
+
+void max6675_2::select_2() {
+    ncs_2 = 0;
+}
+
+void max6675_2::deselect_2() {
+    ncs_2 = 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675_2.h	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,25 @@
+#ifndef MAX6675_2_h
+#define MAX6675_2_h
+
+#include "mbed.h"
+
+class max6675_2
+{
+    SPI& spi_2;
+    DigitalOut ncs_2;
+  public:
+  
+    max6675_2(SPI& _spi_2, PinName _ncs_2);
+    void select_2();
+    void deselect_2();
+    
+    float read_temp_2();
+  private:
+    PinName _CS_pin_2;
+    PinName _SO_pin_2;
+    PinName _SCK_pin_2;
+    int _units_2;
+    float _error_2;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 22 19:24:30 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file