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:
- 5:793afeef45dc
- Parent:
- 4:9050c5d6925e
- Child:
- 6:b567fcb604aa
--- a/main.cpp Tue Jan 10 00:57:19 2017 +0000 +++ b/main.cpp Mon Jan 16 14:39:30 2017 +0000 @@ -1,6 +1,3 @@ -/* -Should also consider the different errors that need to be sent -*/ #include "mbed.h" #include "CANParserBMU.h" #include "Data_Types_BMU.h" @@ -64,7 +61,7 @@ //Store data in the eeprom write_SOC_EEPROM(measurements, current_EEPROM_address); - // CAN bus transactions + // CAN bus transmit_data(measurements,status); // Conserve power - enter a low powered mode @@ -79,7 +76,7 @@ /* Place all of the collected data onto the CAN bus */ - // Send cell voltaages voltages + // Send cell voltages for(int i= 0; i < NO_CMUS; i++) { createVoltageTelemetry(i + 2 , measurements.cell_voltages[i].first_cell_voltages); createVoltageTelemetry(i + 3, measurements.cell_voltages[i].last_cell_voltages); @@ -95,7 +92,7 @@ createCellTemperatureMAXMIN(measurements.min_cell_temp,measurements.max_cell_temp); // Battery voltage and current - // @TODO make add the voltage and current + // @TODO add the voltage createBatteryVI(measurements.battery_voltage,measurements.battery_current); //Extended battery pack status @@ -109,6 +106,7 @@ pointer of the first memory location of measurement data. The EEPROM only has a finite number of read/write cycles which is why we aren't writing to the same location throughout */ + uint16_t start_address; char start_address_array[2]; char SOC_out[8]; // 4 bytes for the 2 floats one is SOC and the other % charge @@ -130,9 +128,11 @@ // Select the next address to write to start_address += 0x0040; if(start_address > MAX_WRITE_ADDRESS) { - start_address = START_WRITE_ADDRESS; // Loop round to the start of the eeprom + start_address = START_WRITE_ADDRESS; // Loop to the start of the eeprom } + /*@TODO need to include a CRC check for the address pointer for the scenario + when power is removed and we are writing to the eeprom*/ // write the new address to location 0x0000 start_address_array[0] = start_address | 0x00FF; start_address_array[1] = start_address >> 8; @@ -214,7 +214,7 @@ { // Here collect all measured data from the sensors /* - TODO SOC and cell voltages + * TODO Cell voltages */ //Current, SoC