日韩欧美自拍在线观看-欧美精品在线看片一区二区-高清性视频一区二区播放-欧美日韩女优制服另类-国产精品久久久久久av蜜臀-成人在线黄色av网站-肥臀熟妇一区二区三区-亚洲视频在线播放老色-在线成人激情自拍视频

Night Light Saver V6

出處:gaoyysea 發(fā)布于:2008-07-06 00:00:00 | 2204 次閱讀

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 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.




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.

 


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_6
char 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 hours
code 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 function
code 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

Schematicsaver6.pdf 
Firmwarelamp.c 
lamp.rar
C compilerSDCC.zip 
SDCC.zip
Orcad 9.1 schematic fileNA
0次

版權與免責聲明

凡本網注明“出處:維庫電子市場網”的所有作品,版權均屬于維庫電子市場網,轉載請必須注明維庫電子市場網,http://www.hbjingang.com,違反者本網將追究相關法律責任。

本網轉載并注明自其它出處的作品,目的在于傳遞更多信息,并不代表本網贊同其觀點或證實其內容的真實性,不承擔此類作品侵權行為的直接責任及連帶責任。其他媒體、網站或個人從本網轉載時,必須保留本網注明的作品出處,并自負版權等法律責任。

如涉及作品內容、版權等問題,請在作品發(fā)表之日起一周內與本網聯(lián)系,否則視為放棄相關權利。

OEM清單文件: OEM清單文件
*公司名:
*聯(lián)系人:
*手機號碼:
QQ:
有效期:

掃碼下載APP,
一鍵連接廣大的電子世界。

在線人工客服

買家服務:
賣家服務:
技術客服:

0571-85317607

網站技術支持

13606545031

客服在線時間周一至周五
9:00-17:30

關注官方微信號,
第一時間獲取資訊。

建議反饋

聯(lián)系人:

聯(lián)系方式:

按住滑塊,拖拽到最右邊
>>
感謝您向阿庫提出的寶貴意見,您的參與是維庫提升服務的動力!意見一經采納,將有感恩紅包奉上哦!