智能车制作

 找回密码
 注册

扫一扫,访问微社区

查看: 4001|回复: 7
打印 上一主题 下一主题

[软件类] 重读官方的方案。不知道对不对,特拿过来讨论讨论

[复制链接]

21

主题

274

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
3307
威望
1082
贡献
1863
兑换币
72
注册时间
2011-3-26
在线时间
181 小时
跳转到指定楼层
1#
发表于 2012-3-24 05:12:44 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
void TI1_OnInterrupt(void)
{
int i;
  /* Write your code here ... */
   //--------------------------------------------------------------------------
   WAITTIME_INC;                               // Increase WAITTIME function counter;
   if(TIME1MS_INT_FLAG)  return;
   
   //--------------------------------------------------------------------------
   g_n1MSEventCount ++;
if(g_nTimeTestFlag)  TIMETEST_ON;
     
   //--------------------------------------------------------------------------
   g_nSpeedControlPeriod ++;
   SpeedControlOutput();
   
   g_nDirectionControlPeriod ++;
   DirectionControlOutput();

  //--------------------------------------------------------------------------
   if(g_n1MSEventCount >= CONTROL_PERIOD) {    // Motor speed adjust
    g_n1MSEventCount = 0;                   // Clear the event counter;
   
    GetMotorPulse();
   } else if(g_n1MSEventCount == 1) {          // Start ADC convert and Car erect adjust
    if(AD_FLAG) {
   for(i = 0; i < INPUT_VOLTAGE_AVERAGE; i ++)
    SampleInputVoltage();
    }
   } else if(g_n1MSEventCount == 2) {          // Get the voltage and start calculation
  if(AD_FLAG) GetInputVoltageAverage();
  //----------------------------------------------------------------------
  AngleCalculate();
  AngleControl();  
  //----------------------------------------------------------------------
  MotorOutput();                          // Output motor control voltage;   
   } else if(g_n1MSEventCount == 3) {          // Car speed adjust
    g_nSpeedControlCount ++;
    if(g_nSpeedControlCount >= SPEED_CONTROL_COUNT) {
     SpeedControl();
     g_nSpeedControlCount = 0;
     g_nSpeedControlPeriod = 0;     
    }
   } else if(g_n1MSEventCount == 4) {          // Car direction control
  g_nDirectionControlCount ++;
  DirectionVoltageSigma();
  if(g_nDirectionControlCount >= DIRECTION_CONTROL_COUNT) {
     DirectionControl();
     g_nDirectionControlCount = 0;
     g_nDirectionControlPeriod = 0;
    }
   }
   
  //--------------------------------------------------------------------------
  if(g_nTimeTestFlag)  TIMETEST_OFF;
}


此中断时间为1ms,中断服务程序中片段0-4,严格的按照时序,5ms执行一次。但SpeedControlOutput();DirectionControlOutput();两个函数,而是每1ms执行一次,与
官网上说的每5ms执行一次相悖。不知道大家注意没有。不知道是不是这样的,求大神指点。。。

21

主题

274

帖子

0

精华

常驻嘉宾

Rank: 8Rank: 8

积分
3307
威望
1082
贡献
1863
兑换币
72
注册时间
2011-3-26
在线时间
181 小时
2#
 楼主| 发表于 2012-3-24 16:21:53 | 显示全部楼层
谢谢指点。。。。。。实验之。。。。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-6 17:26 , Processed in 0.076991 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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