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
main.cpp
- Committer:
- lcockerton62
- Date:
- 2016-12-22
- Revision:
- 0:0a5f554d2a16
- Child:
- 1:51477fe4851b
File content as of revision 0:0a5f554d2a16:
/* Should add a sleep in here Should also consider the different errors that need to be sent */ #include "mbed.h" #include "CANParserBMU.h" #include "Data_Types_BMU.h" #include "CAN_Data.h" #include "CAN_IDs.h" using namespace CAN_IDs; // Function definitions void transmit_data(); void read_EEPROM_startup(); void write_EEPROM(); void take_measurements(); void read_temperature_sensors(); void update_SOC(); void read_sensors(); void init(); CAN can(CAN_READ_PIN, CAN_WRITE_PIN); //Create a CAN object to handle CAN comms int main() { int c = 0; init(); read_EEPROM_startup(); // Read from the eeprom at startup to fill in the values while (true) { // Reading read_sensors(); // Dont want to read the temperature sensors during each iteration of the loop if (c == 0) { read_temperature_sensors(); } else if(c >= 4) { c = -1; } c++; // Check the data take_measurements(); // Update the SOC update_SOC(); //Store data in the eeprom write_EEPROM(); // CAN bus transactions transmit_data(); // Conserve power - enter a low powered mode } } void transmit_data() { /* Place all of the collected data onto the CAN bus */ } void read_EEPROM_startup() { // Read from location 0 on startup } void write_EEPROM() { /* First must read from location 0 to get a pointer to a location Then write the data into the eeprom, using a new location every time Must check that the data you are writing isn't outside the boaunds of the storage space */ } void take_measurements() { /*Data to check: *No data from the sensore *Temperature bounds *Cell overvoltage *Current overvoltage Have an array of error flags */ } void read_temperature_sensors() { //this is a separate function since reading the temperature will be less frequent } void update_SOC() { // Update the SOC value } void read_sensors() { // Like the sound of passing the data in as an array so call by reference could use pointers or a while loop to copy data over?? // Read every sensor apart from the temperature sensors // Read BMS_BCUCORE_balancing // Read SOC } void init() { // Is this required?? }