Question on a current project

57 views
Skip to first unread message

Patrick Pecoraro

unread,
Aug 27, 2016, 7:46:10 PM8/27/16
to Omaha Maker Group
I'm looking at this BOM and I can't figure out why there is a 9v Power supply. All the components are either 5v or 3.3v powered.

Also one of the pics shows a cell phone battery attached.



Dan Linder

unread,
Aug 27, 2016, 9:28:51 PM8/27/16
to omaha-ma...@googlegroups.com
It looks like they are powering everything using the Arduino UNO voltage regulator.  The UNO is capable of taking a wide input DC voltage and provides the 5V and 3.3V pins that apparently feed the GPS, LED, and servo.

Since the 9V is well above 5V, it should run quite a while depending on current draw.  If the servo was moved a lot and with some load, it could drain the 9V battery quickly.  In this case that probably won't be a problem since it is only being used as a latch.  The GPS module is an unknown, to me in this case...

The only modification I would do to this design is to put a second power jack on the outside, just in case the battery dies in the locked position.  Well, that and add an emergency open option just in case the GPS module failed...but then it is only wood, not an industrial safe.  😀

Dan

Sent from my iPad
--
Support Omaha Maker Group with purchases you make anyway. Shop Amazon using our Affiliates link, and OMG receives a portion of the proceeds. http://amzn.to/1f3i3ve
 
Leave lurking behind — come visit us at the Makery at 8410 K Street, #5, Omaha (just off 84th & L). We’re nice, we promise. http://bit.ly/1dKnTmC
---
You received this message because you are subscribed to the Google Groups "Omaha Maker Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-gr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicholas Smith

unread,
Aug 27, 2016, 9:37:01 PM8/27/16
to Omaha Maker Group
The cell phone battery picture might be his prototype and what he had at the time. It does not look like there is any 9v power supply in the picture, so when he wrote the instructions he might have replaced the cell phone batter for the 9v supply. Most of the time working with electronics you want to go higher voltage than what the electronics needed like his 9v instead of 5v because if you start with 5v and the battery drops a little bit some equipment might not work. When you program microcontrollers you usually have voltage regulators that way the microcontroller gets a steady voltage which is very important.

Patrick Pecoraro

unread,
Aug 27, 2016, 9:59:32 PM8/27/16
to omaha-ma...@googlegroups.com
so where does the other battery come into play? Dedicated to the GPS?
You received this message because you are subscribed to a topic in the Google Groups "Omaha Maker Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/omaha-maker-group/wwSSyUsrDDE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to omaha-maker-gr...@googlegroups.com.

Nicholas Smith

unread,
Aug 27, 2016, 10:16:25 PM8/27/16
to Omaha Maker Group
It looks to me that there is only one power source which connects to the Arduino UNO. They then use the regulated power from the Arduino pins to power the other electronics in it.

Kevin Fusselman

unread,
Aug 28, 2016, 12:27:21 AM8/28/16
to Omaha Maker Group

For a backup, a magnetic reed switch might be a good choice... Easily concealed, what with working right through the box...

Patrick Pecoraro

unread,
Aug 28, 2016, 12:22:31 PM8/28/16
to Omaha Maker Group
I was thinking of using a wifi arduino to remotely open the box but the reed switch is an interesting idea. Mind you the Purpose of the box is to permanently lock if the task is not completed in a certain number of distance clues, usually 50.

Patrick Pecoraro

unread,
Sep 4, 2016, 12:05:50 AM9/4/16
to Omaha Maker Group
Here is the code I'm using, with a few of my adjustments. For instance the code was originally put together for an engagement proposal. I'm using it for a birthday present so the wording has been changed. I also added an Acquiring signal message and a loading sequence. 

I have noticed a bug where some times the GPS will get a lock based on the LED going from on off every second to once every 15 seconds meaning it has a lock but the data is not passed on and so the screen still says acquiring signal. I would like to add a For loop so the Acquiring signal loop only goes say 10x before it would say "ERROR... Reset Power" At which point if the user resets the power i have seen it acquire the signal again and move on. I'm also seeing an issue where even though there is a delay after the message "Box Unlocking..." the servo unlocks immediately any way instead of waiting 10 seconds.

See code below:

