首页 | 供应信息 | 采购信息 | PDF资料 | 技术资料 | 行业资讯 | 产品展示 | 人才市场 进入会员区
   技术文章分类:单片机/DSP 嵌入式系统 测试仪表 电源技术 接口电路 存储器 传感与控制 通信网络 无线通信 模拟技术 显示与光电 EDA/PLD 汽车电子 消费电子 电子综合
   电子综合工具:PDF资料大全 电子缩略语 IC型号替换 IC厂家 电子电路图 技术参数 设计应用 解决方案
技术资料 行业资讯 PDF资料 IC价格 IC替换 缩略语 IC供应 IC采购
  您所在的位置: IC37首页 > 技术资料 > 单片机制作 > Night Light Saver V6
Night Light Saver V6
类别:单片机制作  
 
Night Light Saver V6

Latest design of night light saver circuit built with AT89C2051. Nice firmware using c coding developed with SDCC.

This new version has internal Ni-MH battery backup, reset button and simple time setting. Now the circuit board was embedded with lamp fixture. Preset turn on period is from 18:00 to 22:00 everyday. You may let the saver turn on whenever you want. The period of time on can be reprogrammed with sdcc. Howvere this project is not recommended for beginner. The circuit uses transformerless supply and no galvanic isolation!

600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

Figure 1: Embedded saver with lamp fixture

Hardware Description

Figure 1 shows complete hardware schematic of the Night Light Saver V6.0. The AC line was protected F1, a 1A fuse. Any short circuit caused by saver's components will blow the fuse. R1 and C1 limit current to the +5V zener diode, D3. R2 discharges capacitor C1 when power terminal of the circuit was opened. The super capacitor C2,+5V 0.01F filters DC supply. D4 acts as unidirectional switch for current supplied to MCU. BT1 is +3V 60mAH Ni-MH battery for backup the MCU when main power failed. The charging current is approx. 2mA with AC main lives. When main power failed, BT1 supplies approx. 4mA to the MCU. With fully charged, it could be able to provide backup time approx. 15Hrs. The MCU runs with +Vbackup. SW1 helps reset the MCU, in case of brownout voltage by BT1. C4 and internal pull-down resistor forms simple reset circuit. The MCU, 89C2051 runs with 3.579MHz Xtal. SW2 is for clock setting, when pressed, time will be 18:00. P3.7 drives tick LED with small sink current. R5, 4.7k limits less than one mA for D5. P3.0 provides 5Hz clock signal for calibration. The output bit is P1.6. It drives PNP transistor, Q1. R3 limits base current. R5 pull base pin to +V when P1.6 is logic '1' to fully turn off Q1. R4 limits DC current injected to Q2, MAC97 small triac. LP1 is incandescent 25W lamp. The lamp's wattage can be up to 40W.

600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

Figure 2: Complete schematic of Night Light Saver V6.0

saver6.pdf

I built the board with universal pcb and put it under the lamp fixture. SW1 and SW2 are small tact switch. To press them I need a small rod made by bamboo.

600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

Figure 3: Bottom view with Ni-MH battery

Software

The source program is beautiful coding with c language. After timer initialization then idle mode is entered by setting bit0 in PCON register. The timer0 overflows 10 times per second. Tasks for update clock, check SW2, blink LED and update output bit will be executed every 1/10s. The task that controls output instead, will be executed every one second. For different preset time, time on, time off, you can edit the source code and recompile with sdcc easily. I provide sample scheduler scanning function, scan_pgm( ). If you want to modify the code for all 8-bit output on P1 similar to the Miniature Real-time Controller. You may have open collector driver, the same hardware and modify a little bit of the source code. /*

Lamp.c

night light saver V6.0, 89C2051 runs with 3.579MHz xtal

The source code was compiled with sdcc. Copyright (C) 2004 Wichit Sirichote, kswichit@kmitl.ac.th, 20 December 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */#include #define tick_test P3_0 // 10Hz/2 output for clock calibration #define LED P3_7 #define output1 P1_6char status;int count, i; char tick, flag1, temp, timer1, timer2;char hour,min,sec,sec10;// you may press set time button whenever you want the lamp turns on // for winter season you may press ealier than local time // for summer more late, time will shift relatively! // period will be 22:00 - 18:00 = 4 hourscode char time_on1[] = {18,00}; code char time_off1[] = {22,00};// another scheduler, the 3rd byte will write to P1 // you may replace control_output function by scan_pgm functioncode char pgm1[]={18,00,0x80,19,00,0,20,0x80,1,21,00,0};char _sdcc_external_startup() { return 1; // skip static and global variables initialization }scan_pgm() { char i; for(i=0; i<4; i++) { if(hour == pgm1[i*3] && min == pgm1[i*3+1]) P1 = ~pgm1[i*3+2]; } }control_output() { if(hour == time_on1[0] && min == time_on1[1]) status = 0; if(hour == time_off1[0] && min == time_off1[1]) status = 1; }blink_led() { if(flag1&1) { if(++timer1>1) { flag1 &= ~1; // clear flag1.0 timer1=0; LED = 1; // turns off led } } }void time () /* update real-time clock */ { if (++sec10 >= 10) /* 100ms * 10 = 1 s */ { LED = 0; control_output(); // control output every second sec10 = 0; flag1 |=1; if (++sec >= 60) {sec = 0; if (++min >= 60) {min = 0; if (++hour >= 24) {hour = 0; } } } } } set_time() { if((P3&4)==0) { status = 0; hour = 18; min = 0; sec = 0; timer2=0; } }update_output() { if(status) output1 = 1; else output1 =0; // update output bit }void timer_isr(void) interrupt 1 using 1 { TH0 = 0x8b; TL0 = 0x7f; // reload with 35711 for 10Hz tick++; tick_test ^= 1; // test tick for 10Hz/2 or 5Hz time(); set_time(); blink_led(); update_output(); } main() { TMOD = 0x01; // timer1 and timer0 = mode 1 EA = ET0 = TR0 = 1; // enable timer0 interrupt, start timer PCON |= 1; // enable IDLE mode, to extend backup period for(;;) ; }

