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:
- 15:e901aff1f5b3
- Parent:
- 14:e0e88a009f4c
diff -r e0e88a009f4c -r e901aff1f5b3 main.cpp --- a/main.cpp Sun Jul 02 01:45:39 2017 +0000 +++ b/main.cpp Sun Jul 02 11:25:37 2017 +0000 @@ -99,8 +99,8 @@ // CAN bus CAN_data_sent = false;//Currently does nothing, adding this line in more places then using //while(!CAN_data_sent); in order to ensure sending completes - //transmit_data(measurements,status); - test_read_CAN_buffer(); + transmit_data(measurements,status); + //test_read_CAN_buffer(); /* // Conserve power - enter a low powered mode @@ -267,7 +267,7 @@ for(int j = 0; j < 7; j++) measurements.temperature_measurements[i].ROMID[j] = j; - measurements.temperature_measurements[i].measurement = 22.7 + (float) i; + measurements.temperature_measurements[i].measurement = -5 + (float) i; if(measurements.temperature_measurements[i].measurement > max_temperature) { max_temperature = measurements.temperature_measurements[i].measurement; @@ -340,6 +340,7 @@ { 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 for(int i=0; i<CAN_BUFFER_SIZE; i++) { @@ -393,13 +394,22 @@ for(int i = 0; i < CAN_BUFFER_SIZE; i++) { + uint16_t readings[4]; individual_temperature testpoint; if(!(buffer[i].id == BLANK_ID) && buffer[i].id < 10) { testpoint = decodeTemperatureTelemetry(buffer[i]); printf("Temperature is %f and ID[5] is %d \r\n", testpoint.measurement, testpoint.ROMID[5]); }else if(buffer[i].id == 1538) - printf("id 1538 was recieved\r\n"); + printf("id 1538 was recieved\r\n"); + if(buffer[i].id > 0x600 && buffer[i].id < 0x800) + { + for(int i =0; i < 4; i++) + { + readings[i] = (buffer[i].data[2 * i]) + (buffer[i].data[2*i+1] << 8); //Since data is 8 8bit ints not 4 16 bit ones + printf("readings[i] = %d \r\n", readings[i]); + } + } } } bool test_read_voltage_CAN(uint16_t readings[], int can_ids[])