/* Engagement Box   by Kenton Harris 11/12/2012
Reverse Geocache Engagement Ring Box
This program unlocks a box that has reached a certain location.

The device uses the following products from Adafruit Industries:
Ultimate GPS (version1): http://www.adafruit.com/products/746

Tutorials for these products found on learn.adafruit.com helped with much of this.
Copyright (c) 2012, Adafruit Industries
All rights reserved.

Thanks to bnordlund9 for much of the code. This is  simplified verison of his Geobox found here:
Credit to Mikal Hart of http://arduiniana.org/ for the original idea of Reverse Geocache.

*/

#include <math.h>
#include <LiquidCrystal.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3,2);
Adafruit_GPS GPS(&mySerial);
#define GPSECHO false                             //make true to debug GPS
boolean usingInterrupt = false;
void useInterrupt(boolean);

//Servo
#include <PWMServo.h>
PWMServo servoLatch;

//Declarations
const float deg2rad = 0.01745329251994;
const float rEarth = 3958.75;                                            //can replace with 3958.75 mi, 6371000.0 km, or 3440.06 NM
float range = 3000;                                                      // distance from HERE to THERE
String here;                                                             // read from GPS

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 6, 10, 11, 12);

int gpsWasFixed = HIGH;                                                  // did the GPS have a fix?
int ledFix = 4;                                                          // pin for fix LED
int servoPin = 9;                                                        // pin for servo
int servoLock = 110;                                                     // angle (deg) of "locked" servo
int servoUnlock = 0;                                                     // angle (deg) of "unlocked" servo

String there = "N29 33.550, W095 08.340";                                //Desired Location goes here. Make sure you use the same syntax and number of characters

void setup()
{
  servoLatch.attach(SERVO_PIN_A);
  servoLatch.write(servoLock);
  delay(50);
  lcd.begin(16, 2);
  Serial.begin(115200);
  Serial.println("Debug GPS Test:");

  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);                          // RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);                             // 1 Hz update rate
  useInterrupt(true);                                                    // reads the steaming data in a background
  delay(1000);
  

}

void loop(){
  // Parse GPS and recalculate RANGE
  if (GPS.newNMEAreceived()) {
    if (!GPS.parse(GPS.lastNMEA()))                                      // also sets the newNMEAreceived() flag to false
      return;                                                            // We can fail to parse a sentence in which case we should just wait for another
  }
    if (GPS.fix) {
    gpsWasFixed = HIGH;
    digitalWrite(ledFix, HIGH);

  
    here = gps2string ((String) GPS.lat, GPS.latitude, (String) GPS.lon, GPS.longitude);
    range = haversine(string2lat(here), string2lon(here), string2lat(there), string2lon(there));
    Serial.print("Here: ");                                        //for GPS debug
    Serial.print(here);
    Serial.print("There: ");
    Serial.println(there);
    Serial.print("Range: ");
    Serial.print(range);
    Serial.println(" Miles");
    
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Signal Locked");
    lcd.setCursor(0,1);
    lcd.print(range);
    lcd.print("Miles");

    delay(500);
  }
  else {                                                              //No GPS fix- take box outside
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Acquiring Signal");
    lcd.setCursor(0,1);
    delay(200);
    lcd.print(".");
    delay(200);
    lcd.print(".");
    delay(200);
    lcd.print("..");
    delay(400);
    lcd.print("....");
    delay(800);
    lcd.print("....");
    delay(2000);
    lcd.setCursor(0,1);
    lcd.println("Take box outside");
    delay(5000);
    
  }
  
  if (range < 20.0){
    lcd.setCursor(0,1);
    lcd.println("Box Unlocking...");
    delay(10000);
    servoLatch.write(servoUnlock);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.setCursor(0,1);
    lcd.print("Happy Birthday");
    delay(500000);
  }
}


SIGNAL(TIMER0_COMPA_vect) {
  // Interrupt is called once a millisecond, looks for any new GPS data, and stores it
  char c = GPS.read();
  if (GPSECHO)
    if (c) UDR0 = c;  
}

void useInterrupt(boolean v) {
  if (v) {
    OCR0A = 0xAF;
    TIMSK0 |= _BV(OCIE0A);
    usingInterrupt = true;
  } else {
    TIMSK0 &= ~_BV(OCIE0A);
    usingInterrupt = false;
  }
}

