资料编号:214
该仿真功能介绍:
基于51单片机和L298N电机控制电路的51小车仿真电路,该51单片机小车可实现:小车的前进,小车的后退 小车的左拐弯 和右拐弯 (默认电机顺时钟转为前进)
按下仿真按钮后 首先是没有任何反应的
按下前进按键 小车全速前进 电机速度(两端电压)大概为69.2
按下后退按键 小车全速后退 电机速度(两端电压)大概为-69.2
按下左转弯按键 小车左转弯 左前轮左后轮速度(两端电压)大概30左右
右前轮右后轮速度(两端电压)大概50左右
按下右转弯按键 小车右转弯 左前轮左后轮速度(两端电压)大概50左右
右前轮右后轮速度(两端电压)大概30左右
按下停止按键 小车停止
![](https://i-blog.csdnimg.cn/blog_migrate/c682fc62b89d1497dc763f133b63a54d.png)
部分程序展示:
void TIM0Init()
{
TMOD=0x01;//定时器工作方式1
TH0=(65536-1000)/256;//初值高8位
TL0=(65536-1000)%256;//初值低8位
EA=1;//开总中断
ET0=1;//开启定时器0中断
}
void TIM1Init()
{
TMOD=0x10;//定时器工作方式1
TH1=(65536-1000)/256;//初值高8位
TL1=(65536-1000)%256;//初值低8位
EA=1;//开总中断
ET1=1;//开启定时器0中断
}
void CarTurnLeft()
{
TIM0Init();
LeftFront1=1;
LeftFront2=0;
LeftBehind1=1;
LeftBehind2=0;
RightFront1=1;
RightFront2=0;
RightBehind1=1;
RightBehind2=0;
}
void CarTurnRight()
{
TIM1Init();
LeftFront1=1;
LeftFront2=0;
LeftBehind1=1;
LeftBehind2=0;
RightFront1=1;
RightFront2=0;
RightBehind1=1;
RightBehind2=0;
}
void CarStop()
{
LeftFront1=1;
LeftFront2=1;
LeftFrontC=1;
LeftBehind1=1;
LeftBehind2=1;
LeftBehindC=1;
RightFront1=1;
RightFront2=1;
RightFrontC=1;
RightBehind1=1;
RightBehind2=1;
RightBehindC=1;
}
![](https://i-blog.csdnimg.cn/blog_migrate/ee10ee0fe8a20f3cfb0b3279571035e6.png)
![](https://i-blog.csdnimg.cn/blog_migrate/c8d2d4331c1a0a7e0713739cc15d5039.png)