智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 1119|回复: 3
打印 上一主题 下一主题

中断程序

[复制链接]

13

主题

73

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1065
QQ
威望
685
贡献
258
兑换币
241
注册时间
2014-5-19
在线时间
61 小时
毕业学校
东油
跳转到指定楼层
1#
发表于 2015-4-10 16:55:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//*******************直立 中断*************************//
void PIT0_IRQHandler(void)
{     time3++;
      PITCounter++;
      g_nSpeedControlPeriod++;
      SpeedControlOutput();
      g_nDirectionControlPeriod++;
      DirectionControlOutput();
//***********************时间片段0 - 采集数据 直立5MS******************//  
   if(PITCounter>=5)
   {
         if(g_nSpeedControlCount >= 20)
          {
            Speed_control(Speed_Set_Check);             //0.4 Speed_Set_Check
            g_nSpeedControlPeriod=0;
            g_nSpeedControlCount=0;
          }
         
        if(g_nDirectionControlCount >= 2)
         {  
           //Direction_control(Middle-64);               //传递中线误差,计算出转弯速度
           g_nDirectionControlPeriod=0;
           g_nDirectionControlCount=0;  
         }
    Calculate_Speed();                                //编码器采集做差速度控制 测出编码器速度 Check_Speed
    PITCounter = 0;                     
   }
//***********************时间片段1- 控速 100Ms******************//     
else if(PITCounter==1)
  {
           Get_Ang();                                 //1ms调整一次姿态  算出speed_Start直立速度
           MotorOutput();
  }
else if(PITCounter==2)
{      
          MotorOutput();
}
else if(PITCounter==3)
{
         g_nSpeedControlCount++;
}
else if(PITCounter==4)
{
         g_nDirectionControlCount++;//方向控制
}
//***********************时间片段3- 调正左右轮速10Ms ******************//  
   if(time3>=500&&TC==0)
   {
            time3=0;
            Speed_gap();
   }
     led_turn(LED0);
     PIT_Flag_Clear(PIT0);                            //清中断标志位
     
}
回复

使用道具 举报

13

主题

73

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1065
QQ
威望
685
贡献
258
兑换币
241
注册时间
2014-5-19
在线时间
61 小时
毕业学校
东油
2#
 楼主| 发表于 2015-4-10 16:55:59 | 只看该作者
本帖最后由 跳跳糖 于 2015-4-10 17:00 编辑


//*******************直立 中断*************************//
void PIT0_IRQHandler(void)
{      
     time0++;time1++;time2++;time3++;time4++;
      SpeedControlOutput();
      DirectionControlOutput();
//***********************时间片段0 - 采集数据 直立5MS******************//  
   if(time0>=5)
   {

    time0=0;   
    Get_Ang();                     //1ms调整一次姿态  算出speed_Start直立速度
    Calculate_Speed();             //编码器采集做差速度控制 测出编码器速度 Check_Speed

   }
//***********************时间片段1- 控速 100Ms******************//     
   if(time1>=50)
   {
     time1=0;

         g_nSpeedControlCount++;
         g_nSpeedControlPeriod++;
   if(g_nSpeedControlCount >= SPEED_CONTROL_PERIOD)
         {  
           Speed_control(Speed_Set_Check);      //0.4
           g_nSpeedControlPeriod=0;
           g_nSpeedControlCount=0;

         }

   }
//***********************时间片段2 - 输出5Ms ******************//         
   if(time2>=5)
   {
            time2=0;
            MotorOutput();

   }
//***********************时间片段3- 调正左右轮速10Ms ******************//  
   if(time3>=1000&&TC==0)
   {
            time3=0;
            Speed_gap();
   }
//***********************时间片段4- 方向 10Ms******************//     
   if(time4>=10)
   {
     time4=0;
          Direction_control(con_line);               //传递中线误差,计算出转弯速度
         g_nDirectionControlCount++;
         g_nDirectionControlPeriod++;
   if(g_nDirectionControlCount >= DIRECTION_CONTROL_PERIOD)
         {  
          // Direction_control(con_line);               //传递中线误差,计算出转弯速度
           g_nDirectionControlPeriod=0;
           g_nDirectionControlCount=0;

         }

   }
     led_turn(LED0);
     PIT_Flag_Clear(PIT0);                            //清中断标志位


回复 支持 反对

使用道具 举报

13

主题

73

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
1065
QQ
威望
685
贡献
258
兑换币
241
注册时间
2014-5-19
在线时间
61 小时
毕业学校
东油
3#
 楼主| 发表于 2015-4-10 16:56:39 | 只看该作者
本帖最后由 跳跳糖 于 2015-4-10 17:00 编辑

他们 有什么不同 我现在很纠结。第2个是我写的。。。。求救
回复 支持 反对

使用道具 举报

2

主题

78

帖子

0

精华

金牌会员

Rank: 6Rank: 6

积分
2299
威望
1069
贡献
626
兑换币
703
注册时间
2014-12-30
在线时间
302 小时
毕业学校
武大
4#
发表于 2015-5-2 17:34:36 | 只看该作者
跳跳糖 发表于 2015-4-10 16:56
他们 有什么不同 我现在很纠结。第2个是我写的。。。。求救

关于那个中断程序我们也出了一些问题 能不能交流
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关于我们|联系我们|小黑屋|智能车制作 ( 黑ICP备2022002344号

GMT+8, 2024-6-18 14:02 , Processed in 0.042012 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表