String int2fw (int x, int n) {
  // returns a string of length n (fixed-width)
  String s = (String) x;
  while (s.length() < n) {
    s = "0" + s;
  }
  return s;
}

String gps2string (String lat, float latitude, String lon, float longitude) {
  // returns "Ndd mm.mmm, Wddd mm.mmm";
  int dd = (int) latitude/100;
  int mm = (int) latitude % 100;
  int mmm = (int) round(1000 * (latitude - floor(latitude)));
  String gps2lat = lat + int2fw(dd, 2) + " " + int2fw(mm, 2) + "." + int2fw(mmm, 3);
  dd = (int) longitude/100;
  mm = (int) longitude % 100;
  mmm = (int) round(1000 * (longitude - floor(longitude)));
  String gps2lon = lon + int2fw(dd, 3) + " " + int2fw(mm, 2) + "." + int2fw(mmm, 3);
  String myString = gps2lat + ", " + gps2lon;
  return myString;
};
/*
float string2radius (String myString) {
  // returns a floating-point number: e.g. String myString = "Radius: 005.1 NM";
  float r = ((myString.charAt(8) - '0') * 100.0) + ((myString.charAt(9) - '0') * 10.0) + ((myString.charAt(10) - '0') * 1.0) + ((myString.charAt(12) - '0') * 0.10);
  return r;
};*/

float string2lat (String myString) {
  // returns radians: e.g. String myString = "N38 58.892, W076 29.177";
  float lat = ((myString.charAt(1) - '0') * 10.0) + (myString.charAt(2) - '0') * 1.0 + ((myString.charAt(4) - '0') / 6.0) + ((myString.charAt(5) - '0') / 60.0) + ((myString.charAt(7) - '0') / 600.0) + ((myString.charAt(8) - '0') / 6000.0) + ((myString.charAt(9) - '0') / 60000.0);
  //Serial.print("float lat: ");
  //Serial.println(lat);
  lat *= deg2rad;
  if (myString.charAt(0) == 'S')
    lat *= -1;                                                           // Correct for hemisphere
  return lat;
};

float string2lon (String myString) {
  // returns radians: e.g. String myString = "N38 58.892, W076 29.177";
  float lon = ((myString.charAt(13) - '0') * 100.0) + ((myString.charAt(14) - '0') * 10.0) + (myString.charAt(15) - '0') * 1.0 + ((myString.charAt(17) - '0') / 6.0) + ((myString.charAt(18) - '0') / 60.0) + ((myString.charAt(20) - '0') / 600.0) + ((myString.charAt(21) - '0') / 6000.0) + ((myString.charAt(22) - '0') / 60000.0);
  //Serial.print("float lon: ");
  //Serial.println(lon);
  lon *= deg2rad;
  if (myString.charAt(12) == 'W')
    lon *= -1;                                                           // Correct for hemisphere
  return lon;
};


float haversine (float lat1, float lon1, float lat2, float lon2) {
  // returns the great-circle distance between two points (radians) on a sphere
  float h = sq((sin((lat1 - lat2) / 2.0))) + (cos(lat1) * cos(lat2) * sq((sin((lon1 - lon2) / 2.0))));
  float d = 2.0 * rEarth * asin (sqrt(h)); 
  //Serial.println(d);
  return d;
  
};

Patrick Pecoraro

unread,
Sep 8, 2016, 1:52:52 AM9/8/16
to Omaha Maker Group
Okay its all soldered together but I'm running into an issue. When powered by USB everything works great no issues. However when I try to power it via the 9v battery on the Vin pin It works fir a few seconds but the the LCD starts to quickly blink and fades out after each blink. I checked the current draw and the circuit is only pulling 70mA. The battery is rated to 100mA peak.

Any insight is appreciated. I was hoping to have this thing shipped already but with the battery issue and not having a viable locking mechanism yet.. it'll have to be a late bday present.

David Knaack

unread,
Sep 8, 2016, 10:09:46 AM9/8/16
to OMG
That's a fair amount of current for a non-lithium 9v battery, possibly the voltage is dropping low enough that your voltage regulator is giving up. Check the voltage after you turn it on and see how far it drops over those few seconds. I don't know what the minimum for the voltage regulator you are using, but as a guess it'll need around 6v.

