《颜色随环境温度的变化而变化(Colour changes to ambient temperature).doc》由会员分享,可在线阅读,更多相关《颜色随环境温度的变化而变化(Colour changes to ambient temperature).doc(12页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流颜色随环境温度的变化而变化(Colour changes to ambient temperature).精品文档.颜色随环境温度的变化而变化 院(系)名称 专业班级 学生姓名 学号 年 月 日颜色随环境温度的变化而变化在五月五号的电子论坛上,提到了一个被称为“股票球体”的环境光感应显示器。它被引证为一个依靠外在因素而发出各种颜色的装饰品。它通过对周围环境等不断变化的因素进行感应,形成了股票市场重要的起起落落的变化。 这里描述的设计是一种更为精密的简化版本,只需把少量的元器件安装在一个小的印制电路板上就可以做成一个股票球体。它简单的只有一个温
2、度传感器接口,和五个控制色彩的发光二极管。尽管后文也给出了一些想法,但它最终的用途还有如何与其他传感器接口就要靠心灵手巧的读者自己去想了。多姿多彩的世界Ambilux彩色光控制器的中心电路如图1所示。事实上,它以一个围绕的正阻抗变换器PIC微控制器和集成电路1为基础,在这种情况下, 一个更为展新的PIC家庭成员开始在我们的世界里展示自己装置PIC18F242 (或者PIC18F252)。实际上,尽管作者会选择18F装置来证明它用起来多么的简单,但是一个PIC16F876可能很容易就被替换掉。要注意的是,不论如何,软件不能用一个没有配套的翻译代码的16F装置。PIC以RC模式进行操作,它的时钟频
3、率由电阻R12、预置VR3和电容C3决定。设定VR3阻力最小,时钟频率大概是4MHz左右。这个速度远离临界值(以后也能看到)。通过模数转换器(ADC),当PIC输入电压信号时能够产生特定的相应的原始资料,例如温度传感器,虽然它同样很可能只是一个手动控制电位。在对电压进行回应时,五个发光二极管进行相应的触发而发出不同的颜色,这样就会形成一个独有的彩色画面。颜色的选择还有它们的活化顺序都由用户来决定,尽管包括白色的其他颜色也可以选择,但是基本的二极管颜色的通常是在具有代表性的红橙黄绿蓝这个范围内。基本原理在这个例子里,通过引脚RA0最大工作电压范围由PIC的模数转换器进行处理,直流电压是从0V到+
4、5V,不能超出了这个范围。假设输入电压为0V,当软件被写入后,二极管D1处于最大亮度,而其它的二极管从D2到D5均处于关闭状态。当输入电压增大时,D1亮度开始下降,D2亮度开始上升。当输入大约是0.625V时,D1和D2拥有同等的亮度,此时其它的二极管仍处于关闭状态。当电压升到1.25V时,D1完全关掉D2完全打开。当电压上升到超过了1.25V,D2现在开始变暗而D3开始发光,直到1.875V时二者达到同等亮度。当电压继续增大,各个二极管先变亮而后慢慢变弱直至关闭。这样一直继续下去直到电压上升到5V,这时只有D5处于最大亮度,其它二极管均处于关闭状态。根据颜色在序列中已经安排好的顺序,当有效色
5、感应到透明附件里面的东西(例如没有光泽的玻璃球)时会发生改变。如果颜色的序列同上,电压从0V到5V慢慢增加,显示的颜色就会出现从红变为橙红,橙色,黄橙,黄色,黄绿,绿色,蓝绿,蓝色,还有在这些颜色之间的大约128种的渐变颜色。当输入电压再依次下降,颜色变化序列刚好相反。如果电压在某个序列点维持静态,那么颜色也在那个序列点上。温度传感器虽然Ambilux的使用是可选择的,但是为了演示它怎样对周围环境做出一个生动的指示,还是要包括一个简单的温度传感电路。电路如图2所示。硅二极管诸如1N4148可以用来作为温度测量装置。当一个小电流通过硅二极管时,以1N4148为例,在电压和温度之间将产生一个几乎是
6、线性的关系,也就是大约每伏430C(2.3mv每摄氏度)的特有敏感性。结温的计算公式来自于测量二极管的直线方程。Tj = m Vf + To其中Tj是结温,m是温度灵敏度系数用摄氏度每伏来表达,Vf是二极管正向电压,To是补偿温度。为了在结点的内部建立传导,通过二极管的电流必须足够大,而不是只是表面的泄露传导。虽然不是大到要人为地去提高二极管的内部温度,这是必须的。一般用0.1mA作为所需的电流。在图2中,温度传感二极管用D12表示。在阳极(a)它通过电阻R13连接+5V线路,在阴极(k)它通过预置VR1连接0V线路。阴极同时也连接用户运算放大器的输入端。出现在运算电路的基本偏置电压水平可以通
7、过调整进行设定,以提高VR1阻力,降低偏置。用这种方法,一个中路偏置代表,也就是说,一个15C的温度可以被设定。在实践中,如果我们想取温度范围为从0C到30C,那么电流的变化极值在302.3mV=69mV之间。PIC的模数转换输入范围是0V到5V。前置放大器的增益是5000mV/69mV=72。预置VR2在运算放大器的输出端(7脚)和反向输入端(6脚)之间的反馈路径可以用来调整运算放大器的增益,在大概47倍到100倍之间(从R17到R14的比率,加上VR2,加上1)。通过中途设定VR2的滑片位置,可以近似的设置所需的增益,随后如果还有需要的话可以再调整。然后输出电压结果会经过S4转换到PIC的
8、模数转换端RAO脚。事先应当先调整好VR2以便于室内有代表性的温度可以在一个合理的范围内显示出颜色列队。一般建议用蓝色表示最低温,红色表示最高温,当然,你也可以自己选择。如果你想要一个较窄的范围,比如说跨度为10C在15C到25C之间,那么计算结果是102.3mV=23mV。所需增益是5000mV/23mV =217,如此可算出所需反馈电阻是2170kW,也就是2M2W。在这种情况下,需将R14修改为1M5W,但R2仍保持在500kW(预设470kW可用于任何情况下)。放大级在PIC的RAO引脚上加一个0V到5V的直流电压,是完全可行的。然而,可以这样设想,小范围的电压水平可由其他敏感器件源提
9、供。为了实现这个设想,可通过图2中集成电路的4b来提供交流/直流放大阶段。这不仅在开关在S2时为增益提供了一倍或十倍的选择,也在开关在S3时为输入提供了直流或交流的选择。通过所选路径,来自于SK1的输入信号按路线送到集成电路4a反相输入端(2脚)。非反相输入(3脚)通过电阻R15和R16偏向于中间电压(2.5V)。电容器C5增强了输入的稳定性。测试在全面彻查组装版配置的精准度并将元件定位后,在D12(TP8)的阴极(k)和0V之间连接一个测量表。当通电时,调整预置VR1直至电压读数为2.5V(半线电压)。关掉电源,测量集成电路4a输出端7脚(TP6)和输入端6脚(TP7)之间的阻值。调整VR2
10、直到阻值被设定为720KW。这样设置时,运算放大器的增益值近似于建议的72倍。现在重新调整VR1(小心地),直到TP6的输出电压值大约为2.5V。当你用你的手指温暖二极管D12时,TP6的输出端可以看到几毫伏的变化。如果稍后在光的体验有需要的话,VR1和VR2都可以进行轻微的调整,以便于你得到你想要的随温度变化而变化的颜色。如果你想不通过图2所示接口来测试PIC,模数转换器输入端RAO可以通过测试电位计VR4给予一个0V到5V之间的电压,如图1中插图所示。任何电压的改变均可用于Ambilux,倘若它的极端条件没有超过运算放大器或是正阻抗变换器。他们都不需要精密采购或控制。当缓慢变化开始时可能更
11、多的是一般的赏心悦目,用Ambilux做出一个声光转换器,它就可以对声音振幅进行响应,至于为什么一个声卡无法发声那是没有原因的。史提夫通用PIC发光装置MK2这篇文章中展示了一些可能是传感源的例子。他们可能需要进行稍微的修改来适应Ambilux,但是他们看起来有一个合理的起点。他的建议包括声音传感器在麦克风中的应用,基于热敏电阻的温度传感器,基于光敏电阻的光传感器,和一个运动检测器(可根据一个人对传感器的接近程度而变化为不同的颜色这为孩子们提供了很多乐趣)。你的PIC程序编写还有写作技巧能让你写出多种可嵌入到PIC的软件。(大量的代码空间仍可使用)。事实上如果你连好电路并接通开关S5(图1 )
12、,你可以发现,作者已向读者提供了一个简单的程序装置。正如所描述的那样,它在D1到D5之间循环, D5和D1成为一对被控制的二极管,序列如此重复。如果你想把外部设定成线性变化,用一个线性扶轮电位器代替预置VR3。一个值50k的可能比一个100k更能避免PIC的低时钟频率所导致的发光二极管出现闪烁的状况。我们相信一旦建立了这样一个基本框架,很快就会找到更多的不同寻常的新奇用途。 日常实用电子附:英文原文Colour changes to ambient temperatureIN Techno Talk of May05,reference was made to an ambient-sensi
13、ng light display known as the “Stock Orb”. It was quoted as being an ornament that glows in various colours depending on a number of external factors. These factors ranged from sensing the surrounding temperature, to the everchanging ups and downs of values on the Stock Market.The design described h
14、ere is a much simplified version of what the Stock Orb can probably do, using just a handful of components on a small printed circuit board.Aspre sented, it simply interfaces to a rudimentary temperature sensor and controls five coloured l.e.d.s. Its ultimate use and interface to other sensors is up
15、 to the ingenuity of the reader, although some ideas are given later.Colourful worldThe heart of the Ambilux coloured light controller is shown in the circuit of Fig.1. Naturally, it is based around a PIC microcontroller,IC1,inthisinstanceaPIC18F242 (or PIC18F252) device one of the newer PIC family
16、beginning to show itself in our pages. In point of fact, a PIC16F876 could just have readily been use instead,although the author chose the 18F device to show how easy it is to use. Note, however, that the software cannot be used with a 16F device without suitable code translation. The PIC is operat
17、ed in RC mode, with its clock rate set by resistor R12, preset VR3 and capacitor C3. With VR3 set for minimum resistance, the clock rate is about 4MHz or so. The rate is far from critical (also see later).Via its analogue-to-digital converter (ADC), the PIC inputs the signal voltage produced by a pa
18、rticular source, such as the temperature sensor, though it could equally well be just from a manually controlled potentiometer. In response to that voltage, a bank of five l.e.d.s having different colours is triggered accordingly so that a particular colour hue is set to glow.The choice of colours a
19、nd their order of activation is up to the user, but the basic range of l.e.d. colours available is typically red, orange, yellow, green and blue, although other colours are available, including white.Basic principleThe maximum voltage range that can be processed by the PICs ADC, which is accessed in
20、 this instance via pin RA0, is from 0V to +5V d.c., a range which must not be exceeded.Suppose the input voltage is 0V, the software has been written so that l.e.d. D1 is at full intensity and the other l.e.d.s., D2 to D5, are turned off. As the input voltage increases, the intensity of D1 begins to
21、 fall, and that of D2 starts to rise. When the input is at about 0625V, both D1 and D2 have the same brilliance, and the other l.e.d.s still remain off.When the voltage has risen to about 125V, D1 is fully turned off and D2 fully turned on.As the voltage rises above 125V, so D2 now starts to dim as
22、D3 starts to glow, until at 1875V, both are equally bright. As the voltage continues to rise, so the intensity of the respective l.e.d.s fades up and then down. This continues until the voltage has risen to 5V, at which point only l.e.d. D5will be fully on, and all other l.e.d.s will be turned off.D
23、epending on the order in which the colours have been arranged in the sequence, so the effective colour hue perceived inside a translucent enclosure (a “frosted” glass globe for instance) will change. If the colour sequence is as above, and the voltage change is progressively from 0V to 5V, the displ
24、ayed colour will appear to change from red to orangy-red, orange, yellowy-orange, yellow, greeny-yellow, green, bluey-green, blue, and around 128 shades between these groups.As the input voltage falls again, so the colour-changing sequence is reversed. If the voltage remains static at any point in t
25、he sequence, so does the colour at that level.Temperature sensorFor the sake of demonstrating how the Ambilux can be used to provide a colourful indication of ambient conditions, a simple temperature sensing circuit has been included, although its use is optional. Its circuit diagram is shown at Fig
26、.2. Silicon diodes such as the 1N4148 can be used as temperature detecting devices. When a small current flows through a silicon diode, such as the 1N4148, it yields a nearly linear relationship between the voltage and temperature with a typical sensitivity of about 430C per volt (23mV per C). The e
27、quation for computing junction temperature from the measured diode voltage is the straight line equation:Tj = m Vf + Towhere Tj is the junction temperature, m is the temperature sensitivity expressed in terms of C per volt,Vf is the diode forward voltage and To is the offset temperature.The current
28、through the diode must be sufficiently large to establish conduction in the body of the junction rather than just a superficial leakage conduction. It must, though, not be so large as to artificially raise the internal temperature of the diode. Generally 01mA is taken as the required current.In Fig.
29、2 the temperature sensing diode is noted as D12. On the anode (a) side it is biased from the +5V line via resistor R13. On the cathode (k) side, it is connected to the 0V line via preset VR1. The cathode is also connected to the non-inverting input (pin 5) of op.amp IC4a.The basic bias voltage level
30、 seen at IC4a pin 5 can be set by the adjustment of VR1 increased resistance raising the bias, decreased resistance lowering it. In this way a mid-way bias representing, say, a temperature of 15C can be set.In practical terms, if we take the temperature range we want as being 0C to 30C, the change i
31、n current between the extremes is 30 23mV =69mV. The PICs ADC input range is 0V to 5V. The gain required by IC4a is thus 5000mV / 69mV = 72.PresetVR2 in the feedback path between the op.amps output (pin 7) and inverting input (pin 6) can be used to adjust the op.amps gain, to between about 47 and 10
32、0 (the ratio of R17 to the total of R14 plus VR2, plus 1). With VR2s wiper set midway, an approximation of the required gain can be set, and subsequently adjusted if desired. The resulting output voltage can then be fed via switch S4 (Thermo) to the PICs RA0 ADC pin.Adjustment of VR2 should be made
33、(in the light of experience) so that the temperature typically experienced in a house can produce a reasonable range of display colour bands. It is suggested that blue indicates the lowest temperature,and red the highestbut the choice is yours. If you wanted a narrower range, say a 10C swing between
34、 15C to 25C, the calculation is then 10 23mV = 23mV. The gain then needed is 5000mV/23mV =217, thus requiring a feedback resistance of 2170kW, say2M2W. In this case amend R14 to 1M5W, but leave VR2 at 500kW (a 470kW preset may be used in either instance).Amplifier stageIt is perfectly feasible to ap
35、ply a voltage of between 0V and 5V d.c. directly to PIC pin RA0.However,it is envisaged that lower range voltage levels might be supplied by other sensing device sources.To this end, an a.c./d.c. amplifying stage has been provided, via IC4b in Fig.2. This not only provides for a gain choice of 1 or
36、10, as selected by switch S2, but also a choice of a.c. or d.c. input, as selected by S3.Via the selected path, the input signal from socket SK1 is routed to the inverting input (pin 2) of IC4a. The noninverting input (pin 3) is biased to a mid-level voltage (25V) by resistors R15 and R16. Capacitor
37、 C5 enhances the stability of this input. The output from IC4b pin 1 can be routed to the PICs ADC pin RA0 via switch S4.The op.amp type shown in Fig.4 is a TLC2272IP rail-to-rail device, providing an output that can fully swing between 0V and 5V on a 5V supply. Other rail-to-rail dual op.amps may b
38、e used instead.If you know precisely how you wish to use the interface in Fig.4, you may prefer to omit switches S2 to S4, hard-wiring only those connections that you want. Furthermore, any then-unused components in Fig.4 could be omitted as well.TestingHaving thoroughly checked the assembled board
39、for accuracy of assembly and component positioning, connect a meter between the cathode (k) of D12 (TP8) and the 0V line. With power on, adjust preset VR1 until the voltage reads 2.5V (half line voltage).Switch off power and measure the resistance between IC4a output pin 7 (TP6) and input pin 6 (TP7
40、).AdjustVR2 until a resistance of about 720kW is set. This sets the op.amp gain to approximately the suggested 72.NowadjustVR1again(carefully),until the output voltage at TP6 is about 25V.If you warm diode D12 with your finger, the output at TP6 should be seen to change by several millivolts. Both V
41、R1 and VR2 can be slightly readjusted later if desired, in the light of experience, so that you get the desired colour change in response to changing temperature. If you wish to test the PIC without the Interfaces in Fig.2, ADC input RA0 can be fed with a voltage between 0V and 5V by the test potent
42、iometer, VR4, shown inset in Fig.1.Any changing voltage level can be applied to the Ambilux, provided its extremes do not exceed the limits of the op.amp or the PIC.None of them need to be precision sourced or controlled. Whilst slowly changing sources might be more generally pleasing to the eye, th
43、eres no reason why a sound source could not be used, using the Ambilux to be haveas a simple sound-to-light converter, responding to sound amplitudes.Steve Challinor showed a few examples of possible sensor sources in his Versatile PIC Flasher Mk2 article (Dec 04). They may need a bit of modifying t
44、o suit the Ambilux, but they seem reasonable starting points. His suggestions included a Sound Sensor using an electret microphone, a thermistor-based Temperature Sensor, an LDR-based Light Sensor, and a Movement Detector (which could be modified to cause different colours depending on a persons pro
45、ximity to the sensor lots of fun for kids here!).Those of you with PIC program writing and programming skills could also write various control routines for embedding into the PICs software (lots of code space still available). Indeed if you connect and switch on S5 (Fig.1) you will find that the aut
46、hor has already provided you with a simple sequencer. It cycles through D1 to D5 as described, then at D5, both D5 and D1 become the controlled l.e.d. pair, and the sequence repeats.If you want to externally set the rate at which the sequence changes, use a linear rotary potentiometer in place of presetVR3. A value of 50k rather than 100k might be better to avoid low PIC clock rates that cause the l.e.d.s. to flash.Were sure youll find plenty of uses for this unusual display novelty once youve built its basic framework! Everyday Practical Electronics