필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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