ソースを参照

sincos 函数名称修改

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 年 前
コミット
fc3898105e

+ 4 - 4
Applications/foc/core/PMSM_FOC_Core.c

@@ -29,7 +29,7 @@ static bool g_focinit = false;
 static __INLINE void RevPark(DQ_t *dq, float angle, AB_t *alpha_beta) {
 	float c,s;
 #if 0
-	SinCos_Lut(angle, &s, &c);
+	arm_sin_cos(angle, &s, &c);
 #else
 	s = gFoc_Ctrl.out.sin;
 	c = gFoc_Ctrl.out.cos;
@@ -53,7 +53,7 @@ static __INLINE void Clark(float A, float B, float C, AB_t *alpha_beta){
 static __INLINE void Park(AB_t *alpha_beta, float angle, DQ_t *dq) {
 	float c,s;
 #if 0
-	SinCos_Lut(angle, &s, &c);
+	arm_sin_cos(angle, &s, &c);
 #else
 	s = gFoc_Ctrl.out.sin;
 	c = gFoc_Ctrl.out.cos;
@@ -435,7 +435,7 @@ static __INLINE bool PMSM_FOC_Update_Input(void) {
 
 	gFoc_Ctrl.in.s_vDC = get_vbus_float();
 	
-	SinCos_Lut(gFoc_Ctrl.in.s_motAngle, &gFoc_Ctrl.out.sin, &gFoc_Ctrl.out.cos);
+	arm_sin_cos(gFoc_Ctrl.in.s_motAngle, &gFoc_Ctrl.out.sin, &gFoc_Ctrl.out.cos);
 	Park(&iAB, gFoc_Ctrl.in.s_motAngle, &gFoc_Ctrl.out.s_RealIdq);
 
 	float lowpass = gFoc_Ctrl.in.s_motVelRadusPers * FOC_CTRL_US;
@@ -469,7 +469,7 @@ static __INLINE bool PMSM_FOC_Update_Input(void) {
 	if (gFoc_Ctrl.in.s_motVelocityFiltered >= CONFIG_Volvec_Delay_Comp_Start_Vel) {
 		float next_angle = gFoc_Ctrl.in.s_motAngle + gFoc_Ctrl.in.s_motVelRadusPers / PI * 180.0f * (FOC_CTRL_US * 0.8f);
 		rand_angle(next_angle);
-		SinCos_Lut(next_angle, &gFoc_Ctrl.out.sin, &gFoc_Ctrl.out.cos);
+		arm_sin_cos(next_angle, &gFoc_Ctrl.out.sin, &gFoc_Ctrl.out.cos);
 	}
 #endif
 	return true;

+ 3 - 3
Applications/foc/core/foc.c

@@ -34,7 +34,7 @@ void foc_abc_2_dq(float a, float b, float c, float *d, float *q) {
 	float alpha = a;
 	float beta  = ONE_BY_SQRT3 * (b - c);
 	float cos,sin;
-	SinCos_Lut(0, &sin, &cos);
+	arm_sin_cos(0, &sin, &cos);
 	*d = alpha * cos + beta * sin;
 	*q = -alpha * sin + beta * cos;
 }
@@ -61,7 +61,7 @@ void foc_update(foc_t *foc) {
 	
 	LowPass_Filter(foc->mot_velocity_filterd, foc->in.mot_velocity, 0.01f);
 	foc->mot_vel_radusPers = foc->mot_velocity_filterd / 30.0f * PI * mc_conf()->m.poles;
-	SinCos_Lut(foc->in.mot_angle, &foc->sin, &foc->cos);
+	arm_sin_cos(foc->in.mot_angle, &foc->sin, &foc->cos);
 	park(foc, &foc->in.curr_ab, &foc->out.curr_dq);
 	if (!foc->in.b_openloop) {
 		float d_step = (foc->in.target_curr_dq.d - foc->ramp_curr_dq.d) / foc->d_ramp_time;
@@ -102,7 +102,7 @@ void foc_update(foc_t *foc) {
 	if (foc->mot_velocity_filterd >= CONFIG_Volvec_Delay_Comp_Start_Vel) {
 		float vol_dq_angle = foc->in.mot_angle + foc->mot_velocity_filterd / PI * 180.0f * (foc->ts * 0.8f);
 		rand_angle(vol_dq_angle);
-		SinCos_Lut(vol_dq_angle, &foc->sin, &foc->cos);
+		arm_sin_cos(vol_dq_angle, &foc->sin, &foc->cos);
 	}
 #endif
 

+ 3 - 3
Applications/foc/motor/mot_params_ind.c

@@ -148,7 +148,7 @@ void mot_params_ind_inductance(float v, float freq, u16 l_type) {
 	hj_w = 360.0f / hj_n;
 	sys_debug("hj %f, %f, %f, %f, %f, %f, %f\n", hj_v, hj_freq, hj_n, hj_samples, K_terms, Vdead, hj_w);
 	float fft_angle = 360.0f / hj_samples * K_terms;
-	SinCos_Lut(fft_angle, &hj_image, &hj_real);
+	arm_sin_cos(fft_angle, &hj_image, &hj_real);
 	hj_real = hj_real * 2.0f;
 	n_ind_ld = l_type;
 	n_samples = 0;
@@ -204,7 +204,7 @@ void mot_params_high_freq_inject(void) {
 	float hj_angle = hj_w * (float)n_samples;
 	rand_angle(hj_angle);
 	float s, c;
-	SinCos_Lut(hj_angle, &s, &c);
+	arm_sin_cos(hj_angle, &s, &c);
 	float vd = 0, vq = 0;
 	if (n_ind_ld == L_TYPE_D) {
 		vd = hj_v * c;
@@ -257,7 +257,7 @@ void mot_params_calc_inductance(void) {
 	
 	float z_angle = fast_atan_2(i_image, i_real) - fast_atan_2(v_image, v_real);
 	float s,c;
-	SinCos_Lut(pi_2_degree(z_angle), &s, &c);
+	arm_sin_cos(pi_2_degree(z_angle), &s, &c);
 
 	float z_mag = v_mag / (i_mag + 0.0000001f);
 	float z_real = z_mag * c;

+ 1 - 1
Applications/foc/motor/motor_param.c

@@ -216,7 +216,7 @@ void motor_mpta_fw_lookup(float rpm, float torque, dq_t *dq_out) {
 	if (torque != 0) {
 		float advanced_angle = CONFIG_MOT_ADV_ANGLE;
 		float s, c;
-		SinCos_Lut(advanced_angle + 90.0f, &s, &c);
+		arm_sin_cos(advanced_angle + 90.0f, &s, &c);
 		d = ABS(torque) * c;
 		d = fclamp(d, -mc_conf()->m.max_fw_id, mc_conf()->m.max_fw_id);
 		q = sqrtf(SQ(torque) - SQ(d));

+ 1 - 1
Applications/math/fast_math.h

@@ -25,7 +25,7 @@
 #define UTILS_NAN_ZERO(x)	(x = UTILS_IS_NAN(x) ? 0.0F : x)
 
 void fast_sincos(float angle, float *sin, float *cos);
-void SinCos_Lut(float angle, float *s, float *c);
+void arm_sin_cos(float angle, float *s, float *c);
 
 #define MATH_sat(in, minOut, maxOut) (min((maxOut), MAX((in), (minOut))))
 

+ 2 - 2
Applications/math/sin_table.c

@@ -51,7 +51,7 @@ static s16 sinTable[] =
   -5334, -5063, -4790, -4516, -4240, -3964, -3686, -3406, -3126, -2845, -2563,
   -2280, -1997, -1713, -1428, -1143, -857, -572, -286, 0 };
 
-void SinCos_Lut(float angle, float *s, float *c) {	
+void sin_cos_lut(float angle, float *s, float *c) {
 	s16 angle_degree = (s16)angle; //去掉小数部分
 	if ((angle - angle_degree) > 0.5f) {
 		angle_degree += 1;
@@ -64,7 +64,7 @@ void SinCos_Lut(float angle, float *s, float *c) {
 }
 #else
 /*120Mhz mcu, use 1.14us */
-void SinCos_Lut(float angle, float *s, float *c) {
+void arm_sin_cos(float angle, float *s, float *c) {
 	arm_sin_cos_f32(angle, s, c);
 }
 #endif