19基于单片机的数控车床XY工作台与控制系统设计
19基于单片机的数控车床XY工作台与控制系统设计,19,基于,单片机,数控车床,xy,工作台,控制系统,设计
湘潭大学兴湘学院毕业论文(设计)任务书论文(设计)题目:基于单片机的数控车床 XY 工作台与控制系统设计 学号: 2006183819 姓名: 蒋迎龙 专业:机械设计制造及其自动化 指导教师: 系主任: 一、主要内容及基本要求 1、设计基于单片机的数控车床 XY 工作台与控制系统,定位精度:0.01mm,要求能实现工作台 X 和 Y 方向的运动以及直线和圆弧插补等基本控制功能。 2、机械结构图多张,其中装配图 A0 图纸 1 张。 3、控制电路图一张。 4、绘制单片机控制原理图并编写单片机控制程序,要求逻辑清晰,简单明了,可读性强。 5、说明书一份,要求条例性强,语句通顺,无错别字,不少于 25 页。 6、英文文献翻译一份,不少于 3000 字。 二、重点研究的问题1、数控装置总体方案的设计。 2、机械部分的设计。 3、数控系统的设计。 三、进度安排序号 各阶段完成的内容 完成时间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北京:化学工业出版社,1992 3徐元昌数控技术M北京:中国轻工业出版社,2004 4文怀兴,厦田数控机床系统设计M北京:化学工业出版社,2005 5 郑堤,唐可洪机电一体化设计基础M北京:机械工业出版社,1997 6汪道辉.单片机系统设计与实践M.北京:电子工业出版社,2006. 湘潭大学兴湘学院毕业设计说明书题 目:基于单片机的数控车床 XY 工作台与控制系统设计 专 业: 机械设计制造及其自动化 学 号: 2006183819 姓 名: 蒋迎龙 指导教师: 刘习文 完成日期: 2010 年 5 月 31 日 湘潭大学兴湘学院目 录摘 要 1第一章 绪论 21.1 数控机床的生产与发展21.2 数控机床的发展趋势21.3 数控机床在先进制造技术中的作用31.4 对我国数控技术及其产业发展的基本估计 31.5 毕业设计的目的、意义31.6 毕业设计的内容4第二章 数控系统总体方案的确定 51.1 系统运动方式的确定 51.2 伺服系统的选择 51.3 计算机系统的选择 51.4 X-Y 工作台的传动方式 5第三章 机械部分设计 71.1 确定系统脉冲当量 71.2 工作台外形尺寸及重量初步估算 71.3 滚动导轨副的计算、选择 81.4 滚珠丝杠计算、选择 91.5 齿轮计算、设计 121.6 步进电机惯性负载的计算以及步进电机的选用13第四章 数控系统硬件电路设计 151.1 数控系统的硬件电路由以下几部分组成151.2 主控制器的选择151.3 存储器扩展电路设计16第五章 系统控制软件的设计 171.1 系统控制功能分析171.2 系统管理程序控制171.3 自动加工程序设计181.4 汇编语言程序设计19第六章 结束语与致谢 25参考资料 26单片机单片机即单片微型计算机,是把中央处理器、存储器、定时/计数器、输入输出接口都集成在一块集成电路芯片上的微型计算机。与应用在个人电脑中的通用型微处理器相比,它更强调自供应(不用外接硬件)和节约成本。它的最大优点是体积小,可放在仪表内部,但存储量小,输入输出接口简单,功能较低。由于其发展非常迅速,旧的单片机的定义已不能满足,所以在很多应用场合被称为范围更广的微控制器,但是目前在中国大陆仍多沿用“单片机”的称呼。绝大多数现在的单片机都是基于冯诺伊曼结构的,这种结构清楚地定义了嵌入式系统所必需的四个基本部分:一个中央处理器核心,程序存储器(只读存储器或者闪存) 、数据存储器(随机存储器) ,一个或者更多的定时/计时器,还有用来与外围设备以及扩展资源进行通信的输入/ 输出端口所有这些都被集成在单个集成电路芯片上。说单片机与通用型中央处理单元芯片不同是因为前者一般很容易配合最小型的外部支持芯片制成工作计算机。这样就可以很容易的把单片机系统植入装置内部来控制装置了。近年来为了在指令和数据上使用不同的字宽,并提高处理器流水线速度,哈佛结构在微控制器和 DSP 也逐渐得到了广泛的应用。 传统的微处理器是不允许这么做的。它要完成单片机的工作,就必须连接一些其他芯片。比如说,因为片上没有数据存储器,就必须要添加一些 RAM的存储芯片,虽然所添加存储器的容量很灵活,但是至少还是要添加,另外还需要添加很多连线来传递芯片之间的数据。 比如,一个典型的微控制器只需要一个时钟发生器和很少的 RAM 和 ROM(或者 EPROM, E2PROM)就可以在软件和晶振下工作了。同时,微控制器具有丰富的输入输出设备,像是模拟数字转换(ADC),定时器,串口或者其他串行通讯接口(比如 I2C,串行外围接口(SPI),控制器局域网)。通常,这些继承在内部的设备可以通过特殊的指令来操作。 一些现代的微控制器支持一些内建的高级编程语言,比如 BASIC 语言。早期的单片机都是 8 位或 4 位的。其中最成功的是 INTEL 的 8031,因为简单可靠而性能不错获得了很大的好评。此后在 8031 上发展出了 MCS51 系列单片机系统。基于这一系统的单片机系统直到现在还在广泛使用。随着工业控制领域要求的提高,开始出现了 16 位单片机,但因为性价比不理想并未得到很广泛的应用。90 年代后随着消费电子产品大发展,单片机技术得到了巨大的提高。随着 INTEL i960 系列特别是后来的 ARM 系列的广泛应用,32 位单片机迅速取代 16 位单片机的高端地位,并且进入主流市场。而传统的 8 位单片机的性能也得到了飞速提高,处理能力比起 80 年代提高了数百倍。目前,高端的 32位单片机主频已经超过 300MHz,性能直追 90 年代中期的专用处理器,而普通的型号出厂价格跌落至 1 美元,最高端的型号也只有 10 美元。当代单片机系统已经不再只在裸机环境下开发和使用,大量专用的嵌入式操作系统被广泛应用在全系列的单片机上。而在作为掌上电脑和手机核心处理的高端单片机甚至可以直接使用专用的 Windows 和 Linux 操作系统。单片机比专用处理器最适合应用于嵌入式系统,因此它得到了最多的应用。事实上单片机是世界上数量最多的计算机。现代人类生活中所用的几乎每件电子和机械产品中都会集成有单片机。手机、电话、计算器、家用电器、电子玩具、掌上电脑以及鼠标等电脑配件中都配有 1-2 部单片机。而个人电脑中也会有为数不少的单片机在工作。汽车上一般配备 40 多部单片机,复杂的工业控制系统上甚至可能有数百台单片机在同时工作!单片机的数量不仅远超过 PC 机和其他计算的综合,甚至比人类的数量还要多。单片机学习应中的五大重要部分:一、总线:我们知道,一个电路总是由元器件通过电线连接而成的,在模拟电路中,连线并不成为一个问题,因为各器件间一般是串行关系,各器件之间的连线并不很多,但计算机电路却不一样,它是以微处理器为核心,各器件都要与微处理器相连,各器件之间的工作必须相互协调,所以就需要的连线就很多了,如果仍如同模拟电路一样,在各微处理器和各器件间单独连线,则线的数量将多得惊人,所以在微处理机中引入了总线的概念,各个器件共同享用连线,所有器件的 8 根数据线全部接到 8 根公用的线上,即相当于各个器件并联起来,但仅这样还不行,如果有两个器件同时送出数据,一个为 0,一个为1,那么,接收方接收到的究竟是什么呢?这种情况是不允许的,所以要通过控制线进行控制,使器件分时工作,任何时候只能有一个器件发送数据(可以有多个器件同时接收)。器件的数据线也就被称为数据总线,器件所有的控制线被称为控制总线。在单片机内部或者外部存储器及其它器件中有存储单元,这些存储单元要被分配地址,才能使用,分配地址当然也是以电信号的形式给出的,由于存储单元比较多,所以,用于地址分配的线也较多,这些线被称为地址总线。二、数据、地址、指令:之所以将这三者放在一起,是因为这三者的本质都是一样的数字,或者说都是一串0和1组成的序列。换言之,地址、指令也都是数据。指令:由单片机芯片的设计者规定的一种数字,它与我们常用的指令助记符有着严格的一一对应关系,不可以由单片机的开发者更改。地址:是寻找单片机内部、外部的存储单元、输入输出口的依据,内部单元的地址值已由芯片设计者规定好,不可更改,外部的单元可以由单片机开发者自行决定,但有一些地址单元是一定要有的(详见程序的执行过程)。数据:这是由微处理机处理的对象,在各种不同的应用电路中各不相同,一般而言,被处理的数据可能有这么几种情况: 1、地址(如 MOV DPTR,#1000H),即地址 1000H 送入 DPTR。 2、方式字或控制字(如 MOV TMOD,#3 ),3 即是控制字。 3、常数(如 MOV TH0,#10H)10H 即定时常数。 4、实际输出值(如 P1 口接彩灯,要灯全亮,则执行指令:MOV P1, #0FFH,要灯全暗,则执行指令:MOV P1,#00H)这里 0FFH 和 00H都是实际输出值。又如用于 LED 的字形码,也是实际输出的值。 理解了地址、指令的本质,就不难理解程序运行过程中为什么会跑飞,会把数据当成指令来执行了。三、P0 口、P2 口和 P3 的第二功能用法:初学时往往对 P0 口、P2 口和 P3口的第二功能用法迷惑不解,认为第二功能和原功能之间要有一个切换的过程,或者说要有一条指令,事实上,各端口的第二功能完全是自动的,不需要用指令来转换。如 P3.6、P3.7 分别是 WR、RD 信号,当微片理机外接 RAM 或有外部 I/O 口时,它们被用作第二功能,不能作为通用 I/O 口使用,只要一微处理机一执行到 MOVX 指令,就会有相应的信号从 P3.6 或 P3.7 送出,不需要事先用指令说明。事实上不能作为通用 I/O 口使用也并不是不能而是(使用者)不会将其作为通用 I/O 口使用。你完全可以在指令中按排一条 SETB P3.7 的指令,并且当单片机执行到这条指令时,也会使 P3.7 变为高电平,但使用者不会这么去做,因为这通常这会导致系统的崩溃。四、程序的执行过程: 单片机在通电复位后 8051 内的程序计数器(PC )中的值为0000 ,所以程序总是从0000 单元开始执行,也就是说:在系统的ROM 中一定要存在0000这个单元,并且在0000单元中存放的一定是一条指令。五、堆栈:堆栈是一个区域,是用来存放数据的,这个区域本身没有任何特殊之处,就是内部 RAM 的一部份,特殊的是它存放和取用数据的方式,即所谓的 先进后出,后进先出,并且堆栈有特殊的数据传输指令,即PUSH和POP,有一个特殊的专为其服务的单元,即堆栈指针 SP,每当执一次 PUSH指令时,SP 就(在原值的基础上)自动加 1,每当执行一次 POP 指令,SP 就(在原值的基础上)自动减 1。由于 SP 中的值可以用指令加以改变,所以只要在程序开始阶段更改了 SP 的值,就可以把堆栈设置在规定的内存单元中,如在程序开始时,用一条 MOV SP,#5FH 指令,就时把堆栈设置在从内存单元60H 开始的单元中。一般程序的开头总有这么一条设置堆栈指针的指令,因为开机时,SP 的初始值为 07H,这样就使堆栈从 08H 单元开始往后,而 08H 到1FH 这个区域正是 8031 的第二、三、四工作寄存器区,经常要被使用,这会造成数据的混乱。不同作者编写程序时,初始化堆栈指令也不完全相同,这是作者的习惯问题。当设置好堆栈区后,并不意味着该区域成为一种专用内存,它还是可以象普通内存区域一样使用,只是一般情况下编程者不会把它当成普通内存用。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.
收藏