【正文】
,積分作用越弱,反之則越強(qiáng)。PID控制器的特點(diǎn)是只能對(duì)單變量進(jìn)行控制,所以選擇主動(dòng)裝置——旋轉(zhuǎn)臂的角度輸出作為PID控制器的輸入量。當(dāng)擺桿能夠擺動(dòng)接近于180度的位置時(shí),希望擺桿能夠趨向平衡位置(180度位置),并動(dòng)態(tài)保持平衡。 擺桿狀態(tài)檢測(cè)的計(jì)算 擺桿擺起的算法 圖32 倒立擺的系統(tǒng)結(jié)構(gòu) 該圖為簡(jiǎn)化后的力學(xué)模型,由一個(gè)水平旋轉(zhuǎn)臂和擺桿組成,在擺桿前,擺桿處于下垂靜止?fàn)顟B(tài),正常工作狀態(tài)時(shí),擺桿平衡點(diǎn)為=0,擺桿的保持在一定范圍內(nèi)。 擺桿保持平衡的算法設(shè)擺桿在處的速度為v1,在平衡處的速度為v2,F(xiàn)為施加的外力,L為擺桿距離旋轉(zhuǎn)臂的垂直距離,分別為擺桿的角度和角速度。其關(guān)系如下圖: STC89C52芯片電源模塊復(fù)位時(shí)鐘電路模塊按鍵模塊1602液晶顯示屏模塊步進(jìn)電機(jī)模塊角度檢測(cè)模塊 圖41 控制器模塊設(shè)計(jì)控制模塊的電路圖: 圖42 控制模塊的電路圖其中STC89C52引腳功能:STC89C52具體介紹如下: ① 主電源引腳(2根) VCC(Pin40):電源輸入,接+5V電源 GND(Pin20):接地線 ②外接晶振引腳(2根) XTAL1(Pin19):片內(nèi)振蕩電路的輸入端 XTAL2(Pin20):片內(nèi)振蕩電路的輸出端 ③控制引腳(4根) RST/VPP(Pin9):復(fù)位引腳,引腳上出現(xiàn)2個(gè)機(jī)器周期的高電平將使單片機(jī)復(fù)位。脈沖有脈沖時(shí)工作,高電平有效;無(wú)脈沖時(shí)鎖定電機(jī)并自動(dòng)半流方向高電平輸入或懸空時(shí)正轉(zhuǎn);低電平輸入時(shí)反轉(zhuǎn)脫機(jī)高電平輸入或者懸空時(shí)正常工作;低電平時(shí)脫機(jī) 表42 共陽(yáng)極控制方法 該電機(jī)模塊分別設(shè)計(jì)電機(jī)驅(qū)動(dòng)模塊的細(xì)分和衰減、電流設(shè)置表43 細(xì)分設(shè)置細(xì)分SW4SW31OFFOFF2OFFON16ONOFF8ONON表44 電流設(shè)置電流SW6SW53AOFFOFFOFFONONOFFONON表45 衰減設(shè)置衰減SW2SW1低OFFOFF慢OFFON中ONOFF快ONON 圖44 電機(jī)驅(qū)動(dòng)模塊實(shí)物圖 步進(jìn)電機(jī)模塊 步進(jìn)電機(jī)模塊中選用57BGY25080型號(hào)的步進(jìn)電機(jī),驅(qū)動(dòng)方式為恒流斬波驅(qū)動(dòng),勵(lì)磁方式為兩相八拍運(yùn)行,將其安裝在旋轉(zhuǎn)臂上,其結(jié)構(gòu)如下: 圖45 步進(jìn)電機(jī)模塊原理圖其中驅(qū)動(dòng)器ZD6560V4中的A+,A,B+,B與型號(hào)為57BYG25080電機(jī)相連接,單片機(jī)通過(guò)控制電機(jī)驅(qū)動(dòng)器的脈沖+,脈沖來(lái)控制電機(jī)的正反轉(zhuǎn),實(shí)現(xiàn)往復(fù)擺動(dòng)動(dòng)作。第5腳:R/W為讀寫(xiě)信號(hào)線,高電平時(shí)進(jìn)行讀操作,低電平時(shí)進(jìn)行寫(xiě)操作。RS、R/W、E的信號(hào)真值表如表 46所示:表46 RS、R/W、E的信號(hào)真值表RSR/WE功能00下降沿寫(xiě)指令代碼01高電平讀忙標(biāo)志和AC值10下降沿寫(xiě)數(shù)據(jù)11高電平讀數(shù)據(jù) 時(shí)鐘振蕩電路 STC89C52中有一個(gè)用于構(gòu)成內(nèi)部振蕩器的高增益反向放大器,引腳XTAL1和XTAL2分別是該放大器的輸入端和輸出端。對(duì)外接電容CC2雖然沒(méi)有十分嚴(yán)格的要求,但電容容量的大小會(huì)輕微影響振蕩頻率的高低、振蕩器工作的穩(wěn)定性、起振的難易程度及溫度穩(wěn)定性。一個(gè)單片機(jī)系統(tǒng)能否正常工作,首先要檢查是否能復(fù)位成功。在通電瞬間,電容C通過(guò)電阻R充電,RST端出現(xiàn)正脈沖,用以復(fù)位。圖411 復(fù)位電路 電源模塊 供電電源采用100W 24V開(kāi)關(guān)穩(wěn)壓電源,其中端子定義為 表47 各端子表示含義腳位號(hào)功能腳位號(hào)功能1AC/L5DC OUTPUT V2AC/N7DC OUTPUT +V3FG(接地)單組輸出:功率100W輸入電壓:110/220VAC輸出電壓:548VDC 圖4 12 電源模塊第5章 軟件設(shè)計(jì) 調(diào)試軟件Keil C51簡(jiǎn)介Keil C51是美國(guó)Keil Software公司出品的51系列兼容單片機(jī)C語(yǔ)言軟件開(kāi)發(fā)系統(tǒng),與匯編相比,C語(yǔ)言在功能上、結(jié)構(gòu)性、可讀性、可維護(hù)性上有明顯的優(yōu)勢(shì),因而易學(xué)易用。KEILC51標(biāo)準(zhǔn)C編譯器為8051微控制器的軟件開(kāi)發(fā)提供了C語(yǔ)言環(huán)境,同時(shí)保留了匯編代碼高效,快速的特點(diǎn)。1)利用Kile C51進(jìn)行軟件仿真,主要內(nèi)容包括程序的編輯、編譯、連接。 4)根據(jù)電機(jī)旋轉(zhuǎn)和液晶屏顯示實(shí)際情況,修改程序,下載,上電觀察。當(dāng)按鍵1按下時(shí),擺桿就會(huì)在電機(jī)的帶動(dòng)下做往復(fù)擺動(dòng)、擺桿在外力撤銷(xiāo)后保持倒立平衡狀態(tài)。當(dāng)按鍵3按下時(shí),外力拉起擺桿至接近至165176。如果按鍵1按下,則驅(qū)動(dòng)電機(jī)使擺桿擺動(dòng),如果按鍵沒(méi)有按下,則繼續(xù)等待,一直到按鍵按下。則用電機(jī)調(diào)節(jié)使其達(dá)到要求,如果達(dá)到了,則保持倒立平衡,并維持一段時(shí)間。和擺桿完成圓周運(yùn)動(dòng)所用的時(shí)間。用秒表記錄恢復(fù)到倒立擺狀態(tài)所用的時(shí)間和旋轉(zhuǎn)臂轉(zhuǎn)過(guò)的最大角度。 總結(jié)與展望本論文研究基于單片機(jī)控制的旋轉(zhuǎn)倒立擺系統(tǒng)。本文先通過(guò)對(duì)旋轉(zhuǎn)倒立擺的概念、產(chǎn)生及其意義進(jìn)行了闡述,然后說(shuō)明其組成、工作原理和實(shí)現(xiàn)方法,進(jìn)而采用以STC89C52芯片為主的系統(tǒng)和一些外圍電路,如電機(jī)驅(qū)動(dòng)電路、檢測(cè)電路、液晶LCD顯示電路等搭成簡(jiǎn)單系統(tǒng)來(lái)控制倒立擺?;仡欉@個(gè)設(shè)計(jì)過(guò)程,使我受益匪淺。也為我今后的工作打下了堅(jiān)實(shí)的基礎(chǔ)。指導(dǎo)老師的淵博知識(shí)、嚴(yán)謹(jǐn)?shù)闹螌W(xué)態(tài)度、求實(shí)樸素的工作生活作風(fēng)、勇于探索和孜孜不倦的敬業(yè)精神,老師精湛的技術(shù)和扎實(shí)的專業(yè)知識(shí),都深深的影響著我,將對(duì)我以后的學(xué)習(xí)、生活和工作大有裨益。 再一次向老師和同學(xué)表示感謝! 附錄A:原理圖 附錄B:外文文獻(xiàn)DESIGN AND RESEARCH OF INVERTED PENDELUMABSTRACTInverted Pendulum is a nonlinear, coupling, variable and natural unsteadiness system, which includes robot technology, control theory, puter control and so on. During the control process, pendulum can effectively reflect many pivotal problems such as equanimity, robust, followup and track. Therefore, it is a perfect model used to testing various control theories. The design of controller is a main work of pendulum system. At present, the methods of controller design include: PID control, root locus and frequency respond, statespace method, optimal control theory and so on. The process of a controller design for the firstlevel inverted pendulum system is introduced. In this paper, a PID control and a pole assignment with statespace design are proposed. The Matlab software is used to carring out a program and simulation in the process of the controller design. The Mfile and simulink tool box are applied, and the result shows that these methods are effective. Form this paper, the controller designed by pole assignment with statespace is able to control the angle of pendulum bar and the location of handcart at the same time. The simulation shows that the method of statespace is better than traditional PID control algorithm.Key words: Inverted pendulum。 As a controlled object, it is quite plicated, in and of itself, is a high order time, unstable, multivariable, nonlinear and strong coupling system, only by adopting effective control method can make the stability of [3]. To control the inverted pendulum system, its stable effect is very clear, can be directly through the swing Angle and displacement and stability time measurement, control and be clear at a glance. Theory is the pilot project, the research of inverted pendulum not only has its profound theoretical significance and has important engineering background. From everyday life to meet any of the center of gravity, the pivot of the next control problem, to the space vehicle and all kinds of the stability of servo yuntai, all have great similarity, and the control of the inverted pendulum is control of its stability in practice there are a lot of USES, such as the stability control of offshore drilling platform, the stability control of satellite launcher, rocket attitude control, the plane landed safely, chemical process control belong to this kind of problem. Therefore, the study of mechanism of inverted pendulum is of important theoretical and practical significance, has bee an enduring research subjects in the control theory.2. the main content and the main work done This design to inverted pendulum control system as the research object, using Matlab powerful numerical calculation and digital simulation, plete c