Skip to content

Commit

Permalink
#178 Modified the OrionModel and OrionController to fix this
Browse files Browse the repository at this point in the history
Pack open voltage in the model and controller is now pack summed voltage

Calculation for the voltage has been modified from divided by 10 to 100.
  • Loading branch information
ShawnPierpont committed May 4, 2018
1 parent 74c1957 commit 05e2633
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
16 changes: 8 additions & 8 deletions MainBrain/src/Controller/OrionController/OrionController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void OrionController::updateModelMessage_0x421(uint8_t* messageToParse)
{
orionModel->setPackDischargeCurrentLimit_Byte1(messageToParse[0]);
orionModel->setPackDischargeCurrentLimit_Byte2(messageToParse[1]);
orionModel->setPackOpenVoltage_Byte1(messageToParse[2]);
orionModel->setPackOpenVoltage_Byte2(messageToParse[3]);
orionModel->setPackSummedVoltage_Byte1(messageToParse[2]);
orionModel->setPackSummedVoltage_Byte2(messageToParse[3]);
orionModel->setPackCurrent_Byte1(messageToParse[4]);
orionModel->setPackCurrent_Byte2(messageToParse[5]);
orionModel->setAverageOpenCellVoltage_Byte1(messageToParse[6]);
Expand Down Expand Up @@ -196,8 +196,8 @@ uint16_t OrionController::getPackDischargeCurrentLimit(void)
}

/**
* @brief Retrieve total open pack voltage of the pack to use for the 90% pre-charge setting
* @note Range is 0-6553.5 volts
* @brief Retrieve total summed voltage of the pack to use for the 90% pre-charge setting
* @note Range is 0-65535.0 volts
* @retval total voltage of all batteries
*/
float OrionController::getPackVoltage(void)
Expand All @@ -206,11 +206,11 @@ float OrionController::getPackVoltage(void)
uint16_t packOpenVoltage = 0;
//build the 16 bit value
//shift the first byte over by 8
packOpenVoltage = (uint16_t)orionModel->getPackOpenVoltage_Byte1() << 8;
packOpenVoltage = (uint16_t)orionModel->getPackSummedVoltage_Byte1() << 8;
//OR in the second byte
packOpenVoltage |= (uint16_t)orionModel->getPackOpenVoltage_Byte2();
//now divide this value by 10 and return it
return (float)packOpenVoltage / 10.0;
packOpenVoltage |= (uint16_t)orionModel->getPackSummedVoltage_Byte2();
//now divide this value by 100 and return it
return (float)packOpenVoltage / 100.0;
}


Expand Down
28 changes: 14 additions & 14 deletions MainBrain/src/Model/Orion/Orion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ Orion::Orion(void)
data_0x421->packCurrent_Byte2 = 0;
data_0x421->packDischargeCurrentLimit_Byte1 = 0;
data_0x421->packDischargeCurrentLimit_Byte2 = 0;
data_0x421->packOpenVoltage_Byte1 = 0;
data_0x421->packOpenVoltage_Byte2 = 0;
data_0x421->packSummedVoltage_Byte1 = 0;
data_0x421->packSummedVoltage_Byte2 = 0;
}


Expand Down Expand Up @@ -165,24 +165,24 @@ uint8_t Orion::getPackDischargeCurrentLimit_Byte2(void)


/**
* @brief
* @brief get the first byte of the pack summed voltage
* @note
* @retval
* @retval first byte of the pack summed voltage
*/
uint8_t Orion::getPackOpenVoltage_Byte1(void)
uint8_t Orion::getPackSummedVoltage_Byte1(void)
{
return data_0x421->packOpenVoltage_Byte1;
return data_0x421->packSummedVoltage_Byte1;
}


/**
* @brief
* @brief get the second byte of the pack summed voltage
* @note
* @retval
* @retval second byte of the pack summed voltage
*/
uint8_t Orion::getPackOpenVoltage_Byte2(void)
uint8_t Orion::getPackSummedVoltage_Byte2(void)
{
return data_0x421->packOpenVoltage_Byte2;
return data_0x421->packSummedVoltage_Byte2;
}


