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 CUER

Revision:
13:7b42af989cd1
Parent:
12:fa9b1a459e47
Child:
14:e0e88a009f4c
--- a/main.cpp	Fri Jun 23 17:41:17 2017 +0000
+++ b/main.cpp	Wed Jun 28 16:56:33 2017 +0000
@@ -112,7 +112,7 @@
     Place all of the collected data onto the CAN bus
     */
     // Send cell voltages
-    //voltages sent in sets of 4 + one cmy data set
+    //voltages sent in sets of 4 + one cmu data set
     int repeating_unit_length = NO_READINGS_PER_CMU /4 + 1;
     for(uint16_t i= 0; i < NO_CMUS; i++) {
         //input id is offset, data structure is info, voltage, voltage, ......
@@ -130,6 +130,15 @@
         wait(0.1);
         //printf("Message id: %d \r\n", msg.id);
     }
+    
+    //Transmitting all of the individual probes:
+    for(int i = 0; i < NO_TEMPERATURE_SENSORS; i++)
+    {
+        individual_temperature reading = measurements.temperature_measurements[i];
+        msg = createTemperatureTelemetry(i, reading.ID, reading.measurement);
+        can.write(msg);
+        wait(0.1);
+    }
 
     // Create SOC CAN message
     createPackSOC(measurements.SOC, measurements.percentage_SOC);
@@ -137,7 +146,8 @@
     // Min/max cell voltages
     createCellVoltageMAXMIN(measurements.max_cell_voltage, measurements.min_cell_voltage);
 
-    // Min/Max cell temperature
+    // Min/Max cell temperature, Currently the meaning of temp max/min is a ambiguous 
+    // due to changes to Temperature reading (namely the CMU ID portion of it), @TODO change MAXMIN
     createCellTemperatureMAXMIN(measurements.min_cell_temp,measurements.max_cell_temp);
 
     // Battery voltage and current
@@ -221,7 +231,8 @@
     min_temperature = probe[0]->temperature('C');
     max_temperature = min_temperature; // Initially set the max and min temperature equal
     for (int i=0; i<devices_found; i++) {
-
+        //The ID seems to be set arbitrarily here, might make sense to change
+        //to a constant ID for each sensor to more easily recover the reading.
         measurements.temperature_measurements[i].ID = i;
         measurements.temperature_measurements[i].measurement = probe[i] ->temperature('C');
 
@@ -233,6 +244,7 @@
         
         printf("Device %d temperature is %3.3f degrees Celcius.\r\n",i+1 ,probe[i]->temperature('C'));
     }
+    //There is also a CMU # component of this struct, currently unfilled, perhaps not needed at all.
     measurements.max_cell_temp.temperature = max_temperature;
     measurements.min_cell_temp.temperature = min_temperature;
 }
@@ -279,8 +291,11 @@
        }   
     }
     
+    //Add code to take all temperature measurements and add it to measurements struct.
+    read_temperature_sensors(measurements);
+    
     //Current, SoC
-    measurements.battery_current = (uint32_t) ltc2943.current()*1000; //*1000 to converet to mA
+    measurements.battery_current = (uint32_t) ltc2943.current()*1000; //*1000 to convert to mA
     measurements.percentage_SOC = ltc2943.accumulatedCharge();
     measurements.SOC = (measurements.percentage_SOC /100) * BATTERY_CAPACITY;
 }