求助大神看看我的程序的错误或给一份发动机档位加减档算法设计及仿真图及程序
主要程序代码如下:
//预处理数据
#define CAR_MAX 130
#define TORQUE_MAX 1.25
#define ROTATE_MAX 2550
#define Economy_rpm_MIN 1000
#define Economy_rpm_MAX 1300
struct InputData Preproccess(struct InputData sinputData)//将接收的数据限制在一定范围内
{
sinputData.car_speed = (CAR_MAX < sinputData.scar_speed) ? CAR_MAX : sinputData.car_speed;
sinputData.rotate_speed = (ROTATE_MAX < sinputData.rotate_speed) ? ROTATE_MAX : sinputData.rotate_speed;
sinputData.torquePercent = (TORQUE_MAX < sinputData.torquePercent) ? TORQUE_MAX : sinputData.torquePercent;
return sinputData;
}
//计算当前档位
int ShiftNow(float scar_speed, float srotate_speed, unsigned int Key)//计算当前档位,从6档以上考虑
{
//15.53 12.08 9.39 7.33 5.73 4.46 3.48 2.71 2.1 1.64 1.28 1
gearRadio = 480.255 * srotate_speed / Key / car_speed;//计算齿轮比
int shift_now = 0;
if ((gearRadio>4.31) && (gearRadio<4.61))
{
shift_now = 6;
}
else if ((gearRadio > 3.33) && (gearRadio < 3.63))
{
shift_now = 7;
}
else if ((gearRadio>2.56) && (gearRadio < 2.86))
{
shift_now = 8;
}
else if ((gearRadio>1.95) && (gearRadio < 2.25))
{
shift_now = 9;
}
else if ((gearRadio>1.49) && (gearRadio < 1.79))
{
shift_now = 10;
}
else if ((gearRadio>1.13) && (gearRadio < 1.43))
{
shift_now = 11;
}
else if ((gearRadio>0.85) && (gearRadio < 1.15))
{
shift_now = 12;
}
else
shift_now = 0;//当前档位值初始化为0,将丢弃该点的所有值
return shift_now;
}
//计算换挡状态值,3表示不换挡,4表示升档,5表示降档
int ComputeShiftState(float srotate_speed)//计算换挡状态
{
if((srotate_speed>=Economy_rpm_MIN)&&(srotate_speed<= Economy_rpm_MAX))
{
shiftState =3;//不换档
}
else if (srotate_speed > Economy_rpm_MAX)
{
shiftState = 4;//升档
}
else if (srotate_speed < Economy_rpm_MIN)
{
shiftState = 5;//降档
}
else
{
shiftState = 3;
}
return shiftState ;
}
|