機器人小車(論文)_第1頁
機器人小車(論文)_第2頁
機器人小車(論文)_第3頁
機器人小車(論文)_第4頁
機器人小車(論文)_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、機器人小車隊員:劉汝磊、陳 齊、談仲武陳喜、吳天威、沈博偉、孟杰單位:黃山學(xué)院指導(dǎo)老師:孫中勝2008年7月14日 機器人小車摘 要:本系統(tǒng)以89C52單片機為核心,輔以步進電機、LCD顯示、紅外傳感器和觸須傳感器數(shù)據(jù)采集等電路組成,實現(xiàn)了機器人小車的前后行走、左右轉(zhuǎn)彎、靈巧避障,尋軌行走、LCD顯示等功能。避障采用了紅外避障和觸須避障兩種方案,能更好且更精確的避開障礙物。使用LCD顯示,豐富小車功能和構(gòu)造。Abstract:The system is designed to construct a wired monitor system of a master station contro

2、lling multiple slave stations,with a micro-controller 89C52 as the key, complimented by stepper motor drive, LCD display, infrared sensors and sensor data acquisition tentacles, and other circuit components, to achieve a robot walking around the car, turning around, ingenious obstacle avoidance, loo

3、k for tracks Walking, LCD display, and other functions. Obstacle avoidance of the use of infrared obstacle avoidance and tentacles obstacle avoidance two programmes, better and more precise to avoid obstacles. The use of LCD display, rich car functions and structure.一、 功能與方案1、 前后行走與左右轉(zhuǎn)彎小車行走是依靠左右邊的兩個

4、伺服電機,伺服電機的工作原理與普通的電機不通,它的動力來源于不同頻率的脈沖。在這里,給它1.3ms左右的脈沖時,它就正轉(zhuǎn),如圖1所示。給它1.5ms左右的脈沖時,它就靜止,如圖2所示。給它1.7ms左右的脈沖時,它就反轉(zhuǎn),如圖3所示。圖1 1.3 ms的控制脈沖序列使電機順時針全速旋轉(zhuǎn)圖2 電機轉(zhuǎn)速為零的控制信號時序圖圖3 1.7ms的連續(xù)脈沖序列使電機逆時針全速旋轉(zhuǎn) 圖4 伺服電機的連線原理圖(左)和實際接線示意圖(右)伺服電機與單片機的連接如圖4所示:不同頻率的脈沖是由單片機通過編程送出,如程序一所示:程序一:while(1)P1_0=1; /P1_0輸出高電平delay_nus(1500

5、); /延時1.5msP1_0=0; /P1_0輸出低電平delay_nus(20000); /延時20ms (伺服電機靜止)while(1)P1_0=1; /P1_0輸出高電平delay_nus(1300); /延時1.3msP1_0=0; /P1_0輸出低電平delay_nus(20000); /延時20ms(伺服電機正轉(zhuǎn))P1_0=1; /P1_0輸出高電平delay_nus(1700); /延時1.7msP1_0=0; /P1_0輸出低電平delay_nus(20000); /延時20ms (伺服電機反轉(zhuǎn))機器人小車的轉(zhuǎn)彎是通過讓一個伺服電機轉(zhuǎn)動,另一個不轉(zhuǎn)或是反轉(zhuǎn)來實現(xiàn)的。2、機器人

6、小車的避障功能避障采取了兩種方案,一種是紅外避障,另一種是觸須避障。a、紅外避障要想讓紅外接收裝置最大范圍地接收到反射回來的信號,就一定要調(diào)整探頭和接收裝置的角度問題,盡量讓它們工作在同一條直線上。有兩種方法可以控制紅外的探測范圍,一種是軟件方法,一種是硬件方法。軟件方法是通過程序修改紅外的發(fā)射頻率,從而達到控制探測范圍的效果,硬件方法是在紅外發(fā)射裝置上接上一個電阻,便會減小紅外探測范圍,電阻越大,紅外探測也就越小。紅外探測電路如圖5所示:圖5例小車左紅外探測如程序二:程序二:#include#includeint P1_2state(void)return (P1&0x04)?1:0;int

7、 main(void)int counter;int irDetectLeft;uart_Init();printf(Program Running!n);while(1)for(counter=0;counter38;counter+)P1_3=1; delay_nus(13);P1_3=0; delay_nus(13); irDetectLeft=P1_2state();printf(irDetectLeft=%dn,irDetectLeft);delay_nms(100);b、觸須探測:觸須也是相當(dāng)于一個開關(guān)作用,當(dāng)遇到障礙物變形后,便會觸碰到觸須附近的彈片,這樣就相當(dāng)于形狀閉合,電路接

8、通后便會送出一個信號到我們小車上的單片機上,單片機經(jīng)過處理后,送出一個信號到伺服電機,告訴前方有障礙物,需要轉(zhuǎn)彎,這樣就完成了小車避障的功能。觸須探測電路如圖6: 圖 6觸須探測如程序三:程序三:#include#includeint P1_4state(void)/獲取P1_4的狀態(tài)return (P1&0x10)?1:0;int P2_3state(void)/獲取P2_3的狀態(tài)return (P2&0x08)?1:0;int main(void)uart_Init();printf(WHISKER STARTESn);while(1)printf(右邊胡須的狀態(tài):%d ,P1_4stat

