- 1、本文档共29页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
电机转向(Motor steering)
电机转向(Motor steering)
LED Black is 1
Light is 0
Left1=P0^0 / second lights;
Left2=P0^1; / / the first light
Right1=P0^2 / third lights;
Right2=P0^3 / fourth lights;
LN1=1;
LN2=0; / / left motor.
LN1=0;
LN2=1; / / left motor reversal
RN3=1;
RN4=0; / / the right motor is transferred
RN3=0;
RN4=1; / / the right motor reversal
LN1=1;
LN2=0;
RN3=1;
RN4=0; / / motor is transferred
LN1=0;
LN2=1;
RN3=0;
RN4=1; / / motor reversal
LN1=1;
LN2=0;
RN3=0;
RN4=1; turn right (left / right motor reversal motor story)
LN1=0;
LN2=1;
RN3=1;
RN4=0; / / turn left (right and left motor forward reverse motor)
#includereg52.h
#includeintrins.h
#define uint unsigned int
#define uchar unsigned char
#define state P0
#define _NOP () _nop_ ()
Sbit left1=P0^0;
Sbit left2=P0^1;
Sbit right1=P0^2;
Sbit right2=P0^3;
Sbit lN1=P2^0;
Sbit lN2=P2^1;
Sbit rN3=P2^2;
Sbit rN4=P2^3;
Void, delay_882us ()
{
Uint i;
I=110;
While (--i);
}
Void, delay_1000us ()
{
Uint i;
I=125;
While (--i);
}
Void, delay_2400us ()
{
Uint i;
I=300;
While (--i);
}
Void delay_1ms (uchar x)
{
Int i;
While (x--)
{
For (i=0; i125; i++)
{};
}
} / / delay
Void PWM_T (uchar T)
{uint, I, J, k;
For (i=t; i0; i--)
{for (k=0; k2; k++)
{};
}
For (j=100-t; j0; j--)
{for (k=0; k2; k++)
{};
}
} / / duty ratio
Void (go_straight_all) / / go straight at full speed (past) 11
{
LN1=0;
LN2=1;
RN3=1;
RN4=0;
Delay_1ms (10);
}
Void go_back_all () //2 2
{
LN1=1;
LN2=0;
RN3=0;
RN4=1;
Delay_1ms (10);
}
Void stop_00 () //3 3
{
LN1=1;
LN2=1;
RN3=1;
RN4=1;
Delay_1ms (10);
}
Void (turn_right1) / right turn left, the motor is transferred, the right motor reversal //4 4
{
LN1=0;
LN2=1;
RN3=0;
RN4=1;
PWM_T (40);
}
Void turn_right2 () //5 4
{
LN1=0;
LN2=1;
RN3=0;
RN4=1;
PWM_T (80);
}
Void turn_right3 () //6 4
{
LN1=0;
LN2=1;
RN3=0;
RN4=1;
PWM _ t (60);
}
Void turn _ left1 () / / 左转: 右电机正转, 左电机反转 / 7 5
{
Ln1 = 1;
LN2 = 0;
RN3 = 1;
RN4 = 0;
PWM _ t (40);
}
Void turn _ left2 () / / 8 5
{
Ln1 = 1;
LN2 = 0;
RN3 = 1;
RN4 = 0;
PWM _ t (80);
}
Void turn _ left3 () / / 9 5
{
您可能关注的文档
- 浅谈施工企业对分包成本的核算(Discussion on the subcontract cost of construction enterprises).doc
- 浅谈施工阶段的造价控制与管理(Construction cost control and management at construction stage).doc
- 浅谈电力基层企业人工成本管理(Discussion on labor cost management of power primary Enterprises).doc
- 浅谈如何发展符合中国国情的高速铁路(How to develop high speed railway in line with China's national conditions).doc
- 浅谈智能控制的发展与应用(Development and application of intelligent control).doc
- 浅谈砌体结构的质量问题(Discussion on quality of masonry structure).doc
- 浅谈铁路运输人身损害赔偿的几个问题(Discussion on several issues of compensation for personal injury in railway transportation).doc
- 浅述材料发展史(The history of the development of materials).doc
- 测绘标准与测绘标准化(Standardization of Surveying and mapping and standardization of Surveying and mapping).doc
- 测绘知识(Mapping knowledge).doc
文档评论(0)