1658 views|1 replies

3836

Posts

19

Resources
The OP
 

Low power clock based on MSP430F413 fruit battery [Copy link]

When I first came into contact with MSP430, I saw a picture of a fruit battery on the first page of the book. I have always wanted to make a low-power system that can be powered by a fruit battery. In the second half of my graduation, I chose the MSP430F413 microcontroller to draw a low-power board, but I have never debugged it successfully. The LCD display is too dark to be seen. Recently, I debugged it again, replaced the bias resistor, and finally replaced the LCD to display normally. Let's take a look at the final effect:

Final result

Circuit Diagram:

Debugging process

When debugging for the first time, prepare an apple, the positive and negative electrodes of the battery (copper zinc), and the program displays a number. The effect is as follows:

On a whim, I tried it with tap water, and the effect was also great (the program was modified in the middle, this is to display more LCD segments):

Clock debugging effect (the battery is not connected to the circuit here, it is used during debugging, and was not removed at the time. It was connected to the fruit-powered circuit with a jumper cap):

When debugging just now, the multimeter tested the fruit battery voltage close to 0.9V, the short-circuit current 25-30uA, when the circuit was connected and only the number 7 was displayed, the current was 12uA, and the voltage of the 4 fruit batteries dropped from 3.4 to 2.6V; water (ordinary tap water, the number of ions contained in the water in each place is different, and the voltage and current obtained are different) each battery is 0.8V, and the short-circuit current is close to 40uA.

When the program was changed to the clock, the fruit battery dropped from 3.4V to 2.2V, which lasted for about an hour. The LCD had no display at all. The electrodes were changed and reinserted, and the clock continued to run. The test voltage was the same as that of a new fruit battery. When the apples were about to dry, the voltage was lower and the LCD became noticeably darker.

Later, the resistor that provides the liquid crystal bias voltage in the circuit was changed from 330K to 1M, and the system current dropped to about 10uA. The fruit battery can last for about 3-4 hours, and the battery made of water can last for more than 24 hours.

Power consumption analysis

This low-power circuit still has room for optimization. The unused pins of the microcontroller can be further optimized. In the existing circuit, there are general LCD segment pins that are not used, but the driving waveform is also provided. This should be the part that wastes the most current compared to the existing system. Another room for optimization is that the pull-up resistors of the four buttons are too small. When the 10K and 3V are used, the current can reach 300uA when the button is pressed. When using fruit batteries, the button function cannot be used. Now when debugging, CR2302 is used for power supply first, and after adjusting the time, the fruit (water) battery is used for power supply.
After further optimizing the power consumption, the current should be able to drop below 5uA.

program

The key program continues to use the key program in the previous program library;

RTC timing uses TI's RTC software library

The segment code LCD program is transplanted from the digital tube program in the program library:

    #include  <msp430x41x.h>
    #include  "segment_lcd_btl006.h"
    
    /*宏定义,数码管a-h各段对应的比特,更换硬件只用改动以下8行*/
    #define a       0x01                            //  AAAA
    #define b       0x02                            // F    B
    #define c       0x04                            // F    B
    #define d       0x80                            //  GGGG
    #define e       0x40                            // E    C
    #define f       0x10                            // E    C
    #define g       0x20                            //  DDDD  HH
    #define h       0x08        //小数点
    
    /*用宏定义自动生成段码表,很好的写法,值得学习*/
    /*更换硬件无需重写段码表*/
    const char tab[] = {
        a + b + c + d + e + f,                  // Displays "0"
        b + c,                                  // Displays "1"
        a + b + d + e + g,                      // Displays "2"
        a + b + c + d + g,                      // Displays "3"
        b + c + f + g,                          // Displays "4"
        a + c + d + f +g,                       // Displays "5"
        a + c + d + e + f + g,                  // Displays "6"
        a + b + c,                              // Displays "7"
        a + b + c + d + e + f + g,              // Displays "8"
        a + b + c + d + f + g,                  // Displays "9"
        a + b + c + e + f + g,                  // Displays "A"
        c + d + e + f + g,                      // Displays "B"  
        a + d + e + f,                          // Displays "C"
        b + c + d + e + g,                      // Displays "D"
        a + d + e + f + g,                      // Displays "E"
        a + e + f + g,                          // Displays "F"
        a + c + d + e + f,                      // Displays "G"
        b + c + e + f + g,                      // Displays "H"  
        e + f,                                  // Displays "I"
        b + c + d + e,                          // Displays "J"
        b + d + e + f + g,                      // Displays "K"
        d + e + f,                              // Displays "L"  
        a + c + e + g,                          // Displays "M" 
        a + b + c + e + f,                      // Displays "N"   
        c + e + g,                              // Displays "n"
        c + d + e + g,                          // Displays "o"
        a + b + c + d + e + f,                  // Displays "O"
        a + b + e + f + g,                      // Displays "P"
        a + b + c + f + g,                      // Displays "Q" 
        e + g,                                  // Displays "r"
        a + c + d + f +g,                       // Displays "S"
        d + e + f + g,                          // Displays "t"
        a + e + f ,                             // Displays "T" 
        b + c + d + e + f,                      // Displays "U"
        c + d + e,                              // Displays "v" 
        b + d + f + g,                          // Displays "W"
        b + c + d + f + g,                      // Displays "Y" 
        a + b + d + e + g,                      // Displays "Z"
        g,                                      // Displays "-"
        h,                                      // Displays "."  
        0                                       // Displays " "
    }; 
    #undef a
    #undef b
    #undef c
    #undef d
    #undef e
    #undef f
    #undef g 
    
    void lcd_init()
    {
    
        // Initialize LCD
        LCDCTL = LCDP1+LCDP0+LCD4MUX+LCDON;       // 4-Mux LCD, segments S0-S23
        BTCTL  = BTFRFQ1;                         // Set freqLCD = ACLK/128
        P5SEL  = 0xFC;                            // Set Rxx and COM pins for LCD
    
        // Clear LCD memory to clear display
        for (int i=0; i<12; i++)
        {
            LCDMEM[i] = 0x00;
        }
    }
    
    void lcd_clear()
    {    
        for (int i=0; i<12; i++)
        {
            LCDMEM[i] = 0x00;
        }
    }
    
    //不影响小数点或者冒号
    void lcd_display_char(char ch,char addr)
    {
        addr = addr*2+2;
        LCDMEM[addr] = ((tab[ch]&0x0f)<<4)|(LCDMEM[addr]&0x80);
        LCDMEM[addr+1] = (tab[ch]&0xf0);//|(LCDMEM[addr+1]&0x80)
    }