9、e();printf(左邊胡須的狀態(tài):%dn,P2_3state();delay_nms(150); 3、小車尋軌軌道是用黑色絕緣在白色紙板上做成的一個U字型軌道。利用紅外識別軌道,紅外遇到白紙被反射,遇到黑色軌道就被吸收。在小車的前端左右兩邊分別有一個紅外探測器,當(dāng)小車的紅外接收裝置接收到反射回來的信號時,小車就直走,當(dāng)紅外接收裝置沒有接收到信號時,小車就轉(zhuǎn)彎,左邊接收到就左轉(zhuǎn)彎,右邊接收到就右轉(zhuǎn)彎。這樣就可以讓小車尋著軌道行走了。軌道如圖7所示: 圖 7尋軌如程序四:程序四:#include #include #define LeftIR P1_2 /左邊紅外接受連接到P1_2 #defi

10、ne RightIR P3_5 /右邊紅外接收連接到P3_5#define LeftLaunch P1_3 /左邊紅外發(fā)射連接到P1_3#define RightLaunch P3_6 /右邊紅外發(fā)射連接到P3_6#define Kpl 70#define Kpr -70#define SetPoint 3#define CenterPulse 1500 unsigned int time;int leftdistance,rightdistance;/左邊和右邊的距離int delayCount,distanceLeft,distanceRight,irDetectLeft,irDetect

11、Right;unsigned int frequency5=29370,31230,33050,35700,38460;void timer_init(void)IE=0x82; /開總中斷EA,允許定時器0中斷ET0 TMOD |= 0X01;/定時器0工作在模式1:16位定時器模式void FreqOut(unsigned int Freq)time = 256 - (50000/Freq); TH0 = 0XFF ; TL0 = time ; TR0 = 1; delay_nus(800); TR0 = 0;void Timer0_Interrupt(void) interrupt 1L

12、eftLaunch = LeftLaunch; RightLaunch= RightLaunch; TH0 = 0XFF; TL0 = time;void Get_lr_Distances()unsigned char count; leftdistance = 0; /初始化左邊的距離 rightdistance = 0; /初始化右邊的距離 for(count = 0;count5;count+) FreqOut(frequencycount); irDetectRight = RightIR; irDetectLeft = LeftIR; if (irDetectLeft = 1) le

13、ftdistance+; if (irDetectRight = 1) rightdistance+; void Send_Pulse(unsigned int pulseLeft,unsigned int pulseRight)P1_1=1; delay_nus(pulseLeft); P1_1=0; P1_0=1; delay_nus(pulseRight); P1_0=0; delay_nms(18);int main(void)unsigned int pulseLeft,pulseRight; uart_Init(); timer_init(); /printf(Progam Run

14、ning!n); /printf(FREQENCY ETECTEDn); while(1) Get_lr_Distances(); pulseLeft=(SetPoint-leftdistance)*Kpl+CenterPulse; pulseRight=(SetPoint-rightdistance)*Kpr+CenterPulse; printf(distanceLeft=%d distanceRight=%dn, leftdistance, rightdistance); Send_Pulse(pulseLeft,pulseRight); 4、LCD顯示功能這一功能是為了讓小車更加的智能

15、化。具體的功能是:顯示小車動作的命令,例如:小車要左轉(zhuǎn)彎,LCD就顯示turn left, 右轉(zhuǎn)彎顯示turn right 前進顯示forward.LCD顯示有如程序五:程序五:#include #include #include void Forward(void)int i; for(i=1;i=65;i+)P1_1=1;delay_nus(1700); P1_1=0;P1_0=1;delay_nus(1300);P1_0=0;delay_nms(20);void Left_Turn(void)int i; for(i=1;i=26;i+)P1_1=1;delay_nus(1300); P

16、1_1=0;P1_0=1;delay_nus(1300);P1_0=0;delay_nms(20);void Right_Turn(void)int i; for(i=1;i=26;i+)P1_1=1;delay_nus(1700); P1_1=0;P1_0=1;delay_nus(1700);P1_0=0;delay_nms(20);void Backward(void)int i; for(i=1;i=65;i+)P1_1=1;delay_nus(1300); P1_1=0;P1_0=1;delay_nus(1700);P1_0=0;delay_nms(20);int main(void)

17、char Navigation10=F,L,F,F,R,B,L,B,B,Q;int address=0;LCM_Init();while(Navigationaddress!=Q)switch(Navigationaddress)case F:Forward(); Display_List_Char(0,0,case:F); Display_List_Char(1,0,Forward ); delay_nms(500); break;case L:Left_Turn(); Display_List_Char(0,0,case:L); Display_List_Char(1,0,Turn Lef

18、t ); delay_nms(500); break;case R:Right_Turn(); Display_List_Char(0,0,case:R); Display_List_Char(1,0,Turn Right); delay_nms(500); break;case B:Backward(); Display_List_Char(0,0,case:B); Display_List_Char(1,0,Backward ); delay_nms(500); break;address+;while(1);LCD顯示器引腳說明如表一所示:編 號符 號引腳說明編 號符 號引腳說明1GND電源地9D2雙向數(shù)據(jù)口2Vcc電源正

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論