Go Down

Topic: Standby battery pack  (Read 218 times) previous topic - next topic

Marciokoko

I want to power an Arduino from a solar rechargeable battery pack I have.  The problem is that the pack cuts of power after a few seconds of being idle.

Here is my sketch:

Code: [Select]
#include <Servo.h>
Servo servo1;
int servo1pin = 5;
int angle1 = 0;

void setup(){
  servo1.attach(servo1pin);
}

void loop(){
  for(angle1 = 0; angle1 < 180; angle1++)  {
    servo1.write(angle1);              
    delay(25);                  
  }

    servo1.write(90);
  
  delay(3600000); //~ 1 hr
}


So on startup the servo spins of course, as it scans to 180 and returns to 90.  I come back after an hour and nothing has happened.  The arduino led is off.

756E6C

If your power pack is a backup cell phone charger, it will switch off when the current falls below a certain level, it thinks the phone is full charged and won't overcharge it, try a 1/2 watt 100 Ohm resistor across the + and - rails and see if it stays on.
You may have to go as low as 27 - 33 Ohms but watch the resistor wattage, may need a 1 watt.


Marciokoko

Ok, I just happened to take apart a UPS power unit from Tripplite and just happened to find a 47Ω resistor in there.  So I plopped it on a breadboard and it works, the battery doesnt standby anymore.  So why does this happen?

When the phone is fully charged, no current is drawn from the charger, so it shuts down.  A fully phone charged presents a large resistance which tells the charger not to push anymore energy out so it shuts down?

And then when we put the 47Ω resistor bridge between the -/+ charger terminals, it suddenly only has a small 47Ω resistance, so it starts pushing out current?

756E6C

#3
May 12, 2017, 04:02 am Last Edit: May 12, 2017, 04:20 am by 756E6C
Your assumptions are pretty much correct, problem with your fix is the resistor constantly wastes 530 mW, I wrote a simple sketch to pulse the resistor periodically to keep the power bank from timing out, I found that a 50 mS pulse through a 56 Ohm resistor every 15 seconds would keep mine alive:

Code: [Select]
unsigned long iStart; // interval start
const unsigned long iEnd = 15000; // interval end
const int pLen = 50; // pulse length
const byte pPin = 8; // pulse pin
void setup()
{
pinMode(pPin,OUTPUT);
}
void loop()
{
digitalWrite(pPin,millis() - iStart < pLen);
if(millis() - iStart > iEnd)
  iStart += iEnd;
}

You can try different length interval and pulse to find a minimum that will keep yours alive.

Marciokoko

#4
May 12, 2017, 06:44 pm Last Edit: May 12, 2017, 06:44 pm by Marciokoko Reason: image
You mean like this:


756E6C

#5
May 13, 2017, 07:32 am Last Edit: May 13, 2017, 07:39 am by 756E6C
Yes, but the 5V goes to the 5V pin, the VIN pin needs at least 7V to produce a 5V output. Don't try to drive more than about 750 mA into the 5V pin, the circuit board traces might overheat. Also, be cautious when plugging in a USB cable, if the power pack voltage is too high it may feed back into your PC and damage it, make sure the power pack voltage is well regulated 5V.

Marciokoko

#6
May 13, 2017, 03:34 pm Last Edit: May 13, 2017, 03:34 pm by Marciokoko Reason: image
The voltage from the battery pack is 5V.  I always forget the differences between the 5v pin, the Vin, the barrel jack and the usb jack.  Ill read up on that again.

As for the current draw, right now the project is just a MG995R servo and an LCD.  But in the future the project is supposed to grow to an MCU with its LCD running 4 to 8 servos, not simultaneously though.  Servo1 would run for 1 minute and stop, a couple of minutes later Servo2, and so on.  So it would not be drawing current for all at the same time.  But if I wanted to eventually connect 3 servos that would run simultaneously and I know now that I cant pull more than 750mA from pin 5V, I would set it up to run the servos separately from the mcu.

 

Marciokoko

Well i plugged it all in and didnt upload the code for the pulses, but the pack is not turning off.  I think its because the servo keeps humming after stopping.  Do I need to detach it or something?

The servo moves fine but after reaching the desired position it stops and holds there, but as it holds, it hums.  Im guessing this is just wasting energy.

756E6C

#8
May 14, 2017, 05:56 am Last Edit: May 14, 2017, 06:21 am by 756E6C
Your drawing looks fine to me but you need a VCC (5V) wire if not powering from USB.
Many cheap low cost servos do that, I guess that's the cost of "economically priced"  :) , sometimes a little spring force or something will muffle them or mount them on something solid that doesn't resonate like a guitar body.
If you detach, you should save the current position so you can write it back before reattaching (as long as the servo is not moved while detached):
Code: [Select]
currentPos = servo.read();
servo.detatch();
// and later,
servo.write(currentPos);
servo.attach(Pin);

MarkT

#9
May 15, 2017, 04:04 pm Last Edit: May 15, 2017, 04:05 pm by MarkT
You mean like this:


No, not actually like that, like the circuit given in #3, the one with the required base resistor....
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Marciokoko

Oh thanks!  Forgot the base resistor.

Marciokoko

Ok while I get this tested, (Im re-charging my lipo before I test the new code with servo detach and pulse code), I noticed that the LED lights for rx/tx on the nano remained lit throughout my delay of 1 hr with the old code.  Why would that happen?

Here is the code:

Code: [Select]

#include <LiquidCrystal.h>
#include <Servo.h>
Servo servo1;
//Servo servo2;
int servo1pin = 8;
int servo2pin = 9;
int angle1 = 0;
//int angle2 = 0;
float tempVoltage=0.0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
  lcd.begin(16, 2);
  lcd.setCursor (0,0);
  lcd.print("Koffee Servo");
  lcd.setCursor(0,1);
  lcd.print("Lipo Test");
  delay(1000);
  Serial.begin(9600);
  servo1.attach(servo1pin); ATTACH IN LOOP
}

void loop(){
  servo1.write(angle1);
  // Servo #1 ~ 2.5 secs
  for(angle1 = 0; angle1 < 180; angle1++)  {
    //Serial.println(angle1);                                 
    servo1.write(angle1);               
    delay(50);                   
  }
 
  //Read/Display voltage & wait
  readVoltage();
  delay(3600000); //3600000~ 1 hr
 
}


void readVoltage(){
  int analog_val=analogRead(A0); // read A0 and store it in analog_val
  tempVoltage = (analog_val * 5.0)/1024.0;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("V=");
  lcd.print(tempVoltage); //print v to LCD
}

Go Up