Skip to content

Commit

Permalink
Merge pull request #100 from WattRex/feature/MID_PWR
Browse files Browse the repository at this point in the history
feature/MID_PWR Added define to convert to dW from mSI
  • Loading branch information
pastorpflores authored Jul 1, 2023
2 parents d8f5fab + 4ec168a commit 233df54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions firmware/Sources/MID/MID_PWR/mid_pwr.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extern uint32_t HAL_PWM_period;

static SOA_e _checkSOA(const int16_t I, const uint16_t V, const MID_REG_limit_s limits){
SOA_e res = SOA_ok;
int16_t power = (int16_t)(((int32_t)I * (int32_t)V) /100000); // 10^-3(mW) *10^-3 (mW) / 10^-5 -> dW
int16_t power = (int16_t)(((int32_t)I * (int32_t)V) /MID_PWR_TO_dW); // 10^-3(mW) *10^-3 (mW) / 10^-5 -> dW
if (power > limits.lsPwrMax)
res = SOA_over_pwr;
else if (power < limits.lsPwrMin)
Expand Down Expand Up @@ -270,7 +270,7 @@ MID_PWR_result_e MID_PwrApplyCtrl(const int16_t ref, const uint16_t V_LS, const
int16_t new_duty;
switch (control_mode) { //first PI, if needed (in Pwr and V refs)
case MID_PWR_MODE_CP:
actual_power = (int16_t)(((int32_t)I_LS * (int32_t)V_LS) /100000); // dW
actual_power = (int16_t)(((int32_t)I_LS * (int32_t)V_LS) /MID_PWR_TO_dW); // dW
res = _calculatePI(ref, actual_power, MID_PWR_MODE_CP, limits, &curr_ref);
break;
case MID_PWR_MODE_CV:
Expand Down
2 changes: 1 addition & 1 deletion firmware/Sources/MID/MID_PWR/mid_pwr.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**********************************************************************************/
/* Definition of local symbolic constants */
/**********************************************************************************/

#define MID_PWR_TO_dW 100000// 10^-3(mW) *10^-3 (mW) / 10^-5 -> dW
/**********************************************************************************/
/* Definition of local function like macros */
/**********************************************************************************/
Expand Down

0 comments on commit 233df54

Please sign in to comment.