Jump to content
43oh

MSP430G2553 Power Monitoring


Recommended Posts

@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);
  }
}

 

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...