1、增加获取电机运行相关数据的外部接口函数(get_current、get_volatage、get_Temperature、get_speed、get_location)
This commit is contained in:
@@ -170,6 +170,22 @@
|
|||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression>\\BombSensor\../source/Module/dc_motor/dc_motor.c\291</Expression>
|
<Expression>\\BombSensor\../source/Module/dc_motor/dc_motor.c\291</Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>1</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>343</LineNumber>
|
||||||
|
<EnabledFlag>1</EnabledFlag>
|
||||||
|
<Address>0</Address>
|
||||||
|
<ByteObject>0</ByteObject>
|
||||||
|
<HtxType>0</HtxType>
|
||||||
|
<ManyObjects>0</ManyObjects>
|
||||||
|
<SizeOfObject>0</SizeOfObject>
|
||||||
|
<BreakByAccess>0</BreakByAccess>
|
||||||
|
<BreakIfRCount>0</BreakIfRCount>
|
||||||
|
<Filename>..\source\Module\dc_motor\dc_motor.c</Filename>
|
||||||
|
<ExecCommand></ExecCommand>
|
||||||
|
<Expression></Expression>
|
||||||
|
</Bp>
|
||||||
</Breakpoint>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
|
|||||||
@@ -229,6 +229,60 @@ void speed_computer(int32_t encode_now, uint8_t ms)
|
|||||||
sp_count ++;
|
sp_count ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************
|
||||||
|
* 函数名称: get_current
|
||||||
|
* 功能描述: 获取工作电流函数
|
||||||
|
* 参 数: 无
|
||||||
|
* 返 回 值: 电流值
|
||||||
|
*****************************************************************************************/
|
||||||
|
float get_current(void)
|
||||||
|
{
|
||||||
|
return g_motor_data.current; /* 返回工作电流值 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************
|
||||||
|
* 函数名称: get_volatage
|
||||||
|
* 功能描述: 获取工作电压函数
|
||||||
|
* 参 数: 无
|
||||||
|
* 返 回 值: 电压值
|
||||||
|
*****************************************************************************************/
|
||||||
|
float get_volatage(void)
|
||||||
|
{
|
||||||
|
return g_motor_data.volatage; /* 返回工作电压值 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************
|
||||||
|
* 函数名称: get_Temperature
|
||||||
|
* 功能描述: 获取工作温度函数
|
||||||
|
* 参 数: 无
|
||||||
|
* 返 回 值: 温度值
|
||||||
|
*****************************************************************************************/
|
||||||
|
float get_Temperature(void)
|
||||||
|
{
|
||||||
|
return g_motor_data.current; /* 返回工作温度值 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************
|
||||||
|
* 函数名称: get_speed
|
||||||
|
* 功能描述: 获取电机实际转速值函数
|
||||||
|
* 参 数: 无
|
||||||
|
* 返 回 值: 电压值
|
||||||
|
*****************************************************************************************/
|
||||||
|
float get_speed(void)
|
||||||
|
{
|
||||||
|
return g_motor_data.speed; /* 返回电机实际转速值 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************************
|
||||||
|
* 函数名称: get_location
|
||||||
|
* 功能描述: 获取电机实际位置函数
|
||||||
|
* 参 数: 无
|
||||||
|
* 返 回 值: 电压值
|
||||||
|
*****************************************************************************************/
|
||||||
|
float get_location(void)
|
||||||
|
{
|
||||||
|
return g_motor_data.speed; /* 返回电机实际位置 */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************************
|
/*****************************************************************************************
|
||||||
@@ -247,9 +301,7 @@ void Adc1mSRoutine(void)
|
|||||||
if(AdcInitSta == true)
|
if(AdcInitSta == true)
|
||||||
{
|
{
|
||||||
ADC_Start();
|
ADC_Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(AdcDly > 0)
|
if(AdcDly > 0)
|
||||||
AdcDly--;
|
AdcDly--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,13 +147,19 @@ void calc_adc_val(uint16_t * p);
|
|||||||
|
|
||||||
void Encoder (void);
|
void Encoder (void);
|
||||||
|
|
||||||
|
//外部调用接口函数
|
||||||
MotorDirection Motor_GetDirection(void);/* 获取电机转动方向 */
|
MotorDirection Motor_GetDirection(void);/* 获取电机转动方向 */
|
||||||
void Motor_Control(MotorCommand cmd); /* 电机控制 */
|
void Motor_Control(MotorCommand cmd); /* 电机控制 */
|
||||||
void Dcmotor1msRoutine(void);
|
void Dcmotor1msRoutine(void);
|
||||||
void DcmotorLoopHandler(void);
|
void DcmotorLoopHandler(void);
|
||||||
|
|
||||||
|
float get_current(void); /* 获取工作电流 */
|
||||||
|
float get_volatage(void); /* 获取工作电压 */
|
||||||
|
float get_Temperature(void); /* 获取工作温度 */
|
||||||
|
float get_speed(void); /* 获取电机转速 */
|
||||||
|
float get_location(void); /* 获取电机位置 */
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user