1 / 19
文档名称:

有关舵机和直流电机的PID控制算法.doc

格式:doc   大小:47KB   页数:19页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

有关舵机和直流电机的PID控制算法.doc

上传人:Gebu 2022/4/13 文件大小:47 KB

下载得到文件列表

有关舵机和直流电机的PID控制算法.doc

相关文档

文档介绍

文档介绍:有关舵机和直流电机的PID控制算法
#include <> /* common defines and macros */ #include <> /* derivative informationPWM2*/
PWMCLK_PCLK2 = 0; /*选CLOCKB*/
PWMPRCLK |= 0x70; /*128 分频*/
PWMPOL_PPOL2 = 1; /*output is high at the beginning of the period*/
PWMCAE_CAE2 = 0; /*选择所要产生的方波的对齐方式,先高后低*/
PWMPER2 = 120; /*dedicated period register for channel 2*/
PWMDTY2 = 0; /*初始化占空比为0*/
PWME_PWME2 = 1; /*Enable PWM2*/
} /************************ DC MOTOR_1 **************************/ //函数名 : init_pwm3(void) //功能 : 初始化pwm3,产生频率为
//入口参数: 无 //全局变量: 无 //返回参数: 无 //说明 : 无 /****************************************************************/
void init_pwm3 (void)
{
PWME_PWME3 =0; /*Disable PWM3*/
PWMCLK_PCLK3 =0; /*选CLOCKB*/
PWMPRCLK |=0x70; /*128 分频*/
PWMPOL_PPOL3 = 1; /*output is high at the beginning of the period*/
PWMCAE_CAE3 = 0; /*选择所要产生的方波的对齐方式,先高后低*/
PWMPER3 = 120; /*dedicated period register for channel 3*/
PWMDTY3 = 0; /*初始化占空比为0*/
PWME_PWME3 = 1; /*Enable PWM3*/
} /*************************MCCNT*****************************/ //函数名 : init_MCCNT(void) //功能 : 初始化模下计数器,定时间隔为 10ms
//入口参数: 无 //全局变量: 无 //返回参数: 无 //说明 : 无 /***********************************************************/ void init_MCCNT()
{
MCCTL_MCEN = 0; /*Modulus Down-Counter disable*/
MCFLG_MCZF = 1; /*Modulus Counter Underflow Flag*/
MCCTL_MCZI = 1; /*Modulus Counter Underflow Interrupt Enable*/
MCCTL_MODMC= 1;
MCCTL_MCPR = 3; /*16 分频*/
MCCTL_FLMC = 1;
MCCTL_MCEN = 1; /*Modulus Down-Counter Enable*/
MCCNT= 15000; /* 定时10ms */
MCCTL_FLMC = 1;
} /*******************PACA************************************/ //函数名 : init_PACA(void) //功能 : 初始化脉冲累加器 A,用于实时的得到速度值
//入口参数: 无 //全局变量: 无 //返回参数: 无 //说明 : 无 /***********************************************************/ void init_PACA(void)
{
PACTL_PAEN =0; /* Disable PACA*/
PAFLG =0x01; /*清标志寄存器*/
PACTL_PAMOD =0; /*event counter mode*/
PACTL_PEDGE =1; /*Rising edge*/
DLYCT =0x01;