版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、單片機課程設(shè)計藍牙控制小車設(shè)計人員:章葉滿10214021班 級: 電子1001 完成日期:2012年12月27日指導老師: 黃贊武 摘要:利用藍牙進行無線傳輸數(shù)據(jù),并以STC89C52單片機為控制芯片控制電機旋轉(zhuǎn),從而實現(xiàn)通過藍牙控制小車運動的目的。其中電機驅(qū)動為L298N驅(qū)動電路,藍牙模塊與單片機的TXD和RXD相連,進行串口通信。速度由單片機輸出的PWM波控制。1. 實驗目的:通過單片機原理與應用課程設(shè)計,使學生掌握單片機及其擴展系統(tǒng)設(shè)計的方法和設(shè)計原則及相應的硬件調(diào)試的方法。進一步加深單片機及其擴展系統(tǒng)設(shè)計和應用的理解2設(shè)計任務(wù)與要求通過設(shè)計雙單片機控制系統(tǒng),實現(xiàn)藍牙控制小車的功能。單
2、片機1通過電機驅(qū)動模塊來控制電機正反轉(zhuǎn),從而驅(qū)動小車運動。單片機2通過串口TXD,RXD與藍牙模塊從機連接,進行串口通訊,而藍牙模塊主機與電腦相連,從而實現(xiàn)電腦與單片機二之間的通訊。在電腦上通過使用串口調(diào)試助手軟件向單片機發(fā)送控制命令,單片機二接受到電腦的控制命令后,將數(shù)據(jù)命令轉(zhuǎn)換為I/O口高點電平控制命令,傳送到單片機一,進而單片機一根據(jù)命令來控制電機而正反轉(zhuǎn),從而實現(xiàn)電腦控制小車前進、后退、轉(zhuǎn)彎。3. 電路設(shè)計3.1單片機控制電路:單片機是控制單元的核心。起著控制小車所有運行狀態(tài)的作用。單片機控制模塊使用的是STC89C52,使用該芯片很容易實現(xiàn)對其他模塊的控制。通過對單片機STC89C5
3、2寫入程序,可以方便的用軟件來控制整個過程. 3.2單片機最小系統(tǒng):包括單片機主機、復位電路、時鐘電路。3.3雙單片機系統(tǒng):有兩個單片機最小系統(tǒng)組成,其中單片機1的P0.2-P0.7口通過撥碼開關(guān)分別與單片機2的P3.2-P3.7口相連,利用撥碼來控制I/O端口的導通與斷開。3.4電機驅(qū)動系統(tǒng)直流電機和步進電機都可以用于小車驅(qū)動。故有兩種方案。方案一:使用直流電機,加上適當減速比的減速器。直流電機具有良好的調(diào)速性能,控制起來也比較簡單。直流電機只要通上直流電源就可連續(xù)不斷的轉(zhuǎn)動,調(diào)節(jié)電壓的大小就可以改變電機的速度。直流電機的驅(qū)動電路實際上就是一個功率放大器。常用的驅(qū)動方式是PWM方式,即脈沖寬
4、度調(diào)制方式。此方法性能較好,電路和控制都比較簡單。方案二:使用步進電機。步進電機具有良好的控制性能。當給步進電機輸入一個電脈沖信號時,步進電機的輸出軸就轉(zhuǎn)動一個角度,因此可以實現(xiàn)精確的位置控制。與直流電機不同,要使步進電機連續(xù)的轉(zhuǎn)動,需要連續(xù)不斷的輸入點脈沖信號,轉(zhuǎn)速的大小由外加的脈沖頻率決定。去而且其轉(zhuǎn)動不受電壓波動和負載變化的影響,也不受溫度、氣壓等環(huán)境因素的影響,僅與控制脈沖有關(guān)。但步進電機的驅(qū)動相對較復雜,要由控制器和功率放大器組成。具體差別見下表2-4。表2-4 電機控制方式對比直流電機步進電機調(diào)速性能較好較差位置控制精度較差好驅(qū)動簡單復雜穩(wěn)定性較好好,僅與控制脈沖有關(guān)由上表可以看出
5、步進電機和直流電機都有各自的優(yōu)點。步進電機能進行精確的位置控制,但驅(qū)動電路麻煩,鑒于本設(shè)計中小車的位置控制不要求十分精確,直流電機即可滿足小車要求的精度。且直流電機易于控制,驅(qū)動電路十分簡單。驅(qū)動電路小車使用的是直流電機。從單片機輸出的信號功率很弱,即使在沒有其它外在負載時也無法帶動電機,所以在實際電路中我們加入了電機驅(qū)動芯片提高輸入電機信號的功率,從而能夠根據(jù)需要控制電機轉(zhuǎn)動。直流電機常用的PWM,及脈寬調(diào)制方式驅(qū)動。本設(shè)計中電機驅(qū)動采用L298集成H橋芯片。L298中有兩套H橋電路,剛好可以控制兩個電機。它的使能端可以外接高低電平,也可以利用單片機進行軟件控制,極大地滿足各種復雜電路需要。
6、另外,L298的驅(qū)動功率較大,在646V的電壓下,可以提供2A的額定電流,并且具有過熱自動關(guān)斷和電流反饋檢測功能,安全可靠;為了保證L298正常工作,我們另外安裝了續(xù)流二極管。電路如圖3-4所示。能根據(jù)輸入電壓的大小輸出不同的電壓和功率,解決了負載能力不夠這個問題。利用單片機調(diào)整出PWM脈沖和高低電平對直流電機進行驅(qū)動和控制。圖3-4 電機驅(qū)動電路L298集成H橋芯片。其外形、管腳分布如圖3-5所示。 圖3-5 L298管腳分布圖3.5 PWM調(diào)速原理脈沖寬度調(diào)制(Pulse Width Modulation),簡稱PWM。脈沖周期不變,只改變晶閘管的導通時間,即通過改變脈沖寬度來進行直流調(diào)速
7、。PWM的理論基礎(chǔ)是:沖量相等而形狀不同的的窄脈沖加在具有慣性的環(huán)節(jié)上,其效果基本相同。采用PWM進行電機的調(diào)速控制,實際是保持加在電機電機電樞上的脈沖電壓頻率不變,調(diào)節(jié)其脈沖寬度。電機是一個慣性環(huán)節(jié),它的電樞電流餓轉(zhuǎn)速均不能突變,很高的頻率的PWM加在電機上,效果相當于施加一個恒定電壓的直流電。如圖3-6所示。這個電壓可以由脈沖的寬度調(diào)節(jié)。 圖3-6 PWM等效圖示意圖使用PWM方式可以很容易的實現(xiàn)調(diào)速。PWM信號由單片機軟件產(chǎn)生,使用非常方便。由于電路總體上并不復雜,驅(qū)動電路的控制輸入端也可以不用經(jīng)光耦合隔離,直接與單片機引腳相連。前進時,驅(qū)動兩個直流電機都正轉(zhuǎn),后退時,則兩電機都反轉(zhuǎn)。左
8、轉(zhuǎn)時前進時,左電機不轉(zhuǎn)而右電機正轉(zhuǎn),右轉(zhuǎn)前進時,則右電機不轉(zhuǎn)而左電機正轉(zhuǎn)。進入減速區(qū)時,由單片機控制進行PWM變頻調(diào)速,通過軟件改變脈沖調(diào)寬波形的占空比,實現(xiàn)調(diào)速。所有這些都是通過軟件編程實現(xiàn)控制。3.6 供電系統(tǒng):電機電壓為7.2V,單片機及藍牙模塊供電電壓為5V,通過穩(wěn)壓芯片將7.2V電壓轉(zhuǎn)換為5V電壓給單片機和藍牙供電。3.7藍牙串口通信系統(tǒng):將藍牙模塊的主機與電腦相連,從機與單片機2的串口相連。傳輸電腦的控制命令。3.8總體電路圖:4. 程序設(shè)計:4.1設(shè)計流程圖:系統(tǒng)初始化小車移動檢測外部有無信號輸入無信號輸入是否調(diào)動函數(shù)控制小車移動開始傳輸串口數(shù)據(jù)是否還有檢測信號等待下次數(shù)據(jù)結(jié)束Y
9、NNYYN4.2單片機2串口通信程序:#include <at89x51.h>#define left P3_2#define right P3_3#define go P3_4#define back P3_5#define leftdata 0x11 ;左轉(zhuǎn)控制命令#define rightdata 0x22 ;右轉(zhuǎn)控制命令#define godata 0x33 ;前進控制命令#define backdata 0x44 ;后退控制命令unsigned char a,b,flag;void delay1ms(unsigned int x) unsigned int i,j; fo
10、r(j=x;j>0;j-) for(i=75;i>0;i-);main()TMOD=0x20;/定時器工作在方式2TH1=0xfd;TL1=0xfd;/9600波特率TR1=1;/開定時器計數(shù)SM0=0;SM1=1;/串行工作方式1REN=1;/允許接收數(shù)據(jù)EA=1;/開中斷總開關(guān)ES=1;/允許串行中斷while(1) if(flag=1) flag=0; if(b!=a) left=1; right=1; go=1; back=1; switch(b) case leftdata:left=0;break; case rightdata:right=0;break; case
11、godata:go=0;break; case backdata:back=0;break; a=b; delay1ms(30); else left=1; right=1; go=1; back=1; void serial() interrupt 4 /中斷法flag=1;b=SBUF;RI=0;/中斷標志4.3 單片機1電機控制程序:#include <at89x51.h>#define uchar unsigned char#define uint unsigned intvoid motor_r_z(void);/右邊電動機正轉(zhuǎn)void motor_l_z(void);/
12、左邊電動機正轉(zhuǎn)void motor_r_f(void);/右邊電動機反轉(zhuǎn)void motor_l_f(void);/左邊電動機反轉(zhuǎn)void back(uchar,uchar); /小車后退void go(uchar,uchar);/小車前進void stop(void);/小車停止void left(void);/小車左轉(zhuǎn)void right(void);/小車右轉(zhuǎn)sbit PWM1=P25;sbit PWM2=P24;sbit PWM3=P21;sbit PWM4=P22;sbit EN1=P20;sbit EN2=P23;sbit left_k=P02;sbit back_k=P05;sb
13、it go_k=P04;sbit right_k=P03;sbit sound=P27;uchar data t_0; /每產(chǎn)生一次T0定時器中斷的時候t_0加1uchar data motor_r; /motor_r用于存放右邊電機轉(zhuǎn)速和轉(zhuǎn)向的數(shù)據(jù)uchar data motor_l; /motor_l用于存放左邊電機轉(zhuǎn)速和轉(zhuǎn)向的數(shù)據(jù)uchar data Value;uchar data mid;/*初始化函數(shù)*/void ini(void)/T0初始化/TMOD=0x01; /T0工作在方式1TH0=0xff; /裝入T0初值TL0=0xf6;TR0=1;/開T0中斷ET0=1;/T0允許
14、中斷EA=1;/t_0=0;/P2=0;sound=1;void go(uchar left_motor,uchar right_motor)/直行Value=right_motor;motor_r_z();Value=left_motor;motor_l_z();void back(uchar left_motor,uchar right_motor)/后退Value=right_motor;motor_r_f();Value=left_motor;motor_l_f();void left(void)/左轉(zhuǎn)Value=0x45;motor_r_z();Value=0x45;motor_l_
15、f();void right(void)/右轉(zhuǎn)Value=0x45;motor_r_f();Value=0x45;motor_l_z();void motor_r_z(void)/右邊電動機正轉(zhuǎn) ACC=0x64+Value; motor_r=ACC; EN1=1;void motor_l_z(void)/左邊電動機正轉(zhuǎn) ACC=0x64-Value; motor_l=ACC; EN2=1;void motor_r_f(void)/右邊電動機反轉(zhuǎn) ACC=0x64-Value; motor_r=ACC; EN1=1;void motor_l_f(void)/左邊電動機反轉(zhuǎn) ACC=0x64+V
16、alue; motor_l=ACC; EN2=1;void stop(void)EN2=0;EN1=0;/*T0中斷服務(wù)程序*/*PWM產(chǎn)生*/void time0(void) interrupt 1 using 2TR0=0;TH0=0xff;TL0=0xf6;+t_0;ACC=t_0;CY=0;ACC-=motor_r;if(CY=1)PWM1=1;PWM2=0;goto PWM_2;PWM1=0;PWM2=1;PWM_2:ACC=t_0;CY=0;ACC-=motor_l;if(CY=1)PWM3=1;PWM4=0;goto HIGHT;PWM3=0;PWM4=1;HIGHT:ACC=t
17、_0;if(ACC!=0xc9)goto EXIT;ACC=0;t_0=ACC;EXIT:TR0=1; void main(void)ini();while(1)aa: while(left_k)/當左按鍵按下時,left_k等于1. goto bb; P1=0xff; P1=P0; left();/向左轉(zhuǎn) while(!left_k);/如果left_k一直為一,小車便一直左轉(zhuǎn) stop();/判斷右鍵是否按下/bb: while(right_k) goto dd; P1=0xff; P1=P0; right(); while(!right_k); stop();/判斷向前鍵是否按下/dd:
18、 while(go_k) goto ee; P1=0xff; P1=P0; go(0x64,0x64); while(!go_k); stop();/判斷后退鍵是否按下/ee: while(back_k) goto aa; P1=0xff; P1=P0; back(0x64,0x64); while(!back_k);stop();5. 調(diào)試:完成電路設(shè)計與焊接后進行調(diào)試,給單片機上點并接上藍牙串口模塊,打開串口調(diào)試助手,選擇相應串口,將波特率設(shè)定為9600bps,數(shù)據(jù)位8位,停止位1,檢驗位0,然后將鍵盤按鍵綁定,即:當按下A時,發(fā)送十六進制數(shù)據(jù)11H,為左轉(zhuǎn)命令;當按下D時,發(fā)送十六進制數(shù)
19、據(jù)22H,為右轉(zhuǎn)命令;當按下W時,發(fā)送十六進制數(shù)據(jù)33H,為前進命令;當按下S時,發(fā)送十六進制數(shù)據(jù)44H,為后退命令。6. 結(jié)論:經(jīng)過多次軟件調(diào)試,可實現(xiàn)設(shè)計的基本要求,即:可通過電腦按鍵控制小車的運動。g an employment tribunal claimEmployment tribunals sort out disagreements between employers and employees.You may need to make a claim to an employment tribunal if:· you don't agree with th
20、e disciplinary action your employer has taken against you· your employer dismisses you and you think that you have been dismissed unfairly.For more information about dismissal and unfair dismissal, see Dismissal.You can make a claim to an employment tribunal, even if you haven't a
21、ppealed against the disciplinary action your employer has taken against you. However, if you win your case, the tribunal may reduce any compensation awarded to you as a result of your failure to appeal.Remember that in most cases you must make an application to an employment tribunal within thr
22、ee months of the date when the event you are complaining about happened. If your application is received after this time limit, the tribunal will not usually accept it.If you are worried about how the time limits apply to you, take advice from one of the organisations listed under Further help.
23、Employment tribunals are less formal than some other courts, but it is still a legal process and you will need to give evidence under an oath or affirmation.Most people find making a claim to an employment tribunal challenging. If you are thinking about making a claim to an employment tribunal, you
24、should get help straight away from one of the organisations listed under Further help.If you are being represented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you win the case. This is known as a damages-based ag
25、reement. In England and Wales, your solicitor can't charge you more than 35% of your compensation if you win the case.If you are thinking about signing up for a damages-based agreement, you should make sure you're clear about the terms of the agreement. It might be best to get ad
26、vice from an experienced adviser, for example, at a Citizens Advice Bureau. To find your nearest CAB, including those that give advice by e-mail, click on nearest CAB.For more information about making a claim to an employment tribunal, see Employment tribunals.The (lack of) air up th
27、ere Watch mCayman Islands-based Webb, the head of Fifa's anti-racism taskforce, is in London for the Football Association's 150th anniversary celebrations and will attend City's Premier League match at Chelsea on Sunday."I am going to be at the match tomorrow and I have asked to mee
28、t Yaya Toure," he told BBC Sport."For me it's about how he felt and I would like to speak to him first to find out what his experience was."Uefa has opened disciplinary proceedings against CSKA for the "racist behaviour of their fans" during City's 2-1
29、 win.Michel Platini, president of European football's governing body, has also ordered an immediate investigation into the referee's actions.CSKA said they were "surprised and disappointed" by Toure's complaint. In a statement the Russian side added: "We found no racist in
30、sults from fans of CSKA."Age has reached the end of the beginning of a word. May be guilty in his seems to passing a lot of different life became the appearance of the same day; May be back in the past, to oneself the paranoid weird belief disillusionment, these days, my mind has been very mess
31、y, in my mind constantly. Always feel oneself should go to do something, or write something. Twenty years of life trajectory deeply shallow, suddenly feel something, do it.一字開頭的年齡已經(jīng)到了尾聲。或許是愧疚于自己似乎把轉(zhuǎn)瞬即逝的很多個不同的日子過成了同一天的樣子;或許是追溯過去,對自己那些近乎偏執(zhí)的怪異信念的醒悟,這些天以來,思緒一直很凌亂,在腦海中不斷糾纏??傆X得自己自己似乎應該去做點什么,或者寫點什么。二十年的人生軌
32、跡深深淺淺,突然就感覺到有些事情,非做不可了。The end of our life, and can meet many things really do?而窮盡我們的一生,又能遇到多少事情是真正地非做不可?During my childhood, think lucky money and new clothes are necessary for New Year, but as the advance of the age, will be more and more found that those things are optional; Junior high school, t
33、hought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni in peace, suddenly found that isn't really grow up, it seems is not so important; Then in high school, think don't want to give vent to out your inner voice can be in the hig
34、h school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already can't remember his appearance.童年時,覺得壓歲錢和新衣服是過年必備,但是
35、隨著年齡的推進,會越來越發(fā)現(xiàn),那些東西根本就可有可無;初中時,以為要有一場暗戀才意味著真正的成長,但三年過去后,自己心平氣和的寫同學錄的時候,突然就發(fā)現(xiàn)是不是真正的成長了,好像并沒有那么重要了;然后到了高中,覺得非要吐露出自己的心聲才能為高中生涯里的懵懂情愫劃上一個句點,但畢業(yè)晚會的時候最終還是被梗塞在了咽喉,后來再次站在他曾經(jīng)揮汗如雨的球場,看著他投過籃球的球框時,突然間發(fā)現(xiàn)自己已經(jīng)想不起他的容顏。Originally, this world, can produce a chemical reaction to an event, in addition to resolutely, ha
36、ve to do, and time.原來,這個世界上,對某個事件能產(chǎn)生化學反應的,除了非做不可的堅決,還有,時間。A person's time, your ideas are always special to clear. Want, want, line is clear, as if nothing could shake his. Also once seemed to be determined to do something, but more often is he backed out at last. Dislike his cowardice, finally
37、found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. Those who do, just green years oneself give oneself an arm injection, or is a self-righteous spiritual.一個人的時候,自己的想法總是特別地清晰。想要的,不想要的,界限明確,好像沒有什么可以撼動自己。也曾經(jīng)好像已經(jīng)下定了決心去做某件事,但更多的時候是最后又打起了退堂鼓。嫌惡過自己的怯懦,最終卻發(fā)現(xiàn)有很多
38、緣分,有很多錯過,好像冥冥之中真的已經(jīng)注定。那些曾經(jīng)所謂的非做不可,只是青蔥年華里自己給自己注射的一支強心劑,或者說,是自以為是的精神寄托罷了。At the moment, the sky is dark, the air is fresh factor after just rained. Suddenly thought of blue plaid shirt; Those were broken into various shapes of stationery; From the corner at the beginning of deep friendship; Have decl
39、ared the end of the encounter that haven't start planning. Those years, those days of do, finally, like youth, will end in our life.此刻,天空是陰暗的,空氣里有著剛下過雨之后的清新因子。突然想到那件藍格子襯衫;那些被折成各種各樣形狀的信紙;那段從街角深巷伊始的友誼;還有那場還沒有開始就宣告了終結(jié)的邂逅計劃那些年那些天的非做不可,終于和青春一樣,都將在我們的人生中謝幕。Baumgartner the disappointing news: Mission a
40、borted. r plays an important role in this mission. Starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) whe
41、re our day-to-day weather lives. It will climb higher than the tip of Mount Everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.The supersonic descent could happen as early as Sunda.The weatheThe balloon will slowly drift to the edge of space at 120,000
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 基本不等式課件
- 8、《世說新語》二則之陳太丘
- 朗讀白樺的課件
- 金融公司合作合同模板
- 魚類購銷合同模板
- 門窗展架采購合同模板
- 地下停車租賃合同模板
- 解除代理公司合同模板
- 成立公司協(xié)議合同模板
- 菜鳥驛站加盟合同模板
- 《基本天氣圖分析》
- ISO45001-2018標準培訓教材
- 安化黑茶三尖
- 不努力讀書換來一生的卑微和底層
- GB/T 36040-2018居民住宅小區(qū)電力配置規(guī)范
- 系列講座2-高壓輸電線路鐵塔結(jié)構(gòu)設(shè)計
- GB 25131-2010蒸氣壓縮循環(huán)冷水(熱泵)機組安全要求
- 表土剝離與再利用研究
- (精心整理)大衛(wèi)科波菲爾-中英文對照
- 激光切割軟件lasercad說明書
- AFC系統(tǒng)的架構(gòu)及運營
評論
0/150
提交評論