• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!
curtis63

MSP430G2553 Power Monitoring

6 posts in this topic

I'd like to monitor power and indicate to the user of my device when power is getting low (via flashing LED).  Does MSP430G2553 support power monitoring and does the Energia library have any tools to access this monitoring?

Share this post


Link to post
Share on other sites

You could use one the A/D channels connected to VCC and then check that value periodically.

Share this post


Link to post
Share on other sites

Does Energia have a function call to check the value, or does this involve reading a register somewhere?  I'm a windows developer, not a micro-controller developer (that's why I'm using Energia) :-)

Thanks for your patience with me.

Share this post


Link to post
Share on other sites

There is a dedicated channel on ADC with VCC/2.

You have to select 2,5v analog ref and select internal channel : analogRead(128 + 11) (if I remember well)

128 + X force energia to select the specific hardware channel X on analog multiplexer without mapping.

energia likes this

Share this post


Link to post
Share on other sites

@curtis63

What is the supply voltage that you will be using? Depending on that you will select the ADC reference voltage. Either 2.5 or 1.5. Sketch below should help getting started. Keep in mind that this might not be very accurate. If you would like accurate battery capacity left then I would suggest using an external fuel gauge.

#define BAT_MIN_VAL 800

void setup() {
  analogReference(INTERNAL2V5);
  pinMode(RED_LED, OUTPUT);
  digitalWrite(RED_LED, LOW);
}

void loop() {
  uint8_t val = analogRead(128 + 11);
  if(val < BAT_MIN_VAL) {
    flash();
  }
  // do other stuff
  sleepSeconds(5);
}

void flash()
{
  /* Flash LED three times. */
  for (int i = 0; i < 3; i++) {
    digitalWrite(RED_LED, HIGH);
    delay(100);
    digitalWrite(RED_LED, LOW);
    delay(100);
  }
}

 

Share this post


Link to post
Share on other sites

@Curtis63,

I've used both solutions as suggested by @energia, depending on my power choices. One thing to keep in mind if you're using the ADC is what type of battery and the typical discharge curve. Also, you need to think about when and how often you check - right after a power-intensive action may yeld different results than letting a battery recover for some pre-determined time (again, dependent on how the battery responds to loads).  My systems are powered by LiPo cells, so the higher voltage output needs at least a voltage divider, and to avoid a slow drain, the ground needs to be through a port or via some other switching device. Batteries are interesting and challenging.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now