Skip to content

Commit

Permalink
greater value range in park_transform - might be needed for field wea…
Browse files Browse the repository at this point in the history
…kening
  • Loading branch information
dzid26 committed May 24, 2024
1 parent 7d198cc commit 24020a4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions firmware/src/BSP/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ static void inverse_park_transform(uint16_t elecAngle, int16_t Q, int16_t D, int
//calculate sine and cosine with ripple compensation
int16_t sin = sine_ripple(elecAngle, anticogging_factor);
int16_t cos = cosine_ripple(elecAngle, anticogging_factor);


*A = (int16_t)((((int32_t)cos * D) - ((int32_t)sin * Q)) / (int32_t)SINE_MAX); //convert value with vref max corresponding to 3300mV
*B = (int16_t)((((int32_t)sin * D) + ((int32_t)cos * Q)) / (int32_t)SINE_MAX); //convert value with vref max corresponding to 3300mV
int32_t a = (int32_t)(((int64_t)((int32_t)cos * D) - (int64_t)((int32_t)sin * Q)) / (int32_t)SINE_MAX);
int32_t b = (int32_t)(((int64_t)((int32_t)sin * D) + (int64_t)((int32_t)cos * Q)) / (int32_t)SINE_MAX);

*A = (int16_t)(int32_t)clip(a, INT32_MIN, INT32_MAX);
*B = (int16_t)(int32_t)clip(b, INT32_MIN, INT32_MAX);
}

/**
Expand Down

0 comments on commit 24020a4

Please sign in to comment.