KIT Solar Car Project / Mbed 2 deprecated mbed_MAX6675_4_LM61_SD

Dependencies:   mbed SDFileSystem

Files at this revision

API Documentation at this revision

Comitter:
BoostNori
Date:
Mon Mar 02 14:45:01 2020 +0000
Commit message:
6675

Changed in this revision

SDFileSystem.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
max6675_3.cpp Show annotated file Show diff for this revision Revisions of this file
max6675_3.h Show annotated file Show diff for this revision Revisions of this file
max6675_4.cpp Show annotated file Show diff for this revision Revisions of this file
max6675_4.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/SDFileSystem.lib	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "max6675.h"
+#include "max6675_2.h"
+#include "max6675_3.h"
+#include "max6675_4.h"
+#include "SDFileSystem.h"
+#include <time.h>
+#include <stdio.h>
+
+DigitalOut led_1(LED1);
+DigitalOut led_2(LED2);
+DigitalOut led_3(LED3);
+DigitalOut led_4(LED4);
+SPI spi(p11,p12,p13);
+max6675 max(spi,p18);
+SPI spi_2(p11,p12,p13);
+max6675_2 max_2(spi_2,p21);
+SPI spi_3(p11,p12,p13);
+max6675_3 max_3(spi_3,p22);
+SPI spi_4(p11,p12,p13);
+max6675_4 max_4(spi_4,p23);
+AnalogIn LM61(p15);
+SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+Serial pc(USBTX,USBRX);
+DigitalIn swi_1(p23);   //p5~p30のどれでも良い
+DigitalIn swi_2(p22);   //p5~p30のどれでも良い
+
+void led()
+{
+   led_1 = 1;
+   led_2 = 1;
+   led_3 = 1;
+   led_4 = 1;
+   wait(.2);
+   
+   led_1 = 0;
+   led_2 = 0;
+   led_3 = 0;
+   led_4 = 0;
+   wait(.2);
+   
+   led_1 = 1;
+   led_2 = 1;
+   led_3 = 1;
+   led_4 = 1;
+   wait(.2);
+   
+   led_1 = 0;
+   led_2 = 0;
+   led_3 = 0;
+   led_4 = 0;
+   wait(.2);
+}
+
+
+int main() {
+    while(1) {
+        myled = 1;
+        wait(0.2);
+        myled = 0;
+        wait(0.2);
+        float i = .54;
+        printf("%f",i)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675.cpp	Mon Mar 02 14:45:01 2020 +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 Mar 02 14:45:01 2020 +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 Mar 02 14:45:01 2020 +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 Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,26 @@
+
+#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/max6675_3.cpp	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,42 @@
+
+#include <mbed.h>
+#include "max6675_3.h"
+
+max6675_3::max6675_3(SPI& _spi_3, PinName _ncs_3) : spi_3(_spi_3), ncs_3(_ncs_3) {
+
+}
+
+float max6675_3::read_temp_3() {
+    short value_3 = 0;
+    float temp_3 = 0;
+    
+    uint8_t highByte_3=0;
+    uint8_t lowByte_3=0;
+    
+    select_3();
+    wait(.25); //This delay is needed else it does'nt seem to update the temp
+
+    highByte_3 = spi_3.write(0);
+    lowByte_3 = spi_3.write(0);
+    deselect_3();
+
+
+    if (lowByte_3 & (1<<2)) {
+        error("No Probe");
+    } else {
+        value_3 = (highByte_3 << 5 | lowByte_3>>3);
+    }
+
+    temp_3 = (value_3*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_3;
+}
+
+void max6675_3::select_3() {
+    ncs_3 = 0;
+}
+
+void max6675_3::deselect_3() {
+    ncs_3 = 1;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675_3.h	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,26 @@
+
+#ifndef MAX6675_3_h
+#define MAX6675_3_h
+
+#include "mbed.h"
+
+class max6675_3
+{
+    SPI& spi_3;
+    DigitalOut ncs_3;
+  public:
+  
+    max6675_3(SPI& _spi_3, PinName _ncs_3);
+    void select_3();
+    void deselect_3();
+    
+    float read_temp_3();
+  private:
+    PinName _CS_pin_3;
+    PinName _SO_pin_3;
+    PinName _SCK_pin_3;
+    int _units_3;
+    float _error_3;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675_4.cpp	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,42 @@
+
+#include <mbed.h>
+#include "max6675_4.h"
+
+max6675_4::max6675_4(SPI& _spi_4, PinName _ncs_4) : spi_4(_spi_4), ncs_4(_ncs_4) {
+
+}
+
+float max6675_4::read_temp_4() {
+    short value_4 = 0;
+    float temp_4 = 0;
+    
+    uint8_t highByte_4=0;
+    uint8_t lowByte_4=0;
+    
+    select_4();
+    wait(.25); //This delay is needed else it does'nt seem to update the temp
+
+    highByte_4 = spi_4.write(0);
+    lowByte_4 = spi_4.write(0);
+    deselect_4();
+
+
+    if (lowByte_4 & (1<<2)) {
+        error("No Probe");
+    } else {
+        value_4 = (highByte_4 << 5 | lowByte_4>>3);
+    }
+
+    temp_4 = (value_4*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_4;
+}
+
+void max6675_4::select_4() {
+    ncs_4 = 0;
+}
+
+void max6675_4::deselect_4() {
+    ncs_4 = 1;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max6675_4.h	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,25 @@
+#ifndef MAX6675_4_h
+#define MAX6675_4_h
+
+#include "mbed.h"
+
+class max6675_4
+{
+    SPI& spi_4;
+    DigitalOut ncs_4;
+  public:
+  
+    max6675_4(SPI& _spi_4, PinName _ncs_4);
+    void select_4();
+    void deselect_4();
+    
+    float read_temp_4();
+  private:
+    PinName _CS_pin_4;
+    PinName _SO_pin_4;
+    PinName _SCK_pin_4;
+    int _units_4;
+    float _error_4;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 02 14:45:01 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file