Figure 4 shows start time at 18:00 when SW2 was pressed. The lamp will turn on until 22:00 everyday. Since the preset time, 18:00 can set whenever SW2 was pressed, so if you want to change time on, for examples in summer season, sun will set lately, suppose you want the lamp to be turned on at 19:00, you just press SW2 at 19:00. The day after it will turn on at 19:00, however time off will shift to 23:00.

600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

Figure 4: Preset time on for winter

Figure 5 shows a complete lamp fixture with cover and 25W lamp. I have been tested the energy saving lamp, 5W Sylvania, it also works fine. 600) {i=this.width; j=this.height; this.width=600; this.height=j/i*600;}" border=0>

Figure 5: with 25W lamp and cover

Download

Schematic saver6.pdf Firmware lamp.c

lamp.rar C compiler SDCC.zip

SDCC.zip Orcad 9.1 schematic file NA

 
我要投稿 注册会员
客服咨询热线:0755-26000950 0755-26007355
 相关技术资料
·公交车非接触IC卡读写器电..  2008-1-23
·单片机试验板电路一  2008-1-23
·单片机试验板电路二  2008-1-23
·单片机试验板电路四  2008-1-23
·单片机试验板电路三  2008-1-23
·单片机试验板电路五  2008-1-23
·的M16实验板  2008-1-23
·数显量具和51单片机的接口..  2008-1-23
·自制AVRISP下载型烧录器  2008-1-23
·SST89C58电子盘电路..  2008-1-23
·自制PIC单片机编程器电路  2008-1-23
·串行E2PROM--24C..  2008-1-23
·24cxx复制器电路  2008-1-23
·智力抢答器电路  2008-1-23
·RS232-TTL-RS4..  2008-1-23
·点阵式汉字LED显示屏电路..  2008-1-23
·利用PC的RS232口控制..  2008-1-23
·用打印机端口做可编程频率发..  2008-1-23
·一种安全可靠的IC卡读写器..  2008-1-23
·使用SST89C58控制单..  2008-1-23
 
 热门IC
R6642-22  74LS22  ADSP-2185BST-115  SD1400-2  LPC47N217-JV  SSM2475  TC04ACOA  ADS7846IRGVT  CY2304SXC-2  BA6246  PM200CVA060  AM29F400BB-70SE  ST30Y2  MG400J1US2  MG150J7KS50  HM8350AP  FPAL20SL60  HAS-1202  TPS73HD325PWPR  TSB12LV32PZ  TA31194FN  TAS5010PFB  TE28F800B5T90  TP3067AN  TCM1512AP  ISQ74  R3BMF1  IRF630MFP  LNK306GN  SA22A  S82C42PC  ST16C654DIQ64  HD74LS74AFP  HSMS-2860-TR1  ADM1485AR-REEL7  MC14467  SC1205  TDA8563T  SN104275DDAR  MC68HC908QY1CP  MIC2202BMM  MAX4212EUK  MAX8877EUK25-T  OPA2345UA  EP20K60EFC324-1  MAX238ERG  T435-600T  CD54ACT00F3A  MTD2955ET4  FDP070AN06A0