--
Support Omaha Maker Group with purchases you make anyway. Shop Amazon using our Affiliates link, and OMG receives a portion of the proceeds. http://amzn.to/1f3i3ve
 
Leave lurking behind — come visit us at the Makery at 8410 K Street, #5, Omaha (just off 84th & L). We’re nice, we promise. http://bit.ly/1dKnTmC
---
You received this message because you are subscribed to the Google Groups "Omaha Maker Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.

Patrick Pecoraro

unread,
Sep 8, 2016, 12:35:53 PM9/8/16
to Omaha Maker Group
That's the thing it is a Lithium 9v. I tried it on another Arduino a clone and got the same thing. However on the clone Arduino the math is screwed with the destination I put in it should be 1000mi away and is with the Stock Arduino Uno, but on the clone its reads with the same code nothing changed that the distance is 7500miles away.

What I am noticing is that the circuit works fine before the GPS gets a lock. Once it gets a lock then it starts to fade. I am wondering if the GPS pulls more power when the lock is present. I have yet to test this, I'll have to look at that when I get home today.

So you think it could be a voltage drop not a mA increase? How would I test that? Do I test it on the Battery terminal or on the output from the ardiono What pins are those the 5v and the GND?
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-gr...@googlegroups.com.

Ben Hutcheson

unread,
Sep 8, 2016, 12:53:47 PM9/8/16
to omaha-ma...@googlegroups.com
A lithium 9v can actually handle quite a bit more than 100 mA.  Energizer's data sheet doesn't show a serious drop in capacity until a full 1A draw.  At 100 mA it's holding more than 5v for 7 hours.  You can always measure the voltage while the circuit is loaded, to see what the battery is doing, but I really doubt that's the issue.

How did you measure your current draw?  70 mA seems awfully light; I've measured that exact model of servo and seen 300+ mA just holding a position against light load, and well over 1A while moving.  I'd imagine the issue is related to current drawn by the servo.  What does the servo do before and after the GPS gets a lock?  I wouldn't expect the GPS itself is the issue, but if the servo isn't given any signal until the GPS lock is established, you would see a huge spike in servo power as soon as you had GPS.

All that aside, I think we're looking at symptoms here and glossing over the actual problem.  It works on a USB power supply and it doesn't work on a battery, right?  That's because the moment you switch to 9v input, you're running through the linear voltage regulator on the Arduino.  When you put a big load like a motor/servo on it, it's trying to drop a couple watts, overheating, and shutting down to protect itself.  Adding a heatsink to the regulator might help.  Even better would be feeding the box on 4xAAA batteries, or using a separate (bigger) voltage regulator to feed the system off the 9v.

To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.

David Knaack

unread,
Sep 8, 2016, 1:24:44 PM9/8/16
to OMG
"So you think it could be a voltage drop not a mA increase?"

One follows the other. I think your circuit is drawing too much power, causing a problem at the regulator. Either the battery voltage is sagging below what the regulator needs (Uno docs say 7V minimum) causing it to shut down, or its drawing too much current causing it to shut down.

