cancel
Showing results for 
Search instead for 
Did you mean: 

is there an error for current loop of HSO ?

propu
Associate II

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Gael A
ST Employee

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.

View solution in original post

2 REPLIES 2
Gael A
ST Employee

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.

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

propu_0-1740461616643.png