2025-02-23 5:59 PM
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?
Solved! Go to Solution.
2025-02-24 6:52 AM
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).
2025-02-24 6:52 AM
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).
2025-02-24 9:35 PM
Thank you very much, I misunderstood the type of welecT.