云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 电动汽车课程设计(智能小车)

电动汽车课程设计(智能小车)

  • 62 次阅读
  • 3 次下载
  • 2025/5/25 19:13:52

北京理工大学珠海学院2016届电动汽车课程设计

#define Left_moto_go {P1_2=0,P1_3=1;} //左电机向前走 #define Left_moto_back {P1_2=1,P1_3=0;} //左边电机向后转

#define Left_moto_Stop {P1_5=0;} //左边电机停转 #define Right_moto_go {P1_6=1,P1_7=0;} #define Right_moto_back {P1_6=0,P1_7=1;} #define Right_moto_Stop {P1_4=0;}

//右边电机向前走 //右边电机向后走

//右边电机停转

unsigned char pwm_val_left =0;//变量定义

unsigned char push_val_left =0;// 左电机占空比N/20 unsigned char pwm_val_right =0;

unsigned char push_val_right=0;// 右电机占空比N/20 bit Right_moto_stop=1; bit Left_moto_stop =1; unsigned int time=0;

/***********************************************/ //延时函数

void delay(unsigned int k) {

unsigned int x,y; }

/**********************************************/ //前速前进

void run(void) {

push_val_left=8;

push_val_right=8;

Left_moto_go ; //左电机往前走

-第17页-

for(x=0;x

//速度调节变量 0-20。。。0最小,20最大

北京理工大学珠海学院2016届电动汽车课程设计

}

Right_moto_go ; //右电机往前走

//左转

void leftrun(void) {

push_val_right=8;

Right_moto_go ; //右电机往前走

Left_moto_Stop ; //左电机停止 } //右转

void rightrun(void) { }

/* PWM调制电机转速 */ /* 左电机调速 */

/*调节push_val_left的值改变电机转速,占空比*/

void pwm_out_left_moto(void) push_val_left=8;

Left_moto_go ; //左电机往前走 Right_moto_Stop ; //右电机往前走

{

if(Left_moto_stop) {

if(pwm_val_left<=push_val_left)

{

Left_moto_pwm=1;

} else

-第18页-

北京理工大学珠海学院2016届电动汽车课程设计

{

Left_moto_pwm=0;

}

if(pwm_val_left>=20) pwm_val_left=0;

} else {

Left_moto_pwm=0;

} }

/* 右电机调速 */ void pwm_out_right_moto(void) {

if(Right_moto_stop) {

if(pwm_val_right<=push_val_right)

{

Right_moto_pwm=1; } else {

Right_moto_pwm=0;

}

if(pwm_val_right>=20) pwm_val_right=0;

} else

-第19页-

北京理工大学珠海学院2016届电动汽车课程设计

{

Right_moto_pwm=0; } }

/*TIMER0中断服务子函数产生PWM信号*/ void timer0()interrupt 1 using 2 {

TH0=0XFc;

TL0=0X18; time++;

pwm_val_left++; pwm_val_right++; pwm_out_left_moto(); pwm_out_right_moto();

//1Ms定时

} #endif

2. 遥控程序

#include

#define Left_moto_go {P1_2=0,P1_3=1;} //左边电机向前走

#define Left_moto_back {P1_2=1,P1_3=0;} //左边电机向后转

#define Left_moto_Stop {P1_2=0,P1_3=0;} //左边电机停转 #define Right_moto_go {P1_6=1,P1_7=0;} #define Right_moto_back {P1_6=0,P1_7=1;} #define Right_moto_Stop {P1_6=0,P1_7=0;}

//右边电机向前走 //右边电机向后走 //右边电机停转

#define Imax 14000 //此处为晶振为11.0592时的取值, #define Imin 8000 //如用其它频率的晶振时, #define Inum1 1450 //要改变相应的取值。

-第20页-

搜索更多关于: 电动汽车课程设计(智能小车) 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

北京理工大学珠海学院2016届电动汽车课程设计 #define Left_moto_go {P1_2=0,P1_3=1;} //左电机向前走 #define Left_moto_back {P1_2=1,P1_3=0;} //左边电机向后转 #define Left_moto_Stop {P1_5=0;} //左边电机停转 #define Right_moto_go {P1_6=1,P1_7=0;} #define Right_moto_back {P1_6=0,P1_7=1;} #define Right_moto_Stop {P1_4=0;} //右边电机向前走 //右边电机向后走 //右边电机停转 unsigned ch

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com