在motorWare 例程中,模块void updateGlobalVariables_motor(CTRL_Handle handle, ST_Handle sthandle)在fpu32和定点方式先
定义的几个float 参数:
在定点模式下为:
gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
// get the rotor resistance
gMotorVars.Rr_Ohm = EST_getRr_Ohm(obj->estHandle);
// get the stator resistance
gMotorVars.Rs_Ohm = EST_getRs_Ohm(obj->estHandle);
// get the stator inductance in the direct coordinate direction
gMotorVars.Lsd_H = EST_getLs_d_H(obj->estHandle);
// get the stator inductance in the quadrature coordinate direction
gMotorVars.Lsq_H = EST_getLs_q_H(obj->estHandle);
// get the flux in V/Hz in floating point
gMotorVars.Flux_VpHz = EST_getFlux_VpHz(obj->estHandle);
浮点模式下为:
int32_t tmp;
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
// get the rotor resistance
tmp = EST_getRr_Ohm(obj->estHandle);
gMotorVars.Rr_Ohm = *((float_t *)&tmp);
// get the stator resistance
tmp = EST_getRs_Ohm(obj->estHandle);
gMotorVars.Rs_Ohm = *((float_t *)&tmp);
// get the stator inductance in the direct coordinate direction
tmp = EST_getLs_d_H(obj->estHandle);
gMotorVars.Lsd_H = *((float_t *)&tmp);
// get the stator inductance in the quadrature coordinate direction
tmp = EST_getLs_q_H(obj->estHandle);
gMotorVars.Lsq_H = *((float_t *)&tmp);
// get the flux in V/Hz in floating point
tmp = EST_getFlux_VpHz(obj->estHandle);
gMotorVars.Flux_VpHz = *((float_t *)&tmp);
比如
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
EST_getIdRated(obj->estHandle)、MagnCurr_A都为float_t,为这种转换的原因:
谢谢!
Victor Zheng:
您好
没看懂您的问题。你用的是F206x的浮点的例程?现在那个变量运行不对?
Victor
在motorWare 例程中,模块void updateGlobalVariables_motor(CTRL_Handle handle, ST_Handle sthandle)在fpu32和定点方式先
定义的几个float 参数:
在定点模式下为:
gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
// get the rotor resistance
gMotorVars.Rr_Ohm = EST_getRr_Ohm(obj->estHandle);
// get the stator resistance
gMotorVars.Rs_Ohm = EST_getRs_Ohm(obj->estHandle);
// get the stator inductance in the direct coordinate direction
gMotorVars.Lsd_H = EST_getLs_d_H(obj->estHandle);
// get the stator inductance in the quadrature coordinate direction
gMotorVars.Lsq_H = EST_getLs_q_H(obj->estHandle);
// get the flux in V/Hz in floating point
gMotorVars.Flux_VpHz = EST_getFlux_VpHz(obj->estHandle);
浮点模式下为:
int32_t tmp;
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
// get the rotor resistance
tmp = EST_getRr_Ohm(obj->estHandle);
gMotorVars.Rr_Ohm = *((float_t *)&tmp);
// get the stator resistance
tmp = EST_getRs_Ohm(obj->estHandle);
gMotorVars.Rs_Ohm = *((float_t *)&tmp);
// get the stator inductance in the direct coordinate direction
tmp = EST_getLs_d_H(obj->estHandle);
gMotorVars.Lsd_H = *((float_t *)&tmp);
// get the stator inductance in the quadrature coordinate direction
tmp = EST_getLs_q_H(obj->estHandle);
gMotorVars.Lsq_H = *((float_t *)&tmp);
// get the flux in V/Hz in floating point
tmp = EST_getFlux_VpHz(obj->estHandle);
gMotorVars.Flux_VpHz = *((float_t *)&tmp);
比如
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
EST_getIdRated(obj->estHandle)、MagnCurr_A都为float_t,为这种转换的原因:
谢谢!
min zhou2:
回复 Victor Zheng:
比如例程 Lab10c。Lab10c与Lab10a功能相同,但Lab10c为fpu32模式。例程中的void updateGlobalVariables_motor(CTRL_Handle handle)函数差异:
Lab10c:
tmp = EST_getIdRated(obj->estHandle); gMotorVars.MagnCurr_A = *((float_t *)&tmp);
。。。。。。。。。。。。。。。。。
Lab10a:
gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
2个例程中:gMotorVars.MagnCurr_A 、EST_getIdRated(obj->estHandle)相同。
都定义为float_t . fpu32下,
tmp = EST_getIdRated(obj->estHandle);gMotorVars.MagnCurr_A = *((float_t *)&tmp);
转换的原因?
在motorWare 例程中,模块void updateGlobalVariables_motor(CTRL_Handle handle, ST_Handle sthandle)在fpu32和定点方式先
定义的几个float 参数:
在定点模式下为:
gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
// get the rotor resistance
gMotorVars.Rr_Ohm = EST_getRr_Ohm(obj->estHandle);
// get the stator resistance
gMotorVars.Rs_Ohm = EST_getRs_Ohm(obj->estHandle);
// get the stator inductance in the direct coordinate direction
gMotorVars.Lsd_H = EST_getLs_d_H(obj->estHandle);
// get the stator inductance in the quadrature coordinate direction
gMotorVars.Lsq_H = EST_getLs_q_H(obj->estHandle);
// get the flux in V/Hz in floating point
gMotorVars.Flux_VpHz = EST_getFlux_VpHz(obj->estHandle);
浮点模式下为:
int32_t tmp;
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
// get the rotor resistance
tmp = EST_getRr_Ohm(obj->estHandle);
gMotorVars.Rr_Ohm = *((float_t *)&tmp);
// get the stator resistance
tmp = EST_getRs_Ohm(obj->estHandle);
gMotorVars.Rs_Ohm = *((float_t *)&tmp);
// get the stator inductance in the direct coordinate direction
tmp = EST_getLs_d_H(obj->estHandle);
gMotorVars.Lsd_H = *((float_t *)&tmp);
// get the stator inductance in the quadrature coordinate direction
tmp = EST_getLs_q_H(obj->estHandle);
gMotorVars.Lsq_H = *((float_t *)&tmp);
// get the flux in V/Hz in floating point
tmp = EST_getFlux_VpHz(obj->estHandle);
gMotorVars.Flux_VpHz = *((float_t *)&tmp);
比如
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
EST_getIdRated(obj->estHandle)、MagnCurr_A都为float_t,为这种转换的原因:
谢谢!
Victor Zheng:
回复 min zhou2:
你好
最后得到的 gMotorVars.MagnCurr_A对吗?如果对就没什么问题。
我的理解是EST_getIdRated(obj->estHandle);返回的值是一个定点数。在定点代码中可以直接使用,在浮点代码中需要转换。
为了验证,你可以直接看一下gMotorVars.MagnCurr_A所在的地址中的值在两个代码中有什么不同。
在motorWare 例程中,模块void updateGlobalVariables_motor(CTRL_Handle handle, ST_Handle sthandle)在fpu32和定点方式先
定义的几个float 参数:
在定点模式下为:
gMotorVars.MagnCurr_A = EST_getIdRated(obj->estHandle);
// get the rotor resistance
gMotorVars.Rr_Ohm = EST_getRr_Ohm(obj->estHandle);
// get the stator resistance
gMotorVars.Rs_Ohm = EST_getRs_Ohm(obj->estHandle);
// get the stator inductance in the direct coordinate direction
gMotorVars.Lsd_H = EST_getLs_d_H(obj->estHandle);
// get the stator inductance in the quadrature coordinate direction
gMotorVars.Lsq_H = EST_getLs_q_H(obj->estHandle);
// get the flux in V/Hz in floating point
gMotorVars.Flux_VpHz = EST_getFlux_VpHz(obj->estHandle);
浮点模式下为:
int32_t tmp;
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
// get the rotor resistance
tmp = EST_getRr_Ohm(obj->estHandle);
gMotorVars.Rr_Ohm = *((float_t *)&tmp);
// get the stator resistance
tmp = EST_getRs_Ohm(obj->estHandle);
gMotorVars.Rs_Ohm = *((float_t *)&tmp);
// get the stator inductance in the direct coordinate direction
tmp = EST_getLs_d_H(obj->estHandle);
gMotorVars.Lsd_H = *((float_t *)&tmp);
// get the stator inductance in the quadrature coordinate direction
tmp = EST_getLs_q_H(obj->estHandle);
gMotorVars.Lsq_H = *((float_t *)&tmp);
// get the flux in V/Hz in floating point
tmp = EST_getFlux_VpHz(obj->estHandle);
gMotorVars.Flux_VpHz = *((float_t *)&tmp);
比如
tmp = EST_getIdRated(obj->estHandle);
gMotorVars.MagnCurr_A = *((float_t *)&tmp);
EST_getIdRated(obj->estHandle)、MagnCurr_A都为float_t,为这种转换的原因:
谢谢!
Young Hu:
回复 Victor Zheng:
Since the F2806x has an FPU, if you enable the FPU, it treats the floating point variables differently than our IQMath ROM library is expecting them, hence we have to "trick" the compiler into keeping them in the correct format. This will not be "fixed" on existing devices.
TI中文支持网