I agree with Ben about the servo being a likely problem. You could try moving it to a bigger regulator (don't forget the caps) or directly to the battery if your servo voltage rating is suitable.

You can test the voltage just by watching the voltage on the battery leads while it is running. If it drops much below 7V that could be a problem.

To test current you can put the meter in series with a battery lead, if current goes above 200mA for very long, that could be a problem.

Don't assume it is one or the other, could be both. 

To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.

Patrick Pecoraro

unread,
Sep 8, 2016, 6:30:09 PM9/8/16
to Omaha Maker Group
Not sure its the servo the servo is only used once you get to your location. And only to turn 90 degrees. In the situation I mentioned the servo never moves. 4xAAA space is at a premium still haven't figured out the locking mechanism.


On Saturday, August 27, 2016 at 6:46:10 PM UTC-5, Patrick Pecoraro wrote:

Patrick Pecoraro

unread,
Sep 8, 2016, 8:09:07 PM9/8/16
to Omaha Maker Group
So I tested the voltage and it was dropping down to 5.5v. That was on a Tenergy Lithium Cell, I switched to a Sony Stamina Platinum Alkaline Cell And it works fine holds at around 8.8v and draw max 120mA. It does still blink a bit but it does not fade out. I'll Pick up an Energizer lithium and see how well that holds up. I got the Tenergy because it was the only data sheet I could pull up while at fry and had a 1200mAh rating. Now to see if that happens with all Li Cells.

Dan Linder

unread,
Sep 8, 2016, 8:16:34 PM9/8/16
to omaha-ma...@googlegroups.com
In the past when I've had servos that cause power draw issues, I've put a capacitor over the +5/Gnd pins of the servo so it draws from that if the regulator can't handle it.

If you're concerned about the 9V battery keeping up the voltage and current you could add another capacitor between +9/Gnd just before the regulator.

I'm not 100% certain the second option will really help if the 9v battery is really the weak link.

Here's an Adafruit article discussing the use of capacitors as described in the first paragraph.

Good luck!
Dan

--
Support Omaha Maker Group with purchases you make anyway. Shop Amazon using our Affiliates link, and OMG receives a portion of the proceeds. http://amzn.to/1f3i3ve
 
Leave lurking behind — come visit us at the Makery at 8410 K Street, #5, Omaha (just off 84th & L). We’re nice, we promise. http://bit.ly/1dKnTmC
---
You received this message because you are subscribed to the Google Groups "Omaha Maker Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
***************** ************* *********** ******* ***** *** **
"If you wish to make an apple pie from scratch, 
  you must first invent the universe."
  -- Carl Sagan

"Quis custodiet ipsos custodes?"
    (Who can watch the watchmen?)
    -- from the Satires of Juvenal

"I do not fear computers, I fear the lack of them."
    -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************

Patrick Pecoraro

unread,
Sep 12, 2016, 9:41:19 PM9/12/16
to Omaha Maker Group
Okay so power issues are behind me. I just figured out how to get the locking mechanism working. Only to have the GPS distance calculation go crazy. Its the same error I was getting with the other Arduino clone board. The distance calculation seems to have gotten off by 6,623mi. It was showing a slightly off 1075mi to the target location only off by a few miles of 1059mi. I was planning to go wonder around this evening testing the distance calculations but now its completely off and there was no code change for the distance calculations. It has to have to do something with how its being uploaded to the Arduino from the IDE.  Any help is appreciated, I'm at a loss.


On Saturday, August 27, 2016 at 6:46:10 PM UTC-5, Patrick Pecoraro wrote:

David Knaack

unread,
Sep 12, 2016, 11:50:05 PM9/12/16
to OMG
Have you set it up to dump the NMEA sentences to a console so you can take a look at the quality of data you are getting?

Patrick Pecoraro

unread,
Sep 13, 2016, 8:36:18 AM9/13/16
to Omaha Maker Group
I have and I get the correct coordinates output but the distance is still off. I've attached the sketch if you have time to look at it. 
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-gr...@googlegroups.com.
Ryans_Quest_Box.ino

Dan Linder

unread,
Sep 13, 2016, 2:05:21 PM9/13/16
to omaha-ma...@googlegroups.com
I compared your code to the Adafruit code (https://learn.adafruit.com/reverse-geocache-engagement-box/software) the only substantive change I see that should affect that is the change in the "rEarth" float from 6371000.0 to 3958.75.  If you swap that back does the distance computation work better?

Dan

To unsubscribe from this group and stop receiving emails from it, send an email to omaha-maker-group+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Patrick Pecoraro

unread,
Sep 13, 2016, 3:58:32 PM9/13/16
to Omaha Maker Group
I'll take a look at that when I get home but I changed that because I wanted the results to be in miles. And it had been working fine with it. I'll change it back and see what happens.

Patrick Pecoraro

unread,
Sep 13, 2016, 7:38:16 PM9/13/16
to Omaha Maker Group
So I posted over on the Arduino forums and some one fixed the code using a new GPS library they had made. The distance is now relatively accurate more testing is required to verify. And the signal lock is way faster.

Attached is the refined sketch if you are interested.


On Saturday, August 27, 2016 at 6:46:10 PM UTC-5, Patrick Pecoraro wrote:
Ryan_Quest_box_Mark_II.ino
Reply all
Reply to author
Forward
0 new messages