フィルターのクリア

Scaling of generated duty cycle from simulink to NXP MCU expresso environment

2 ビュー (過去 30 日間)
Nandhini
Nandhini 2024 年 1 月 30 日
コメント済み: Nandhini 2024 年 2 月 23 日
I have developed the FOC model for PMSM, the generated code has been integrated with driver code in NXP MCU expresso environment,while integrating the generated duty cycle values with duty 0 to 100% for example my duty cycle value ranges between -0.8 to 0.8 i mapped to duty 0 to 100% using the equation
duty=map(scale_va,0,1642,0,4000);
scale_va=(rty.Va*1000+820);
My issue is duty varies between only 0 and 100 iam not getting the in between values like 20% or 30% or 45%,
help me in this regard to scale the duty cycle values to duty 0 to 100%.

採用された回答

Avadhoot
Avadhoot 2024 年 2 月 21 日
Hi Nandhini,
I understand that you are getting only 0 and 100 as the duty values. This might be stemming from the mapping that you have used. You want to map from the range [-0.8,0.8] to the range [0,100]. You have also provided the scale and shift function to transform this from one range to another. You can try making the below modifications to your code so that it maps correctly to the [0,100] scale.
normalized_va = (rty.Va + 0.8) / 1.6; % Normalize from -0.8 to 0.8 to 0 to 1
duty_percentage = normalized_va * 100; % Scale to 0 to 100%
I have made the following changes to your code:
  1. I have normalized the voltage values from [-0.8,0.8] to [0,1].
  2. Used the normalized voltage values to calculate the duty percentage by multiplying it by 100.
If you need to apply the shift in the scale, then you can modify the function accordingly. Even after implementing these changes, if you are getting the same result then please ensure that the precisions of the values and the calculations are correct. Ensure that the values are not getting casted to int during the calculations.
I hope this helps.
  1 件のコメント
Nandhini
Nandhini 2024 年 2 月 23 日
Hi Avadhoot,
Thank you for your reply.Actual Iam clear with formula that you mentioned, but i have different issue now.Iam with default values in simulation and check the output duty values and it has been variation in values,when i generate the code and integrate the code in NXP MCU expresso environment the output values are not changing only the variation is in between two values,my question is i want integrate the timer or clock frequency in the generated code or please say how frequency can be integrated with code in software environment.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by