The timing program will be interrupted every 1 second, and the timing will increase by 1 second. The corresponding setting interface will be displayed when setting:

    #include  <msp430x41x.h>
    #include  "RTC_Calendar.h"
    #include  "RTC_TA.h"
    #include "segment_lcd_btl006.h"
    #include "time.h"
    
    char state = 0;  //1-6:年月日 时分秒
    
    void time_init()
    {
        lcd_init();
        setDate(2015,9,13);
        setTime( 0, 0, 0, 1);                  // initialize time to 12:00:00 AM
        TACCR0 = 32768-1;
        TACTL = TASSEL_1+MC_1;                    // ACLK, upmode
        TACCTL0 |= CCIE;                          // enable TA0CCRO interrupt
    }
    
    //两位时间显示,格式十六进制高地位 地址0低位,1高位
    void time_display(char time,char addr)
    {
        addr = addr*2;
        lcd_display_char(time>>4,addr+1);
        lcd_display_char((time&0x0f),addr);  
    }
    
    //4位时间显示,year,格式十六进制各个位 
    void year_display(int year)
    {
        lcd_display_char(year>>12,3);
        lcd_display_char((year>>8)&0x0f,2);  
        lcd_display_char((year>>4)&0x0f,1);  
        lcd_display_char((year)&0x0f,0);  
    }
    
    //计时标志,冒号闪烁
    void tick()
    {
        LCDMEM[1]&=~0X80;
        LCDMEM[2]^=0x80;
        time_display(get24Hour(),1);
        time_display(TI_minute,0);
    }
    
    void setting()
    {
        LCDMEM[1]=0X80;
        switch(state)
            {
                case 1:
                    year_display(TI_year);
                    break;
                case 2:
                    time_display(TI_month==9?TI_month+7:TI_month+1,1);
                    break;
                case 3:
                    time_display(TI_day,0);
                    break;
                case 4:
                    time_display(get24Hour(),1);
                    LCDMEM[2]|=0x80;
                    break;
                case 5:
                    time_display(TI_minute,0);
                    LCDMEM[2]|=0x80;
                    break;
                case 6:
                    time_display(TI_second,0);
                    LCDMEM[2]|=0x80;
                    break;
                default:
                    state = 0;
                    break;
            }
    }
    
    
    // Timer A0 interrupt service routine
    #pragma vector=TIMERA0_VECTOR
    __interrupt void Timer_A (void)
    {
        incrementSeconds();
        if(state == 0)
        {
            tick();
        }
        else
        {
            setting();
        }
        __bic_SR_register_on_exit(LPM3_bits);
    }

The main function changes the operation status according to the key and sets the time value:

    #include  <msp430x41x.h>
    #include  "RTC_Calendar.h"
    #include  "RTC_TA.h"
    #include  "segment_lcd_btl006.h"
    #include "time.h"
    #include "key.h"
    
    int main( void )
    {
      // Stop watchdog timer to prevent time out reset
        WDTCTL = WDTPW + WDTHOLD;
        FLL_CTL0 |= XCAP14PF;                     // Configure load caps
        time_init();
        KeyInit();
        __bis_SR_register(GIE);
    
        while(1)
        {
            __bis_SR_register(LPM3_bits);           // enter LPM3, clock will be updated
            char key = ReadKey();
            if(key=='0'&&state==1)
            {
                setDate(2015,TI_month>9?TI_month-5:TI_month+1,(TI_day>>4)*10+(TI_day&0x0f));
            }
            if(key=='1')
            {
                if(++state == 7)
                {
                    state = 0;
                }        
            }
            if(key=='2')
            {
                switch(state)
                {
                    case 1:
                        incrementYears();
                        break;
                    case 2:
                        incrementMonths();
                        break;
                    case 3:
                        incrementDays();
                        break;
                    case 4:
                        incrementHours();
                        break;
                    case 5:
                        incrementMinutes();
                        break;
                    case 6:
                        incrementSeconds();
                        break;
                    default:
                        state = 0;
                        break;
                }
            }
            if(state!=0)
            {
                lcd_clear();
                setting();
            }
            else
            {
                tick();
            }
        }
    
        return 0;
    }

Latest operation results

I just took this photo this morning. Yesterday (2015-10-02) evening, I found that the LCD was a little dark. I added some salt to the water, and the display effect was better, and the running time should be longer:

This post is from Microcontroller MCU

Latest reply

sharp   Details Published on 2019-7-9 20:29
 

1140

Posts

0

Resources
2
 

sharp

This post is from Microcontroller MCU
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>
Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list