Night Light Saver V6

          2016-07-05 15:37
          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! Figure 1: Embedded saver with lamp fixture Hardware DescriptionFigure 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. Figure 2: Complete schematic of Night Light Saver V6.0 Night Light Saver V6saver6.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. Figure 3: Bottom view with Ni-MH battery SoftwareThe 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. 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. Figure 5: with 25W lamp and cover Download Schematic saver6.pdf Firmware lamp.cNight Light Saver V6lamp.rar C compiler SDCC.zipNight Light Saver V6SDCC.zip Orcad 9.1 schematic file NA
          主站蜘蛛池模板: 老司机福利在线播放| 幻女free性zozozoxxxxx| 天天摸日日添狠狠添婷婷| 在线视频网站WWW色| 国产精品亚洲а∨天堂2021| 国产成年无码久久久免费| 国产91精品在线| 亚洲精品无码国产片| 口工全彩无遮挡3d漫画在线| 免费观看呢日本天堂视频| 亚洲色图综合在线| 久久综合久久鬼色| 中文乱码精品一区二区三区| 99热精品久久只有精品30| 被吃奶跟添下面视频| 色九月亚洲综合网| 永久黄网站色视频免费观看| 男人边摸边吃奶边做下面| 欧美性生交xxxxx久久久| 日本chinese人妖video| 在线视频网站WWW色| 国产好痛疼轻点好爽的视频| 国产日韩av在线播放| 国产精品9999久久久久| 国产99在线播放| 亚洲成色在线综合网站| 中文无码人妻有码人妻中文字幕 | 日本三级带日本三级带黄国产| 女人被免费网站视频在线| 国产成人精品自线拍| 便器调教(肉体狂乱)小说| 久久综合亚洲色hezyo国产| segui久久综合精品| 麻豆国产三级在线观看| 波多野结衣妻奴| 欧美激情(一区二区三区)| 日本免费v片一二三区| 国产精品麻豆va在线播放| 午夜精品久久久久久久久| 亚洲AV综合色区无码二区爱AV | 久久亚洲欧美国产精品|