《895191577关于单片机的中英翻译.doc》由会员分享,可在线阅读,更多相关《895191577关于单片机的中英翻译.doc(5页珍藏版)》请在三一办公上搜索。
1、微控制器微控制器是一个可编程集成电路(IC),当你开启微控制器时就会看到一系列的命令,这些命令是你事先植入芯片中的。你可以通过改变这些命令做不同的事情(通常称为编程)。为了修改你的命令你需要一个PG320这样的装置,你可以通过PG320从计算机上下载程序到微控制器上。这一章将为你展示一些简单的程序和如何下载。2.0.1 555定时器如何产生脉冲555 定时器是由简单的晶体管组成,作用和触发器一样,它们本身不能定时,当你接上电源它们开始产生脉冲,当你撤掉电源它们就不能产生脉冲,所以对于555定时器本身来说不能产生脉冲。产生脉冲的方法就是用一些元件把555连接在一个电路中(如下面的电路)。这个电路
2、是由一个电容器和一个电阻器构成的。我们可以交换触发器和启动充电电容。电阻器用来控制电容充电的快慢。电阻越大,电容充电时间越长。电路中的电压可以用作输入的另一个触发器,因为起始电压为0时,在第二个开关处不会有任何的反应,但最终由于电容器充电到一定值激活第二个触发器。555工作的原理是当你交换第一个触发器,输出引脚为Vcc(由阳极供应电压),电容器开始充电。当电容器电压达到2/3的Vcc(也就是Vcc*2/3),第二个触发器闭合使输出电压为0伏。555定时器的引出线如下: 详细资料 引脚2(触发器)是脉冲的启动开关。触发器的字符线路告诉我们电压与我们通常所期望的相反。当引脚2接0伏电压,对这个相反
3、行为的专业术语称为“低态有效”。对于IC输入模块看到低态有效行为很平常,因为晶体管电路的转换实质就像我们在LED和晶体管指南看到的一样。引脚6是脉冲的关闭开关。我们把电容器的阳极连接到这个引脚上,电容器的阴极接地。当引脚2(触发器)是Vcc,555定时器电压处于0伏控制引脚7(注意反转电压),当引脚2电压为0伏时555停止控制引脚7,然后电容器开始充电。电容器通过连接在Vcc上的电阻充电,电流开始流入电容器,电容器的电压开始升高。 引脚3是输出(在这里输出实际的脉冲)端。引脚3上起始电压为0,当触发器(引脚2)上电压为0时,555 通过Vcc控制引脚3直到引脚6电压达到Vcc的2/3(也就是V
4、cc*2/3)。然后将引脚3的电压接地,这样你就可以看到一个脉冲(此外注意翻转作用).引脚7上的电压同样也要接地,连接电容器进行地面放电。观看脉冲为了看到脉冲我们用一个LED接在555输出端(引脚3)。当输出端电压为0伏时LED将不工作,当输出端是Vcc时LED将工作。构建电路因为555的放置要穿过电路实验板的中间线路所以一边4个引脚。(为了使它们放在孔中你可能需要把引脚弯曲一点)。直到完成电路后才可以通电。上面的图表指导你怎样将555上面的引脚编号。你可以通过寻找在芯片末端的半个循环发现以脚1。有时候不是半个循环,而是一个点或是很浅的洞。在你开始构建电路之前,用跳线连接红或绿动力行和在电路板
5、另一边的红或绿动力行。然后你会很容易的将电路板两边的Vcc和地线连接在一起(如果电线太短,对于阳极(Vcc)用两个电线接在一起成一排,对于地线用两根电线接在一起成不同的排)。将引脚1接地.将引脚8接到Vcc上.将引脚4接到Vcc上.将LED的阳极接到330欧姆的电阻器上,LED的阴极接地。将330欧姆电阻器的其它接头连接输出端引脚3.将引脚7用一个10K的电阻接到Vcc上(R =10K)。引脚7和6用跨接线连接。引脚6接220F的电容器阳极(C=220F)。(为了使阴极能插进电路实验板你可能需要将阳极(长腿的)弯进或弯出一点。电容器的阴极接地。引脚2用线接出作为触发器。开始把引脚2和Vcc连接
6、起来。现在接电源。LED将被激活停留大约2秒。从Vcc上拔掉连接引脚2的电线,你可以通过用你手指接触连接引脚2的电线或将电线接地或是移开来再一次激活555。(它应该产生大约2秒钟的脉冲)振荡接下来我们将使LED不断的反射而不必触发它。我们将钩住555以便它自己本身可以触发。工作原理就是我们在电容器和放电引脚,引脚7之间加一个电阻。现在,电容器将充电(通过 )当电压达到2/3 Vcc时,把引脚3和引脚7接地。但由于RB电容器不能立即放电,电容器通过RB从充电到放电需要一定的时间,RB的电阻越大时间越长。电容器开始放电的时间也就是LED工作中断的时间。为再一次触发555,我们将引脚6和触发器(引脚
7、2)连接起来。当电容器充电时电容器内的电压越来越低。当电压降到1/3 Vcc时触发器引脚2使引脚3变为Vcc并且通过LED激活555。将引脚7从地面上断开,电容器开始通过RA和RB再次充电。从以前的电路上构建这个电路,做法如下:断开电源。去掉引脚6和引脚7之间的跨接线,用2.2K的电阻来代替(RB=2.2K)用引脚2处的跨接线连接引脚2和引脚6。现在重新连接电源并且LED应该始终闪烁(只要电源是开着的)。用不同阻值的RA和RB做实验看一下LRD闪烁时间长短的变化(你可以改变电容器充放电时间的长短)。Microcontrollers A microcontroller is an integra
8、ted circuit (IC) that is programmable. When you turn on the power to the microcontroller it goes through a series of commands. These commands are put in the chip by you. You can make it do different things by changing the commands (usually called the program). To change the commands you need a devic
9、e like the PG302. The PG302 lets you download the program from your computer to the microcontroller. This chapter will show you some simple programs and how to download those to2.0.1The 555 Timer Creating a Pulse The 555 is made out of simple transistors that are about the same as on / off switches.
10、 They do not have any sense of time. When you apply a voltage they turn on and when you take away the voltage they turn off. So by itself, the 555 can not create a pulse. The way the pulse is created is by using some components in a circuit attached to the 555 (see the circuit below). This circuit i
11、s made of a capacitor and a resistor. We can flip a switch and start charging the capacitor. The resistor is used to control how fast the capacitor charges. The bigger the resistance, the longer it takes to charge the capacitor. The voltage in the capacitor can then be used as an input to another sw
12、itch. Since the voltage starts at 0, nothing happens to the second switch. But eventually the capacitor will charge up to some point where the second switch comes on. The way the 555 timer works is that when you flip the first switch, the Output pin goes to Vcc (the positive power supply voltage) an
13、d starts charging the capacitor. When the capacitor voltage gets to 2/3 Vcc (that is Vcc * 2/3) the second switch turns on which makes the output go to 0 volts. The pinout for the 555 timer is shown below Deep Details Pin 2 (Trigger) is the on switch for the pulse. The line over the word Trigger tel
14、ls us that the voltage levels are the opposite of what you would normally expect. To turn the switch on you apply 0 volts to pin 2. The technical term for this opposite behavior is Active Low. It is common to see this Active Low behavior for IC inputs because of the inverting nature of transistor ci
15、rcuits like we saw in the LED and Transistor Tutorial. Pin 6 is the off switch for the pulse. We connect the positive side of the capacitor to this pin and the negative side of the capacitor to ground. When Pin 2 (Trigger) is at Vcc, the 555 holds Pin 7 at 0 volts (Note the inverted voltage). When P
16、in 2 goes to 0 volts, the 555 stops holding Pin 7 at 0 volts. Then the capacitor starts charging. The capacitor is charged through a resistor connected to Vcc. The current starts flowing into the capacitor, and the voltage in the capacitor starts to increase. Pin 3 is the output (where the actual pu
17、lse comes out). The voltage on this pin starts at 0 volts. When 0 volts is applied to the trigger (Pin 2), the 555 puts out Vcc on Pin 3 and holds it at Vcc until Pin 6 reaches 2/3 of Vcc (that is Vcc * 2/3). Then the 555 pulls the voltage at Pin 3 to ground and you have created a pulse. (Again noti
18、ce the inverting action.) The voltage on Pin 7 is also pulled to ground, connecting the capacitor to ground and discharging it. Seeing the pulse To see the pulse we will use an LED connected to the 555 output, Pin 3. When the output is 0 volts the LED will be off. When the output is Vcc the LED will
19、 be on. Building the Circuit Place the 555 across the middle line of the breadboard so that 4 pins are on one side and 4 pins are on the other side. (You may need to bend the pins in a little so they will go in the holes.) Leave the power disconnected until you finish building the circuit. The diagr
20、am above shows how the pins on the 555 are numbered. You can find pin 1 by looking for the half circle in the end of the chip. Sometimes instead of a half circle, there will be a dot or shallow hole by pin 1. Before you start building the circuit, use jumper wires to connect the red and blue power r
21、ows to the red and blue power rows on the other side of the board. Then you will be able to easily reach Vcc and Ground lines from both sides of the board. (If the wires are too short, use two wires joined together in a row of holes for the positive power (Vcc) and two wires joined together in a dif
22、ferent row of holes for the ground.) Connect Pin 1 to ground. Connect Pin 8 to Vcc. Connect Pin 4 to Vcc. Connect the positive leg of the LED to a 330 ohm resistor and connect the negative end of the LED to ground. Connect the other leg of the 330 ohm resistor to the output, Pin 3. Connect Pin 7 to
23、Vcc with a 10k resistor (RA = 10K). Connect Pin 7 to Pin 6 with a jumper wire. Connect Pin 6 to the positive leg of the 220uF Capacitor (C = 220uF). (You will need to bend the positive (long leg) up and out some so that the negative leg can go in the breadboard. Connect the negative leg of the capac
24、itor to ground. Connect a wire to Pin 2 to use as the trigger. Start with Pin 2 connected to Vcc. Now connect the power. The LED will come on and stay on for about 2 seconds. Remove the wire connected to Pin 2 from Vcc. You should be able to trigger the 555 again by touching the wire connected to pi
25、n 2 with your finger or by connecting it to ground and removing it. (It should be about a 2 second pulse.) Making it Oscillate Next we will make the LED flash continually without having to trigger it. We will hook up the 555 so that it triggers itself. The way this works is that we add in a resistor
26、 between the capacitor and the discharge pin, Pin 7. Now, the capacitor will charge up (through RA and RB) and when it reaches 2/3 Vcc, Pin 3 and Pin 7 will go to ground. But the capacitor can not discharge immediately because of RB. It takes some time for the charge to drain through RB. The more re
27、sistance RB has, the longer it takes to discharge. The time it takes to discharge the capacitor will be the time the LED is off. To trigger the 555 again, we connect Pin 6 to the trigger (Pin 2). As the capacitor is discharging, the voltage in the capacitor gets lower and lower. When it gets down to
28、 1/3 Vcc this triggers Pin 2 causing Pin 3 to go to Vcc and the LED to come on. The 555 disconnects Pin 7 from ground, and the capacitor starts to charge up again through RA and RB. To build this circuit from the previous circuit, do the following. Disconnect the power. Take out the jumper wire betw
29、een Pin 6 and Pin 7 and replace it with a 2.2k resistor (RB = 2.2K). Use the jumper wire at pin 2 to connect Pin 2 to Pin 6. Now reconnect the power and the LED should flash forever (as long as you pay your electricity bill). Experiment with different resistor values of RA and RB to see how it changes the length of time that the LED flashes. (You are changing the amount of time that it takes for the Capacitor to charge and discharge.)