1347-基于單片機的數控車床XY工作臺與控制系統(tǒng)設計
1347-基于單片機的數控車床XY工作臺與控制系統(tǒng)設計,基于,單片機,數控車床,xy,工作臺,控制系統(tǒng),設計
湘潭大學興湘學院畢業(yè)論文(設計)任務書論文(設計)題目:基于單片機的數控車床 XY 工作臺與控制系統(tǒng)設計 學號: 2006183819 姓名: 蔣迎龍 專業(yè):機械設計制造及其自動化 指導教師: 系主任: 一、主要內容及基本要求 1、設計基于單片機的數控車床 XY 工作臺與控制系統(tǒng),定位精度:0.01mm,要求能實現工作臺 X 和 Y 方向的運動以及直線和圓弧插補等基本控制功能。 2、機械結構圖多張,其中裝配圖 A0 圖紙 1 張。 3、控制電路圖一張。 4、繪制單片機控制原理圖并編寫單片機控制程序,要求邏輯清晰,簡單明了,可讀性強。 5、說明書一份,要求條例性強,語句通順,無錯別字,不少于 25 頁。 6、英文文獻翻譯一份,不少于 3000 字。 二、重點研究的問題1、數控裝置總體方案的設計。 2、機械部分的設計。 3、數控系統(tǒng)的設計。 三、進度安排序號 各階段完成的內容 完成時間1 查閱資料、調研 1-3 周2 開題報告、制訂設計方案 4 周3 機械設計 5-7 周4 電路設計、編寫程序 8-10 周5 翻譯 11 周6 撰寫論文 11-13 周7 修改,寫出正式稿 14 周8 答辯 15 周四、應收集的資料及主要參考文獻1濮良貴,紀名剛機械設計M北京:高等教育出版社,2005 2成大先機械設計手冊M北京:化學工業(yè)出版社,1992 3徐元昌數控技術M北京:中國輕工業(yè)出版社,2004 4文懷興,廈田數控機床系統(tǒng)設計M北京:化學工業(yè)出版社,2005 5 鄭堤,唐可洪機電一體化設計基礎M北京:機械工業(yè)出版社,1997 6汪道輝.單片機系統(tǒng)設計與實踐M.北京:電子工業(yè)出版社,2006. 單片機單片機即單片微型計算機,是把中央處理器、存儲器、定時/計數器、輸入輸出接口都集成在一塊集成電路芯片上的微型計算機。與應用在個人電腦中的通用型微處理器相比,它更強調自供應(不用外接硬件)和節(jié)約成本。它的最大優(yōu)點是體積小,可放在儀表內部,但存儲量小,輸入輸出接口簡單,功能較低。由于其發(fā)展非常迅速,舊的單片機的定義已不能滿足,所以在很多應用場合被稱為范圍更廣的微控制器,但是目前在中國大陸仍多沿用“單片機”的稱呼。絕大多數現在的單片機都是基于馮諾伊曼結構的,這種結構清楚地定義了嵌入式系統(tǒng)所必需的四個基本部分:一個中央處理器核心,程序存儲器(只讀存儲器或者閃存) 、數據存儲器(隨機存儲器) ,一個或者更多的定時/計時器,還有用來與外圍設備以及擴展資源進行通信的輸入/ 輸出端口所有這些都被集成在單個集成電路芯片上。說單片機與通用型中央處理單元芯片不同是因為前者一般很容易配合最小型的外部支持芯片制成工作計算機。這樣就可以很容易的把單片機系統(tǒng)植入裝置內部來控制裝置了。近年來為了在指令和數據上使用不同的字寬,并提高處理器流水線速度,哈佛結構在微控制器和 DSP 也逐漸得到了廣泛的應用。 傳統(tǒng)的微處理器是不允許這么做的。它要完成單片機的工作,就必須連接一些其他芯片。比如說,因為片上沒有數據存儲器,就必須要添加一些 RAM的存儲芯片,雖然所添加存儲器的容量很靈活,但是至少還是要添加,另外還需要添加很多連線來傳遞芯片之間的數據。 比如,一個典型的微控制器只需要一個時鐘發(fā)生器和很少的 RAM 和 ROM(或者 EPROM, E2PROM)就可以在軟件和晶振下工作了。同時,微控制器具有豐富的輸入輸出設備,像是模擬數字轉換(ADC),定時器,串口或者其他串行通訊接口(比如 I2C,串行外圍接口(SPI),控制器局域網)。通常,這些繼承在內部的設備可以通過特殊的指令來操作。 一些現代的微控制器支持一些內建的高級編程語言,比如 BASIC 語言。早期的單片機都是 8 位或 4 位的。其中最成功的是 INTEL 的 8031,因為簡單可靠而性能不錯獲得了很大的好評。此后在 8031 上發(fā)展出了 MCS51 系列單片機系統(tǒng)?;谶@一系統(tǒng)的單片機系統(tǒng)直到現在還在廣泛使用。隨著工業(yè)控制領域要求的提高,開始出現了 16 位單片機,但因為性價比不理想并未得到很廣泛的應用。90 年代后隨著消費電子產品大發(fā)展,單片機技術得到了巨大的提高。隨著 INTEL i960 系列特別是后來的 ARM 系列的廣泛應用,32 位單片機迅速取代 16 位單片機的高端地位,并且進入主流市場。而傳統(tǒng)的 8 位單片機的性能也得到了飛速提高,處理能力比起 80 年代提高了數百倍。目前,高端的 32位單片機主頻已經超過 300MHz,性能直追 90 年代中期的專用處理器,而普通的型號出廠價格跌落至 1 美元,最高端的型號也只有 10 美元。當代單片機系統(tǒng)已經不再只在裸機環(huán)境下開發(fā)和使用,大量專用的嵌入式操作系統(tǒng)被廣泛應用在全系列的單片機上。而在作為掌上電腦和手機核心處理的高端單片機甚至可以直接使用專用的 Windows 和 Linux 操作系統(tǒng)。單片機比專用處理器最適合應用于嵌入式系統(tǒng),因此它得到了最多的應用。事實上單片機是世界上數量最多的計算機。現代人類生活中所用的幾乎每件電子和機械產品中都會集成有單片機。手機、電話、計算器、家用電器、電子玩具、掌上電腦以及鼠標等電腦配件中都配有 1-2 部單片機。而個人電腦中也會有為數不少的單片機在工作。汽車上一般配備 40 多部單片機,復雜的工業(yè)控制系統(tǒng)上甚至可能有數百臺單片機在同時工作!單片機的數量不僅遠超過 PC 機和其他計算的綜合,甚至比人類的數量還要多。單片機學習應中的五大重要部分:一、總線:我們知道,一個電路總是由元器件通過電線連接而成的,在模擬電路中,連線并不成為一個問題,因為各器件間一般是串行關系,各器件之間的連線并不很多,但計算機電路卻不一樣,它是以微處理器為核心,各器件都要與微處理器相連,各器件之間的工作必須相互協(xié)調,所以就需要的連線就很多了,如果仍如同模擬電路一樣,在各微處理器和各器件間單獨連線,則線的數量將多得驚人,所以在微處理機中引入了總線的概念,各個器件共同享用連線,所有器件的 8 根數據線全部接到 8 根公用的線上,即相當于各個器件并聯(lián)起來,但僅這樣還不行,如果有兩個器件同時送出數據,一個為 0,一個為1,那么,接收方接收到的究竟是什么呢?這種情況是不允許的,所以要通過控制線進行控制,使器件分時工作,任何時候只能有一個器件發(fā)送數據(可以有多個器件同時接收)。器件的數據線也就被稱為數據總線,器件所有的控制線被稱為控制總線。在單片機內部或者外部存儲器及其它器件中有存儲單元,這些存儲單元要被分配地址,才能使用,分配地址當然也是以電信號的形式給出的,由于存儲單元比較多,所以,用于地址分配的線也較多,這些線被稱為地址總線。二、數據、地址、指令:之所以將這三者放在一起,是因為這三者的本質都是一樣的數字,或者說都是一串0和1組成的序列。換言之,地址、指令也都是數據。指令:由單片機芯片的設計者規(guī)定的一種數字,它與我們常用的指令助記符有著嚴格的一一對應關系,不可以由單片機的開發(fā)者更改。地址:是尋找單片機內部、外部的存儲單元、輸入輸出口的依據,內部單元的地址值已由芯片設計者規(guī)定好,不可更改,外部的單元可以由單片機開發(fā)者自行決定,但有一些地址單元是一定要有的(詳見程序的執(zhí)行過程)。數據:這是由微處理機處理的對象,在各種不同的應用電路中各不相同,一般而言,被處理的數據可能有這么幾種情況: 1、地址(如 MOV DPTR,#1000H),即地址 1000H 送入 DPTR。 2、方式字或控制字(如 MOV TMOD,#3 ),3 即是控制字。 3、常數(如 MOV TH0,#10H)10H 即定時常數。 4、實際輸出值(如 P1 口接彩燈,要燈全亮,則執(zhí)行指令:MOV P1, #0FFH,要燈全暗,則執(zhí)行指令:MOV P1,#00H)這里 0FFH 和 00H都是實際輸出值。又如用于 LED 的字形碼,也是實際輸出的值。 理解了地址、指令的本質,就不難理解程序運行過程中為什么會跑飛,會把數據當成指令來執(zhí)行了。三、P0 口、P2 口和 P3 的第二功能用法:初學時往往對 P0 口、P2 口和 P3口的第二功能用法迷惑不解,認為第二功能和原功能之間要有一個切換的過程,或者說要有一條指令,事實上,各端口的第二功能完全是自動的,不需要用指令來轉換。如 P3.6、P3.7 分別是 WR、RD 信號,當微片理機外接 RAM 或有外部 I/O 口時,它們被用作第二功能,不能作為通用 I/O 口使用,只要一微處理機一執(zhí)行到 MOVX 指令,就會有相應的信號從 P3.6 或 P3.7 送出,不需要事先用指令說明。事實上不能作為通用 I/O 口使用也并不是不能而是(使用者)不會將其作為通用 I/O 口使用。你完全可以在指令中按排一條 SETB P3.7 的指令,并且當單片機執(zhí)行到這條指令時,也會使 P3.7 變?yōu)楦唠娖?,但使用者不會這么去做,因為這通常這會導致系統(tǒng)的崩潰。四、程序的執(zhí)行過程: 單片機在通電復位后 8051 內的程序計數器(PC )中的值為0000 ,所以程序總是從0000 單元開始執(zhí)行,也就是說:在系統(tǒng)的ROM 中一定要存在0000這個單元,并且在0000單元中存放的一定是一條指令。五、堆棧:堆棧是一個區(qū)域,是用來存放數據的,這個區(qū)域本身沒有任何特殊之處,就是內部 RAM 的一部份,特殊的是它存放和取用數據的方式,即所謂的 先進后出,后進先出,并且堆棧有特殊的數據傳輸指令,即PUSH和POP,有一個特殊的專為其服務的單元,即堆棧指針 SP,每當執(zhí)一次 PUSH指令時,SP 就(在原值的基礎上)自動加 1,每當執(zhí)行一次 POP 指令,SP 就(在原值的基礎上)自動減 1。由于 SP 中的值可以用指令加以改變,所以只要在程序開始階段更改了 SP 的值,就可以把堆棧設置在規(guī)定的內存單元中,如在程序開始時,用一條 MOV SP,#5FH 指令,就時把堆棧設置在從內存單元60H 開始的單元中。一般程序的開頭總有這么一條設置堆棧指針的指令,因為開機時,SP 的初始值為 07H,這樣就使堆棧從 08H 單元開始往后,而 08H 到1FH 這個區(qū)域正是 8031 的第二、三、四工作寄存器區(qū),經常要被使用,這會造成數據的混亂。不同作者編寫程序時,初始化堆棧指令也不完全相同,這是作者的習慣問題。當設置好堆棧區(qū)后,并不意味著該區(qū)域成為一種專用內存,它還是可以象普通內存區(qū)域一樣使用,只是一般情況下編程者不會把它當成普通內存用。Single Chip Microcomputer A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). The majority of computer systems in use today are embedded in other machinery, such as telephones, clocks, appliances, vehicles, and infrastructure. An embedded system usually has minimal requirements for memory and program length and may require simple but unusual input/output systems. For example, most embedded systems lack keyboards, screens, disks, printers, or other recognizable I/O devices of a personal computer. They may control electric motors, relays or voltages, and read switches, variable resistors or other electronic devices. Often, the only I/O device readable by a human is a single light-emitting diode, and severe cost or power constraints can even eliminate that. In contrast to general-purpose CPUs, microcontrollers do not have an address bus or a data bus, because they integrate all the RAM and non-volatile memory on the same chip as the CPU. Because they need fewer pins, the chip can be placed in a much smaller, cheaper package. Integrating the memory and other peripherals on a single chip and testing them as a unit increases the cost of that chip, but often results in decreased net cost of the embedded system as a whole. (Even if the cost of a CPU that has integrated peripherals is slightly more than the cost of a CPU + external peripherals, having fewer chips typically allows a smaller and cheaper circuit board, and reduces the labor required to assemble and test the circuit board). This trend leads to design. A microcontroller is a single integrated circuit, commonly with the following features: central processing unit - ranging from small and simple 4-bit processors to sophisticated 32- or 64-bit processors input/output interfaces such as serial ports (UARTs) other serial communications interfaces like IC, Serial Peripheral Interface and Controller Area Network for system interconnect peripherals such as timers and watchdog RAM for data storage ROM, EPROM, EEPROM or Flash memory for program storage clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit many include analog-to-digital converters This integration drastically reduces the number of chips and the amount of wiring and PCB space that would be needed to produce equivalent systems using separate chips and have proved to be highly popular in embedded systems since their introduction in the 1970s. Some microcontrollers can afford to use a Harvard architecture: separate memory buses for instructions and data, allowing accesses to take place concurrently. The single slice of the earlier period all of machines are 8 or 4.Among them, the INTEL is most successful of 8031, because of in brief dependable but the function was quite good to acquire very big good opinion.Henceforth at 8031 up developed MCS51 serieses a single slice machine system.According to the single slice of this system machine system is still in the extensive usage till now.Because the industry controls the exaltation ofwith realm request, starting appearing 16 single slice machine, but because sex price wanted to dont get a very extensive application than the disregard.Develop greatly along with the consumption electronics product after 90s, the single slice machine technique got a huge exaltation.Along with the extensive application of INTEL i 960 serieses especially later ARM series, the 32 single slice machine replaces 16 single slice the high level position of the machine quickly, and gets into an essential market.And traditional of 8 single slice the function of the machine also got to fly to raise soon, handling an ability to compare with to raise few a hundredfolds in 80s.Currently, 32 single slice of the high level with main machine already over 300 MHzs, the function keeps appropriation processor of making track for the mid 90s, and the common model number factory price drop into to USD 1, tallest carry of model number also only USD 10.The contemporary and single slice machine system has already no longer developed and used just under the naked machine environment, the in great quantities appropriative built-in operate system is applied extensively in the whole serieseses of the single slice is on board.But Be ising the high level of handheld PC and cellular phone core processing single slice the machine even can use appropriative Windows and the Linux operate system directly. Single slice the machine ratio appropriation processor is the most suitable to match to apply in the built-in system, so it got the most applications.In fact the single slice machine is an amount the most calculators are in the world.The modern mankind are living medium use of.assemble in almost each electronics and machine product have a single slice machine.All have 1-2 single slice machine in the computer accessorieses such as cellular phone, telephone, calculator, home appliances, electronics toy, handheld PC and mouse etc.And personal computer in would also capable number not a few single slice the machine be working.Provide with more than 40 departments a single slice machine generally on the car, complicated industrys controling the top of the system even may has single several hundred pedestalses slices machine to work in the meantime!Single slice the amount of the machine not only far above the PC machine and other calculations of comprehensive, even than the mankinds amount still want have another Singlechip study should be an important part in the five: First, the bus: we know that a circuit is always from the components through wires connected, and in analog circuits, the connection does not become a problem, because the devices are generally serial inter-relationship between the various devices connection is not much, but not the same as computer circuits, which is based on the microprocessor as the core, the device must be connected with the microprocessor, the device must be between the mutual coordination and so on need to connect on a lot of If still the same as analog circuits, in the microprocessor and a separate connection between the devices, the quantity line will be many alarmingly so in the microprocessor introduced the concept of bus, all devices share the connection All devices of all eight data lines from eight public online, which is equivalent to all devices in parallel, but only this is not enough, if there is two devices send data simultaneously, a 0, a 1, then , the receiving party received what is it? This situation is not allowed, so to pass the line of control to control the device time job, any time there can be only one device to send data (which may have multiple devices simultaneously receiving). Devices data lines will be referred to as data bus, all the line of control devices known as control bus. Singlechip at internal or external memory and other devices have memory cells, these memory cells to be assigned addresses to use, the allocation of addresses is of course to give the form of electrical signals, and because memory cells are more so for address the allocation of more lines, these lines were known as the address bus. Second, data, address, command: The reason why these three together, because these three are the essence is the same - figure, or are a string of0 and1, composed of sequence . In other words, addresses, instructions are also data. Command: from single-chip chip designer provides a figure, it is consistent with our mnemonic commonly used commands have a strict one-to-one relationship, not by the developer to change the MCU. Address: Singlechip are looking for internal, external storage units, input and output port based on the value of the internal units address has been provided for the chip designers, and can not be changed, the external unit can be single-chip developers to decide, but Yes there is some address must be the unit (see procedures for the implementation process). Data: This is the object of treatment by the microprocessor, in a variety of different applications in different circuits, in general, the data may be processed so have several situations: 1 .address (such as MOV DPTR, # 1000H), that address 1000h into the DPTR. 2. the way the words or control characters (such as MOV TMOD, # 3), 3 which controls the characters. 3. constants (such as MOV TH0, # 10H) 10H that is constant from time to time. 4 .The actual output value (such as the mouth then P1 lantern light to light the whole, then the implementation of instruction: MOV P1, # 0FFH, to light the whole dark, then the implementation of instruction: MOV P1, # 00H) and 00H are here 0FFH actual output value. Another example is the font code for the LED, is the actual output value. Understanding of the address, the nature of instructions, running is not difficult to understand why the process of running fly, the data will be implemented as instructions. Three, P0 mouth, P2 and P3 the mouth of the second function Usage: often on P0 beginner I, P2 and P3 mouth I use the second function puzzled think the second function and the original features have a switch between the process, or that there have to be a directive, in fact, the ports second feature is completely automatic, no need to use command to convert. Such as P3.6, P3.7, respectively, are WR, RD signal, when the micro-chip RAM or external justifications machine has an external I / O port, they were used as the second function, can not be used as general-purpose I / O port to use, as long as one microprocessor implementation of the MOVX instruction 1, there will be a corresponding signal sent from the P3.6 or P3.7, no prior use instructions indicate. In fact can not be used as general-purpose I / O port use is not should not but (user) not as a general-purpose I / O port to use. At command you can arrange a Medium of Instruction SETB P3.7, and when the single-chip implementation of this Article directions, P3.7 will also become high, but users will not do so, because This usually will lead to the collapse of the system. Four, the program implementation process: single-chip power-on reset in 8051 after the program counter (PC) in the value of0000 , so the procedure always0000 unit begin implementation of, that is to say: the systems ROM must exist in the0000 in this unit, and0000 in the storage unit must be a command. Five, the stack: the stack is a region, are used to store data, the region does not have any unique position, that is a part of internal RAM, special is its data storage and access methods, namely, the so-called advanced after that last-in first-out , and the stack has a special data transmission command, ie PUSH and POP , there is a special unit specifically for its services, that is, the stack pointer SP, when they first PUSH instruction, the SP on (at the original value of the foundation on) automatically add one, whenever the implementation of a POP instruction, SP on (at the original value basis) minus one automatically. Because of the value of SP can be used to change directions, so as long as the stage at the beginning of the proceedings to change the value of the SP, you can put the stack set up the required memory units, such as at the beginning of the proceedings, with a MOV SP, # 5FH instructions when put on the stack from the memory modules installed in the unit 60H start. The normal procedure at the beginning of the total that there is a stack pointer of the instruction set, because at startup, SP initial value of 07H, thus the stack from the beginning the next unit 08h, and 08h to 1Fh in the region 8031 is the second, Three, four working registers area, often used, this will lead to data chaos. The author has prepared a different program, not exactly the same instructions to initialize the stack, which is the authors customary problem. When set up the stack area, does not mean that the region as a dedicated memory, it can be as common as the use of memory region, but under normal circumstances programming will not put it as an ordinary memory use.
收藏