摘要本文是基于单片机控制的人体感应及自动调光家居智能灯的设计。
每年中国无用照明所损耗的电量资源巨大,这些浪费主要产生于楼梯间、路灯、洗手间灯场所。
随着技术的发展,越来越多的智能家居出现在我们的日常生活中,例如智能洗衣机、智能空调、智能电饭煲等等。
因此,为了保护环境和响应国家节能减排政策的实施,本文设计一种基于单片机控制的人体感应及自动调光家居智能灯。
该系统通过AT89C52单片机进行对各个部件控制协调,红外检测模块、光敏检测模块与PWM调光技术结合从而实现对灯光亮度的自动调节的作用。
PWM 调光的原理是在不改变PWM方波周期的前提下,通过变更PWM的占空比从而控制输出给照明灯的电压使得照明灯出现不同的亮度。
红外检测模块的原理是当模块检测到照明灯附近有人体靠近且周围环境光线较弱时,此时该模块充当开关的作用,使照明灯打开,照明灯的亮度以及调节通过光敏检测模块和PWM电路控制。
为了起到节能效果,当红外检测模块检测不到有人存在时,照明灯持续照明1分钟后自动熄灭。
为了提高该系统的适应范围以及满足不同人的需求,在该系统设计时加入了手动控制的模式,当调节至手动模式时,照明灯的亮度通过手动操作来控制。
关键词:单片机;照明灯;PWM;红外检测;光敏检测AbstractThis paper is based on the MCU control of human body induction and automatic dimming home intelligent lamp design. China consumes a huge amount of electricity each year from useless lighting, which is mainly generated in stairwells, street lamps and toilet lamps. With the development of technology, more and more smart homes appear in our daily life, such as smart washing machines, smart air conditioners, smart rice cookers and so on. Therefore, in order to protect the environment and respond to the implementation of national energy conservation and emission reduction policy, this paper designs a kind of human body induction and automatic dimming home intelligent lamp based on SCM control.The system controls and coordinates the various parts by AT89C52 single chip microcomputer. The infrared detection module, the photosensitive detection module and the PWM dimming technology are combined to realize the automatic adjustment of the light brightness. The principle of PWM dimming is that under the premise of not changing the PWM square wave period, by changing the duty cycle of PWM to control the output voltage to the floodlight so that the floodlight appears different brightness. The principle of the infrared detection module is that when the module detects that there is a human body near the floodlight and the ambient light is weak, the module ACTS as a switch to make the floodlight open. The brightness of the floodlight and the regulation are controlled by the photosensitive detection module and PWM circuit. In order to achieve energy-saving effect, when the infrared detection module cannot detect the presence of someone, the floodlight will be automatically extinguished after 1 minute of continuous illumination. In order to improve the adaptability of the system and meet the needs of different people, a manual control mode was added to the system design. When the system is adjusted to manual mode, the brightness of the floodlight is controlled by manual operation.Key words: MCU; Light; PWM. Infrared detection; Photosensitive detection目录摘要 (I)Abstract (II)1 绪论 (1)1.1 课题的背景及目的 (1)1.1.1 课题的背景 (1)1.1.2 课题的目的 (1)1.2 课题的国内外研究现状 (1)1.3 课题研究内容及要求 (2)1.4 本课题总体设计思路与安排 (3)1.5 本课题的研究时间安排 (4)2 方案论证 (5)2.1 方案设计 (5)2.2 各模块元器件的选择 (5)2.2.1 主控模块 (5)2.2.2 光控模块 (7)2.2.3 人体感应模块 (8)2.3 编程语言的选择 (8)2.3.1 汇编语言 (8)2.3.2 C语言 (9)2.4 本章思路 (9)3 元器件介绍 (10)3.1 单片机 (10)3.1.1 单片机的引脚介绍 (10)3.1.2 AT89C52单片机最小系统 (11)3.1.3 单片机的中断系统 (11)3.2 光敏传感器 (12)3.3 可控硅 (12)3.4 热释电红外传感器 (14)3.5 本章思路 (14)4 仿真电路设计 (15)4.1 系统总体电路 (15)4.2 光控电路设计 (15)4.3 人体检测电路 (16)4.4 照明电路设计 (17)4.5 控制电路的设计 (18)4.5.1 时钟电路 (18)4.5.2 复位电路 (18)5 软件设计及仿真 (20)5.1 软件介绍 (20)5.2 主程序流程图 (20)6 仿真结果与分析 (22)7 总结 (27)参考文献 (28)致谢 (30)1绪论1.1课题的背景及目的1.1.1课题的背景伴随着科学技术以及物联网技术的不断发展,智能家居以及节能减排为当代家居电器发展指明了方向。
智能家居电器不仅为人们的生产生活提供了更进一步的便利,也为我们节约用电,保护环境做了一定的贡献。
党的十九大以来,中国进入了告诉发展和绿色发展阶段,国家的发展必定离不开工业和科学技术的支持,这些行业的发展使得电能的消耗量骤然增加,而中国的电能提供主要还是依靠传统的火力发电,而火力发电势必会对环境造成一定影响。
如何在我们日常生活中节约用电成为了现在很多家用电器厂商共同关注的核心问题[1]。
本课题是针对家庭智能灯的设计,使用单片机作为主控芯片,搭配红外检测模块以及光敏传感器来对人体红外以及外界光线强度进行判别,从而决定是否开灯以及应该给予何种程度的光亮。
光亮程度的原理是根据外界光线强度进行调整灯的亮度,光线越暗则越亮,亮度可进行划分为几个等级。
当检测到人体且外界光线较暗时灯亮,灯亮后传感器一直检测是否有人体在装置附近,若为检测到,则灯亮一定的时间后自动关闭,无论是从视环境光线强弱还是自动关灯,都起到了一定的节约能源的作用[2-3]。
1.1.2课题的目的本课题是针对智能灯的设计,通过单片机和光敏元件以及人体感应传感器搭建成一个可以自动检测人体并通过环境光线来调节灯光亮度的作用,其在家庭中使用时可以让夜晚或者深夜起床提供很大方便,特别是家中有小孩或者老人的情况,同时采用自动感应技术不仅提供了方便,也有效节约了电能,因为当系统一分钟没有感应到人存在则会自动熄灭。
对于以后家用灯光的发展也提供了一个很好的方案。
1.2课题的国内外研究现状智能家居的概念最早起源于美国,1984年美国联合科技公司将建筑设备信息化、智能化概念应用于美国康涅狄格州哈特佛市的城市建设中[4],从此拉开了全世界进行智能家居建造的序幕[5]。
由此可以看出国外针对此项研究较国内要早很多,特别是西方的发到国家。
由于他们进入工业革命以及电子行业发展要早很多年,包括现在很多家用智能灯也都是从国外进口来的,虽然质量和款式都很好,但由于价格过于昂贵,不适合国内行情[6]。
我国针对该项研究虽然起步较晚,但由于国内科研学者和相关研究机构的不懈努力进步很快。
且该领域并非顶尖领域,国内的传统行业与现代电子技术结合,在该领域已经赶超一些发到国家[7]。
目前,这类产品主要研发及销售地分布在广东、上海、浙江一带。
且加入中国元素的该类产品无论在造型还是实用上都比较新颖。
我国现阶段的照明系统一般采用主电源经配电箱分成多路配电输出线,提供照明灯回路用电,由串接在照明灯回路中的开关面板直接接通或断开供电线来实现对灯的控制,灯只有开和关两种状态,无逻辑时序及亮、暗调光控制,因而无法形成各种灯光亮度组合的场景及系统控制。
全球性的能源短缺和环境污染在经济高速发展的中国表现得尤为突出,节约和环保是中国实现社会经济可持续发展所急需解决的问题。