BMS_T2
Dependencies: INA226
Revision 3:61174d4de67d, committed 2020-10-13
- Comitter:
- takuma1
- Date:
- Tue Oct 13 07:20:11 2020 +0000
- Parent:
- 2:3bbbe439ec11
- Commit message:
- BMS_T2;
Changed in this revision
diff -r 3bbbe439ec11 -r 61174d4de67d main.cpp --- a/main.cpp Tue Oct 13 06:26:34 2020 +0000 +++ b/main.cpp Tue Oct 13 07:20:11 2020 +0000 @@ -5,8 +5,7 @@ #include "LTC6811.h" #include "CAN.h" #include "INA226.hpp" -#include "max6675.h" -#include "max6675_2.h" + #define UI_BUFFER_SIZE 64 @@ -28,10 +27,7 @@ DigitalOut BAT_MIN_safty(p21); DigitalOut BAT_MAX_safty(p22); INA226 VCmonitor(i2c); -SPI spi(p11,p12,p13); -max6675 max(spi,p18); -SPI spi_2(p11,p12,p13); -max6675_2 max_2(spi_2,p21); + void run_command(uint32_t cmd); @@ -263,8 +259,7 @@ } - max.select(); - max_2.deselect_2(); +/* //平均化処理 @@ -313,7 +308,7 @@ //BAT_Current = C; - + */ }
diff -r 3bbbe439ec11 -r 61174d4de67d max6675.cpp --- a/max6675.cpp Tue Oct 13 06:26:34 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ - -#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; -}
diff -r 3bbbe439ec11 -r 61174d4de67d max6675.h --- a/max6675.h Tue Oct 13 06:26:34 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#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
diff -r 3bbbe439ec11 -r 61174d4de67d max6675_2.cpp --- a/max6675_2.cpp Tue Oct 13 06:26:34 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ - -#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; -}
diff -r 3bbbe439ec11 -r 61174d4de67d max6675_2.h --- a/max6675_2.h Tue Oct 13 06:26:34 2020 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#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