CUER / Mbed 2 deprecated BMS_BMUCore_Max

Dependencies:   CUER_CAN CUER_DS1820 LTC2943 LTC6804 mbed PowerControl

Revision:
18:521ffdd724f3
Parent:
17:94dd9a0d3870
Child:
20:a1a1bfc938da
--- a/main.cpp	Sun Jul 02 13:35:18 2017 +0000
+++ b/main.cpp	Sun Jul 02 15:06:51 2017 +0000
@@ -79,7 +79,6 @@
     
     while (true) {
         
-        // Take measurements from the sensors
         take_measurements(measurements);
         /*// Dont want to read the temperature sensors during each iteration of the loop
         if (c == 0) {
@@ -143,6 +142,7 @@
         wait(0.1);
     }
     
+    printf("Devices found %d \r\n", devices_found);
     //Transmitting all of the individual probes:
     for(uint8_t i = 0; i < devices_found; i++)
     {
@@ -241,9 +241,10 @@
     DigitalOut isotherm_12V_pin(ISOTHERM_12V_PIN);
     isotherm_12V_pin = 1;
     probe[0]->convert_temperature(DS1820::all_devices);
-    isotherm_12V_pin = 0;
+    //isotherm_12V_pin = 0;
     min_temperature = probe[0]->temperature('C');
     max_temperature = min_temperature; // Initially set the max and min temperature equal
+    printf("Devices found in temp readings: %d", devices_found);
     for (int i=0; i<devices_found; i++) {
         for(int j = 0; j < 7; j++)
             measurements.temperature_measurements[i].ROMID[j] = probe[i]->ROM[j];
@@ -257,7 +258,7 @@
             min_temperature = measurements.temperature_measurements[i].measurement;
         }
         
-        printf("Device %d temperature is %3.3f degrees Celcius.\r\n",i+1 ,probe[i]->temperature('C'));
+        //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.
@@ -319,6 +320,7 @@
 
 void init()
 {
+    //Comment out measurement stuff with BCU testing
     temperature_init(); // Initialise the temperature sensors
     LTC2943_initialise(); //Initialises the fixed parameters of the LTC2943
     LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2); //Initialises the LTC6804s
@@ -379,9 +381,32 @@
         safe_to_write[i] = true;
     }
     
-    //voltage readings:
+    //voltage and Temp readings:
+    individual_temperature templist[NO_TEMPERATURE_SENSORS];
+    for(int i = 0; i < NO_TEMPERATURE_SENSORS; i++)
+    {
+        templist[i].measurement = -1;
+        templist[i].ID = 0;
+    }
     
+    for(int i = 0; i < CAN_BUFFER_SIZE; i++)
+    {
+        int j = 0; //Just adding this to fill up temperature array in a cleaner way, wont be relevent later.
+        //voltage
+        if(decodeVoltageTelemetry(msgArray[i], &voltage_readings[0]));
+        else if(msgArray[i].id >= 0x800)
+        {
+            templist[j] = decodeTemperatureTelemetry(msgArray[i]);
+            j++;
+        }   
+    }
+    //Print obtained Readings:
+    for(int i = 0; i < NO_CMUS; i++)
+        for(int j = 0; j < 12; j++)
+            printf("Voltage number %d for CMU %d is %d \r\n", j, i, voltage_readings[i].voltages[j]);
     
+    for(int i = 0; i < NO_TEMPERATURE_SENSORS; i++)
+        printf("Temperature of Sensor with ID %d is %f \r\n", templist[i].ID, templist[i].measurement);           
 }
 bool test_read_voltage_CAN(uint16_t readings[], int can_ids[])
 {