Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/MID_PWR Added define to convert to dW from mSI #100

Merged
merged 1 commit into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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