Ttf01uK9

[Event] Summer Electronics - Smart Night Light

 
Overview
Summer Electronics - Smart Night Light
I. System Scheme
        1.1 Illumination Adjustment Circuit Scheme
   Scheme 1: Uses an STM32 microcontroller to generate a PWM signal, and the PWM output can be controlled and adjusted by a 100K potentiometer.
   Scheme 2: Uses a 555 timer to output a PWM signal, and the PWM output can be controlled and adjusted by a 100K potentiometer.
Scheme Selection: Scheme 1 is more expensive; Scheme 2 has a simpler circuit; considering all factors, Scheme 2 is chosen.
      
1.2 Power Supply Scheme
   Scheme 1: Uses an adjustable power supply. Scheme   
2: Uses a combination of a battery pack, Type-C interface, and boost module.   
Scheme Selection: Scheme 1, the adjustable power supply is not portable; Scheme 2, the desk lamp is a practical product and should prioritize user convenience, therefore dry batteries are considered for easy disassembly, or a Type-C interface for easy replacement; considering all factors, Scheme 2 is chosen.
 
1.3 Light Board Scheme
Scheme 1: Use strip light strip combination
Scheme 2: Use dot light board combination   
Selection: Scheme 1, if the requirement is for uniform and stable brightness across the entire A4 paper area, with an illuminance difference of less than 5% between points, requires adding many light strips. The LEDs in the light strips are denser, resulting in higher power consumption and making it uneconomical and environmentally unfriendly. Scheme 2, with its smaller area, allows for more flexible distribution of dot light boards. It also allows for adding or changing the position of any light board at any location, and is easily customizable. Furthermore, the LEDs are not too dense, saving energy. Considering all factors, Scheme 2 is preferred.
 
1.4 Illuminance Display Scheme
Scheme 1: Use 4-digit LED display
Scheme 2: Use OLED screen   
Selection: Scheme 1 can only display numbers; Scheme 2 can display text and other content, providing a better display interface. Considering all factors, Scheme 2 is preferred.
 
II. Theoretical Analysis and Calculation
In the illuminance adjustment circuit, to suit the LED's operating frequency, the value of a capacitor in the circuit needs to be calculated. This capacitor generates a sawtooth wave through charging and discharging, which is input into the 555 timer, which generates a PWM square wave signal. The charging and discharging frequency of the capacitor is adjusted by a 100K potentiometer. Since the sawtooth wave and square wave signals have the same frequency, determining the frequency of the sawtooth wave determines the frequency of the PWM wave. Therefore, the PWM output of the 555 timer can be indirectly adjusted by regulating the potentiometer, thereby controlling the LED brightness. The following is the calculation and determination of the capacitance value:
Capacitance Calculation (using the formula to calculate the charging and discharging time of the potentiometer at 50%)
Charging time: topen = 0.693 * (R1 + R2) * C
          topen = 0.693 * (1000 ohms + 50000 ohms) *
          0.00000001F topen = 0.00035343 seconds (0.35 milliseconds)
 
Charging time: tclose = 0.693 * R 3 * C tclose =
          0.693 * 50000 ohms * 0.00000001F
          tclose = 0.0003465 seconds (0.34 milliseconds)
 
Period (T): topen + tclose        
= 0.00035343 + 0.0003465 = 0.00069993 (0.69 milliseconds)
 
Frequency (f): 1/T      
=1/0.00069993 (1.428Hz)
 
Operating cycle: ton/(ton+toff) = 50.5%
 
Component values: R1 = 1000 ohms, R2 = 50000 ohms, R3 = 50000 ohms, C = 0.0000000F.
 
Determine the capacitor value
. Since low-frequency flickering light can be detected by the naked eye, the LED frequency cannot be too low. Otherwise, the LED will be visible flickering.
A comparison of the frequencies of some common LED lights is as follows:




[Calculated LED


standard household light


LED board




1Hz


50-60Hz


>1400Hz]




Larger capacitors can be used to reduce higher operating frequencies. However, a suitable capacitor needs to be chosen. The following calculations compare the two:




10nF small capacitor (high frequency):


100uF large capacitor (low frequency):
 




Frequency = 1/Period
= 1/0.00069993
= 1.428Hz
 


Period = 6.99 seconds
Frequency = 0.14Hz
 




Clearly, the 100uF large capacitor is too low for the desired frequency, so a smaller capacitor needs to be selected. Finally, a 10nF small capacitor was chosen as the experimental material.
 
III. Circuit and Program Design
 1. Illuminance Adjustment Circuit Design
Note: The component selection is marked in the schematic diagram.
 
2. Illuminance Detection Circuit Design
3. Illuminance Detection Program Design (main.c program in Keil5)
#define EXAMPLE_DATE "2023-11-16"
#define DEMO_VER "1.0"
static void PrintfLogo(void);
SYSDATA_T g_tSYSDATA;
void bsp_keyProcess(void);
uint8_t buf[100]={0};
float myflux = 0.0;
uint8_t writeflag = 0;
uint8_t count; //number of times
int main(void)
{
    uint8_t i = 1; /* key code */
    uint8_t result = 0 ;
    uint8_t test[100] ="fkdjfkajkfjdskfjd12132443590549689";
    bsp_Init(); /* Hardware initialization */
 
   // PrintfLogo(); /* Print routine information to serial port 1 */
    bsp_StartAutoTimer(3, 2000);
    printf("SYSCORE = %d
",SystemCoreClock);
    for(i=0;i
    {
        buf[i] = 255 - i;
    }
    while(1)
    {
        bsp_Idle();
        if(bsp_CheckTimer(3))
        {
            myflux = BH1750_GetLux();
            printf("Current illumination value is %0.2f
",myflux);
            sprintf(buf,"%0.2fLux ",myflux);
            
            OLED_ShowChinese(0,0,0,16,1);//light
            OLED_ShowChinese(16,0,1,16,1);//light
            OLED_ShowChinese(32,0,2,16,1);//light
            OLED_ShowString(48,0,buf,16,1);
            OLED_Refresh();
            
            g_tSYSDATA.flux = myflux;
            g_tSYSDATA.advalue = count;
            if(writeflag == 1 )//Data needs to be stored
            {
                if(count
                {
                    printf("Number of times data is stored: %02d --> %0.02f
",g_tSYSDATA.advalue,g_tSYSDATA.flux);
                    count++;
                    ee_WriteBytes((uint8_t *)&g_tSYSDATA,sizeof(g_tSYSDATA)*(count-1),sizeof(g_tSYSDATA));
                }
                else
                {
                    count =0;
                    writeflag =0;
                }
            }
        }
        bsp_keyProcess();
    }
}
 
IV. Test Plan and Test Results
1. Test Environment
: ① Completely dark environment
② Oscilloscope: CA620T dual-trace oscilloscope
③ Power supply: 9V battery pack and 5.3V Type-C output plus 12V boost module.
 
2. Test Procedure:
The entire device was placed in a completely dark environment to avoid interference from ambient light. An oscilloscope was used to detect sawtooth waves and PWM modulation signals emitted by a 555 timer. Potentiometers were adjusted, and the current flowing through the LEDs was measured at multiple different potentiometer resistance values. Simultaneously, illuminance was measured using a mobile app illuminance meter and a BH1750 module illuminance meter for comparison. The input voltage and current of the power supply were measured with a multimeter. The input power was calculated using the formula P = voltage U * current I. The voltage and current flowing through the LEDs were then measured, and the output power was calculated using the formula. Finally, the power efficiency (the ratio of power consumed by the LED board to the output power of the power supply) was calculated.
 
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 16:11:29

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号