Adds Balancing function (on the top of SPI_I2C_Parser.cpp) and changes main function adding a test case for balancing to show that it is working as intended.
Fork of BMS_BMUCore_cellvoltage_Mrinank by
Diff: main.cpp
- Revision:
- 4:1881b14c977b
- Parent:
- 3:2238838234e1
- Child:
- 5:fc2503217ad4
--- a/main.cpp Mon Aug 29 21:52:41 2016 +0000 +++ b/main.cpp Wed Aug 31 09:18:34 2016 +0000 @@ -11,8 +11,8 @@ There are 3 primary communication protocols that the BMU utilises: CAN, SPI and I2C. -CAN is used to dump battery status information to the rest of the car --SPI is used to commmunicate with the state of charge (SoC) board --I2C is used to communicate with the CMUs which are individually addressed +-I2C is used to commmunicate with the state of charge (SoC) board +-SPI is used to communicate with the CMUs which are individually addressed The mbed itself utilises conventional SPI and I2C which both get converted into differential signals to give isoSPI and dI2C to give greater resilience to EM noise reducing the chance of transmission errors. @@ -114,6 +114,8 @@ #include "CAN_IDs.h" #include <stdlib.h> +using namespace std; + //Define battery pack cooling fan PWM pins PwmOut fan1(p21); @@ -123,20 +125,23 @@ DigitalIn alcc(p20); int main () { - + //i.format(8,3); //All data transfer on LTC6804 occur in byte groups. LTC6820 set up such that POL=1 and PHA=3, this corresponds to mode 3 in mbed library. spi.frequency(spiBitrate); + //i.frequency(spiBitrate); + uint8_t configReg [1][8]; + wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode + LTC6804_rdcfg(1, configReg); + + return 0; + } - uint16_t vCells[numberOfCMUs][12]; + /*uint16_t vCells[numberOfCMUs][12]; - wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode + LTC6804_init(MD_FILTERED, DCP_ENABLED, CELL_CH_ALL, AUX_CH_ALL);//set_adc LTC6804_setConfigReg( - while(true) { LTC6804_acquireVoltageTx();//adcv LTC6804_acquireAllVoltageRegRx(0, numberOfCMUs, vCells); //rdcv, 0 means read all cell voltages + */ - - return 0; - } -