![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Has base BMU code but sends dummy temperature and voltage readings to test CAN
Dependencies: CUER_CAN DS1820 LTC2943 LTC6804 mbed
Fork of BMS_BMUCore_Max by
Diff: main.cpp
- Revision:
- 4:9050c5d6925e
- Parent:
- 2:94716229ecc3
- Child:
- 5:793afeef45dc
--- a/main.cpp Fri Dec 30 16:19:31 2016 +0000 +++ b/main.cpp Tue Jan 10 00:57:19 2017 +0000 @@ -8,6 +8,7 @@ #include "CAN_IDs.h" #include "EEPROM_I2C.h" #include "Temperature.h" +#include "LTC2943_Read.h" using namespace CAN_IDs; @@ -22,6 +23,7 @@ void take_measurements(BMU_data &measurements); CAN can(CAN_READ_PIN, CAN_WRITE_PIN); //Create a CAN object to handle CAN comms +uint16_t eeprom_start_address; //the initial address where we store/read SoC values Timeout loop_delay; bool delay_finished = false; @@ -38,8 +40,9 @@ uint32_t status; int c = 0; init(); - current_EEPROM_address = read_EEPROM_startup(measurements); - // Read from the eeprom at startup to fill in the values + current_EEPROM_address = read_EEPROM_startup(measurements); // Read from the eeprom at startup to fill in the values of SoC + ltc2943.accumulatedCharge(measurements.percentage_SOC); // Initialise the LTC2943 with the current state of charge + while (true) { // Take measurements from the sensors @@ -213,10 +216,17 @@ /* TODO SOC and cell voltages */ + + //Current, SoC + measurements.battery_current = (uint32_t) ltc2943.current()*1000; //*1000 to converet to mA + measurements.percentage_SOC = ltc2943.accumulatedCharge(); + measurements.SOC = (measurements.percentage_SOC /100) * BATTERY_CAPACITY; + } void init() { temperature_init(); // Initialise the temperature sensors + LTC2943_initialise(); //Initialises the fixed parameters of the LTC2943 }