----------------源代码:KK_C的 运行问题-------------
void main(void){
Init(); //Board init 初始化系统
PpmWaitSignal(); //Wait rx signal, led will flash 等待接收机的信号,等待时LED闪烁
Setup(); //Load & Adjust parameters 加载&调节参数
//Main loop 主循环
LED0_OFF();
while(1)
{
TimerRst();
CaclAttitude(); //Caculate plane attitude 计算飞行器姿态
TimerTo(1000);
//Do something between MotorControlBegin() and MotorControlEnd
//See functions declaration, can not exceed 1000us
//在MotorControlBegin()和MotorControlEnd()之间干点事儿,注意不要超过1000us
MotorControlBegin(); //Output head of ppm signal 输出PPM信号的头部分
PpmReadSignal(); //Read rx 读取接收机信号 140us
if(RxThr<RxThrLow) //If thr shutdown 如果油门关闭
{
GyroGainRead();//Read gain 读取感度电位器 670us
ArmingRoutine(); //Arm/disarm 加锁解锁测试 5us
}
else
{
AxisMixer();//Cacl motor signal 计算电机信号 305us
}
//If locked(arm) or no gyro base, shutdown all motor
//如果处于锁定态或者陀螺仪基准未建立,关闭所有马达
if(InLock || GyroBaseCnt || RxThr<5)
{
Motor1=Motor2=Motor3=Motor4=0;
}
//MOTOR6_L(); //I use it for test execute period 我用来观察执行时间的
MotorControlEnd();//Output whole ppm signal 输出完整的PPM信号
}
}
疑问:
主程序:
TimerRst();
CaclAttitude(); //Caculate plane attitude 计算飞行器姿态
TimerTo(1000);
读取姿态并保持在在1ms内。在MotorControlBegin()和MotorControlEnd()1000us 也就是1ms输出PPM貌似占用125*8us也就是 1ms总共应该是3ms的主程序运行周期?
那么CaclAttitude(); 读取的就是四轴3ms内的姿态变化吗?PPM信号是在中断里面读取的。也就是一旦中断读取完每个通道的信号,数据更新后四轴才能更新参数,这个时间不影响主程序时间对吧?
求各位魔友讨论概释。 四轴不都是几百Hz的程序运行么?
3ms的话333Hz应该也可以吧 楼主能否发一个KK_C的完整版程序啊,我参考下,谢谢了
页:
[1]