Skip to main content
Associate II
February 24, 2025
Solved

is there an error for current loop of HSO ?

  • February 24, 2025
  • 1 reply
  • 561 views

MCSDK:mdsdk6.3.1

 

In the decoupling term calculation of the current loop, is there an error? welecT is of the fixp30_t type, while the compensation term uses FIXP_mpy(upQ, welecT). The result obtained in this case should still be Q30. Should FIXP_mpy be changed to FIXP30_mpy?

 

propu_0-1740362238583.png

 

 

Best answer by Gael A

Hello propu,

I think you are getting confused on how fixed-point operations work. First of all, welecT is of fixp24_t type, not fixp30_t. This is also the case for upQ, so multiplying the two is done by using FIXP_mpy which is in fact FIXP24_mpy. That is because the recipient variable is also a fixp24_t variable.

I suppose the reason you think welecT is of fixp30_t is because of the "welecT = FIXP30_mpy(...) line above. This doesn't mean that welecT is of fixp30_t type.

When multiplying two fixed-point numbers, the resulting number's fixed-point type is the sum of the two multiplied numbers type : fixp24_t * fixp30_t -> fixp54_t. Which is why we then right-shift by 30 bits, using FIXP30_mpy, to come up with a fixp24_t number. This is exactly what happens when we multiply felec_pu (fixp30_t) and wfsT (fixp24_t).

1 reply

Gael A
Gael ABest answer
ST Employee
February 24, 2025

Hello propu,

I think you are getting confused on how fixed-point operations work. First of all, welecT is of fixp24_t type, not fixp30_t. This is also the case for upQ, so multiplying the two is done by using FIXP_mpy which is in fact FIXP24_mpy. That is because the recipient variable is also a fixp24_t variable.

I suppose the reason you think welecT is of fixp30_t is because of the "welecT = FIXP30_mpy(...) line above. This doesn't mean that welecT is of fixp30_t type.

When multiplying two fixed-point numbers, the resulting number's fixed-point type is the sum of the two multiplied numbers type : fixp24_t * fixp30_t -> fixp54_t. Which is why we then right-shift by 30 bits, using FIXP30_mpy, to come up with a fixp24_t number. This is exactly what happens when we multiply felec_pu (fixp30_t) and wfsT (fixp24_t).

If you agree with my answer, please consider accepting it by clicking on 'Accept as solution'.Hope this will help,Gaël A.
propuAuthor
Associate II
February 25, 2025

Thank you very much, I misunderstood the type of welecT.

propu_0-1740461616643.png