Maker Pro
Maker Pro

MSP430 measure power consumption

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
Hi all ! I'm doing "energy harvester" with wireless sensor node that includes msp430g2553 MCU. Trying to measure power consumtion, but no do not go for now. Using shunt resistor (1k 5%) i have got 345uA for active and 320uA for LPM3 mode. I thout that is something wrong here. Measured using multimeter - got almost the same results - 319uA for LMP3 mode ! Do not understand...It means that MCU do not go sleep ? Testing algorythm is : waiting for button press, then send some data using UART (150 in my code), after that go to sleep (LPM3) and wake up when UART RX or P1 BIT4 interrupt occures. Now everything is acting as is should, only current consumtion is very high in LPM3. Maybe someone can find mistake in my code (sorry for my language comments and variables in the code :) ) . Thanks !

#include <stdio.h>
#include "serial.h"
#define LED0 BIT0
#define LED1 BIT6
#define RXD 0x02
#define TXD 0x04
#define MYGTUKAS 0x08


volatile unsigned int skaitliukas=5, leisti=0,miegoti=0;

void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;

uart_init(); //is header failo

P1DIR &=~MYGTUKAS; // Mygtukas kaip įėjimas BUTTON as INPUT
P1OUT |= MYGTUKAS;
P1REN |= MYGTUKAS; // Enables pullup resistor on button

P1DIR |= LED0;
P1DIR |= LED1;
P1OUT &= ~LED0; //pradine busena - off
P1OUT &= ~LED1;

P1IE |= BIT4; // igaliname P1.4 pertraukti interrupt fot P1 BIT4

UC0IE |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__enable_interrupt();

while(1)
{

P1OUT|=LED1; // LED for indicating active mode

if((P1IN & MYGTUKAS)==!MYGTUKAS) { // Was button pressed?
P1OUT ^=LED0 ;
leisti^=0xFF;
__delay_cycles(500000);
}

if (leisti==0xff) //START FLAG
{
//SENT DATA FOR RF MODULE

send_int(9); //duomenu nusistovejimui
__delay_cycles(23000);

send_int(1);
send_int(2);
__delay_cycles(23000);

miegoti++; //counter for sleep mode

}
if (miegoti>=150) { //go to sleep

P1OUT &= ~LED1; //išjungiam LED indikuodami kad miegam LED1 OFF
P1OUT &= ~LED0; //išjungiam LED indikuodami kad miegam LED0 OFF
miegoti=0x00; //clear sleep mode counter
leisti=0x00; //clear start flag
_BIS_SR(LPM3_bits + GIE); // Einame i LPM3 miego rezima Go to LPM3 mode
}
} //while pabaiga
} //main pabaiga


//----------------------------------P1 BIT 4 interrupt -----------------------------------------

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1IFG &= ~BIT4; // P1.4 IFG cleared
P1IES &= ~BIT4; // toggle the interrupt edge,
_BIC_SR(LPM3_EXIT); // Pabusti is miego rezimo LPM3 //WAKE UP
}
//----------------------------------UART RECEIVED interrupt---------------------------------------

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
if (UCA0RXBUF == '1')
{
//for future
}
_BIC_SR(LPM3_EXIT); // Pabusti is miego rezimo LPM3 //WAKE UP
}
//------------------------------UART TX interrupt----------------------------------------

#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
//for future
}
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Can you post a complete schematic as well?
 

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
For the moment schematic is not completed. Here it is:

Need there invert reset signal for msp, also add RF RX module and two reed switches and more..

Now i'm imitating everything on launchpad with button and wires.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
How are you measuring the current? Can you show that on the schematic?

The way you are switching power to P5 won't work. An N-channel MOSFET requires its gate to be driven several volts positive relative to its source. You need to use a P-channel MOSFET with source and drain swapped. The MOSFET will be ON when its gate is pulled to 0V and OFF when its gate is high.

When you regenerate your schematic can you save it in some format other than JPG? JPG is only designed for continuous-tone images such as photographs; other formats such as PNG or GIF will give a cleaner image at a smaller file size.

You can attach your image to your post - use the Upload a File button.
 

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
When I measure current i use 3.3V straight to the pin 1, also no jumpers to emulation part, and no jumpers on LED's. Only MSP. I do it like this :

Or insteed multimeter shunt resistance, then voltage drop/resistance = cirrent. Almost same result..
 

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
Little news from me. There are some bugs in MSP libs, so insteed _BIS_SR(LPM3_bits + GIE); for go sleep and _BIC_SR(LPM3_EXIT); for wake from sleep need use LMP3; and LMP3_EXIT; functions. Now i have <10uA in LMP3 mode.
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
Great! Is that what you were expecting?
 

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
I'm expecting forever lasting device :D joke. I want to get as low as possible power consumption for my device. Here is algorithm that i want to implement with lowest power consumption:algorithm.png
 

wdariusw

Nov 10, 2014
149
Joined
Nov 10, 2014
Messages
149
Hi again ! KrisBlueNZ said that #3 post power to P5 wont work. Please see now and give opinions about powering MOD1, MOD2 and MSP. Will it work now? thanks !
 
Top