Expand Down Expand Up @@ -361,9 +361,9 @@ void Orion::setPackDischargeCurrentLimit_Byte2(uint8_t newPackDischargeCurrentLi
* @param newPackOpenVoltage:
* @retval None
*/
void Orion::setPackOpenVoltage_Byte1(uint8_t newPackOpenVoltage_Byte1)
void Orion::setPackSummedVoltage_Byte1(uint8_t newPackOpenVoltage_Byte1)
{
data_0x421->packOpenVoltage_Byte1 = newPackOpenVoltage_Byte1;
data_0x421->packSummedVoltage_Byte1 = newPackOpenVoltage_Byte1;
}


Expand All @@ -373,9 +373,9 @@ void Orion::setPackOpenVoltage_Byte1(uint8_t newPackOpenVoltage_Byte1)
* @param newPackOpenVoltage:
* @retval None
*/
void Orion::setPackOpenVoltage_Byte2(uint8_t newPackOpenVoltage_Byte2)
void Orion::setPackSummedVoltage_Byte2(uint8_t newPackOpenVoltage_Byte2)
{
data_0x421->packOpenVoltage_Byte2 = newPackOpenVoltage_Byte2;
data_0x421->packSummedVoltage_Byte2 = newPackOpenVoltage_Byte2;
}


Expand Down
12 changes: 6 additions & 6 deletions MainBrain/src/Model/Orion/Orion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Orion : public BaseModel
//gets for values from message 0x421
uint8_t getPackDischargeCurrentLimit_Byte1(void);
uint8_t getPackDischargeCurrentLimit_Byte2(void);
uint8_t getPackOpenVoltage_Byte1(void);
uint8_t getPackOpenVoltage_Byte2(void);
uint8_t getPackSummedVoltage_Byte1(void);
uint8_t getPackSummedVoltage_Byte2(void);
uint8_t getPackCurrent_Byte1(void);
uint8_t getPackCurrent_Byte2(void);
uint8_t getAverageOpenCellVoltage_Byte1(void);
Expand All @@ -55,8 +55,8 @@ class Orion : public BaseModel
//gets for values from message 0x421
void setPackDischargeCurrentLimit_Byte1(uint8_t newPackDischargeCurrentLimit_Byte1);
void setPackDischargeCurrentLimit_Byte2(uint8_t newPackDischargeCurrentLimit_Byte2);
void setPackOpenVoltage_Byte1(uint8_t newPackOpenVoltage_Byte1);
void setPackOpenVoltage_Byte2(uint8_t newPackOpenVoltage_Byte2);
void setPackSummedVoltage_Byte1(uint8_t newPackOpenVoltage_Byte1);
void setPackSummedVoltage_Byte2(uint8_t newPackOpenVoltage_Byte2);
void setPackCurrent_Byte1(uint8_t newPackCurrent_Byte1);
void setPackCurrent_Byte2(uint8_t newPackCurrent_Byte2);
void setAverageOpenCellVoltage_Byte1(uint8_t newAverageOpenCellVoltage_Byte1);
Expand Down Expand Up @@ -84,8 +84,8 @@ class Orion : public BaseModel
{
uint8_t packDischargeCurrentLimit_Byte1; //This value takes 2 bytes to represent and requires no modification, it is the discharge current limit represented in amps
uint8_t packDischargeCurrentLimit_Byte2;
uint8_t packOpenVoltage_Byte1; //This value takes 2 bytes to represent and requires dividing the value by 10 (ten) to get the open voltage of the entire pack in volts
uint8_t packOpenVoltage_Byte2;
uint8_t packSummedVoltage_Byte1; //This value takes 2 bytes to represent and requires dividing the value by 100 (one-hundred) to get the open voltage of the entire pack in volts
uint8_t packSummedVoltage_Byte2;
uint8_t packCurrent_Byte1; //This value takes 2 bytes to represent and requires dividing the value by 10 (ten) to get the current output at the time of the message in amps
uint8_t packCurrent_Byte2;
uint8_t averageOpenCellVoltage_Byte1; //This value takes 2 bytes to represent and requires dividing the value by 10,000 (ten-thousand) to get the average open cell voltage of the cells in volts
Expand Down

0 comments on commit 05e2633

Please sign in to comment.