Playing with high voltage

Now I’m playing with high voltage.

Well,12v DC which is much higher than the 5v I’ve been dealing with. And to increase my chance of hurting myself I’ve been dealing with higher current in the 2+ amp scale, which is much higher than the 60mA I’ve been working with. So I’ve been careful not to cross the streams like Egon.

The circuit is really simple: power, MOSFET to switch on the current, and a pull-down resistor. Now that I have an idea of how to get higher-intensity lighting with Arduino, I can reevaluate how the main lamp will be constructed.

quickMOSFETsketch_bb

quickMOSFETsketch_schem

 

Logic board update

Lots of movement on the logic board today.

Instead of printing and assembling 16+ LED boards plus a logic board, why not just put it together (like PB&J) onto one board? Then I only need to attach one PCB to the enclosure, and the less things I need to do myself, the better.

Below you can see a Fritzing printout taped to a 1/2″ piece of foamcore inside a prototype enclosure. I expect that the base will be thicker in order to house more stuff, and by stuff I mean at least a battery and charging mechanism, and so that I can hold the Lamp without touching the glass.

IMG_7413

As I was showing this around the office, a gauntlet was thrown down: why use an Arduino Uno r3 when I could use a smaller version without any penalty in processing or functionality, with the added gift of miniaturizing the stack? I didn’t have an answer to this, except, “Umm.”

So challenge accepted!

BigRound+LED+MINI-2_pcbI have now integrated an Arduino Pro Mini 5v into the PCB stack. I also added some power flexibility by adding a power mounting block and an external 5v voltage regulator, even though the Pro Mini can accept up to 12VDC and has a built-in voltage regulator. I wanted to split out that function so that the Arduino doesn’t have to do any additional work. Also, I don’t know exactly how much power the main light will take, and I want some headroom to attach the largest battery I can safely source.

You might remember, dear reader, that I originally started this experiment using an Arduino Pro Mini 3v3 board (oh how we go round the bend again). I decided against reusing the 3v3 board because the GPS module which I found to be most stable needs 5v and I don’t want to go around shifting voltage where I don’t need to. I’m all about reducing complexity now.

With that in mind, I am certainly thinking about removing IC3 & IC4; IC1 & 2 run the 16 compass LEDs, while IC3 & 4 are two additional shift registers  which are legacies from my original idea to build my own LED lighting array. I am now considering using an LED string such as this one sold by Adafruit or a single point source I can vary in intensity (yet to be sourced). Moving my main power supply from a 3v3/5v LiPoly source to a high voltage battery would open up more lighting sources I could use efficiently.

Adafruit and Sparkfun orders placed, let’s play with it when they arrive.

 

 

 

Compass PCB prototype 02

Building on the Compass PCB prototype 01 I’ve updated the PCB so that I can install the 16 boards easier, along with doing some little things to reduce the amount of wires which will need to run this array.

LED PCB v0.4I created a Ground Bus which I can solder to Board 01 from the Arduino GND and then daisy chain the next 15 together, so I get rid of 15 unnecessary wires. I then moved the +5v feed (which will come from the shift registers) to the top, so I can solder wire, straight, or angled headers depending on what I decide. Lastly, I moved the support holes to the center so that I will be able to flip the board one way or another to install it. This will allow me to manage the 16 wires which go back to the shift registers in a logical way. How I will do that is for another day, at least I know I have options, and I’m giving myself some flexibility here.

 

 

A note about power consumption

The Lamp is a portable object which communicates with the satellites in order to find important (or not) places in the world, and then shine a light.

Pretty simple. But the details are important.

The important part of the above sentence is the concept of portability. I can’t tether the lamp to mains power, or require a giant car battery.

Of all the limitations this project has, is the battery. Right now I’m specifying a 3.7v 2000mAh Lithium Ion Battery with an alternate being the 3.7V 6600mAh Lithium Ion Battery Pack, and connecting it to the system through an Adafruit PowerBoost 500 rechargeable 5V power shield. I guess I could design my own charging system, but lithium-ion batteries scare me. They pack a lot of power per cubic centimeter, but don’t play well with others, tending to melt or blow up if they are shorted, bent, crushed or punctured. So, I will have to create a cage for it so it doesn’t hurt me.

Let’s look at what the system draws without lighting the lamp at all:

Component unit
Arduino35.00mA
Compass board0.11mA
Compass LED20.00mA
GPS board55.00mA
Total110.11mA

So I have 2,000 mAh at worst case battery to play with, but let’s assume a 10% reduction due to recharging, storage loss, etc. This gives me 1,800 mAh to work with. I also am assuming worst-case scenario where the lamp is fully lit (for example at a center of population). In reality, most of the time all the LED’s will be lit. I’m sure there I can use calculus to find the slope and areas of illumination to derive the typical power consumption.

Item1 hr ops2hr ops3hr ops4hr ops
System power110.11220.22330.33440.44
Lamp power remaining1689.891579.781469.671359.56
WS2812 LED @ 60mA
(round down)
28 lamps26 lamps24 lamps22 lamps
Luminous Intensity @ 233 (mcd)36524 mcd6058 mcd5592 mcd5126 mcd
R20WHT-F-0160 @20mA
(round down)
84 lamps78 lamps73 lamps67 lamps
Luminous Intensity @ 600 (mcd)350400 mcd46800 mcd43800 mcd40200 mcd

Besides the total power available, the real limiting factor of the battery is the standard discharge of 500mA which can peak at 1000mA. I don’t want to go toward peaking, because see exploding, above.

I have some options: I could source alternative batteries, use multiple batteries to run different systems or parts of systems, or find a better illumination system so I can get the maximum luminance per mA.

 

Compass Prototype 1

Building on yesterday’s Compass LED PCB prototype, I wanted to get the compass actually working so I could drive some LED’s.

Using Adafruit triple-axis accelerometer & magnetometer LSM303 and NeoPixel Ring – 24 x WS2812 RGB LED, I was able to get a functioning digital compass fairly quickly utilizing the Adafruit_LSM303 library.

I don’t know if I will use off-the-shelf LED’s for the compass as shown in the Compass PCB prototype 01 or use a Neopixel version via SparkFun, the WS2812 RGB LED Breakout. I save about 1.3 mA per LED versus my chosen through-hole LED if I use the WS2812 with a single channel of the RGB on, but to get white it costs me 60 mA! If I use this breakout board I won’t have to assemble or test out the components and boards or test out a self-designed board, which is a huge time saver and reduces the change of me messing up, but I don’t think I can afford the power for the compass.

If I use the Neopixel for the compass, I’m stuck using the Neopixel library for the compass and my home-brew shift registers to drive the lamp subsystem. Which might not be a problem since they both do different things. In the end it might come down to aesthetics: which system do I want more control over the color of light, the lamp or the compass? I think I would want more control over the lamp colors via the Neopixel than control the color of the compass.

Compass Prototype 01

Until I get a handle on my power consumption, I won’t be able to choose one system over the other.

 

 

Compass PCB prototype 01

I’ve been thinking a lot about the Lamp’s compass. Creating a Lamp with built-in dowsing rod capability will both increase complexity – a major headache is dealing with all the shift registers and the accompanying 16 LED’s – not to mention the added power load required to drive an accelerometer and magnetometer continuously. But it will be cool. And that’s the whole point, right?

Magnetic Declination of NE USAWhy do I need both an accelerometer and a magnetometer. The magnetometer is self explanatory: I need to know which way is magnetic north and compare that to the local Lamp heading so I can turn on the correct LED to point me in the right direction. I don’t have perfect balance. The accelerometer is essential to compensate for a non-flat magnetometer reading. I can also get fancy and begin to compensate for magnetic declination by both reading the accelerometer and the GPS location. If I want to get fancy.

I’ll deal with the power consumption and compass later, but right now the thought of custom making then soldering 16 LED housings to make a hexakaidecagon (hexadecagon) makes me want to run down the street. Luckily, I’ve been messing with Fritzing Fab and designed my own little LED PCB which will hold the LED, a resister, pins to go to ground and to the proper shift register, and mounting holes. At US$2.15 per board each one isn’t exactly cheap, but I will have a consistent and rugged board to mount the electronics to and then to an internal housing. Kit-bashing my own would both be more time consuming and I would have 16 times to foul it up.

I tried to fabricate my own LED harness with MakerBot, but it just was a pain in the butt to fab and then I still had all the electronics to deal with anyway. I might have to fab one anyway to hold the PCB’s but that will just give me another factor of safety with the electronics.

LED_Ring_01

LED_part2_pcbAs it is, this board might win as the most simple board produced by Fritzing, but you try to create a run of 16 (or 32 in case I mess up) boards yourself. I’m going to rely on mass production on this one.

IMG_7337.JPG

 

Prototype 4 – Compass

Another day, another module. This time a compass, well, a magnetometer. In this case a triple-axis Accelerometer+Magnetometer (Compass) Board – LSM303 from Adafruit. This module will allow the lamp to know which direction (nominally) it is pointed.

Besides the lamp becoming brighter the closer it gets to a center of population, there is a compass ring which can point you in the correct direction. Prototype 3 with the shift registers is an early concept of the 16 LED’s, albeit in a straight line.

Conceptually it should work this way: the GPS module will calculate the distance between the Lamp and the closest Population Center, and get the numerical direction in degrees. The LSM303 will calculate the local orientation of the Lamp. Then we can compare the two, do some math, and light one of the 16 LED’s. Here is a great example (code) using Adafuit’s NeoPixel’s (warning, loud music):

Right now, the compass module is orienting what appears to be fairly close to precise measurements (using my trusty compass) and the trust sharpie + post-it combination. I just need to build the LED array, but that shouldn’t be too bad, but that is dependent on evolving the case design an additional step.

I am a bit concerned about magnetic interference from the other components, so I will have to find a place for it far away from the battery and the GPS module just in case.

IMG_7297.JPG

 

 

Prototype 3 – Shift Registers

Now that both the GPS subsystem is at a good place and there is some material exploration going on, it is time to look at how to turn on a large amount of LED’s.

Photo by SparkFun

Shift Registers are fun little digital circuits where all they do is continually cascade bits, shifting in the data present at input and shifting out the last bit. The nice result is that you can drive multiple items – such as large array of LED’s – with only three pins: a clock pin, a latch pin which stores the data, and a data wire. I don’t know the upper limit, but at some point there becomes too many IC’s to sync at the right speed and you have too many LED’s to run off of the given power.

So now I can drive a n = (∞ − 1) amount of LED’s for the lamp itself, with power being the limiting factor, and have room for other items.  The upshot is that I can now easily drive the Compass subsystem –  an array of 16  LED’s which correspond to the 16 cardinal directions. Combining the GPS output from Prototype 1 with two shift registers was easy – with the help of Serial to Parallel Shifting-Out with a 74HC595 from Arduino. Mostly it is a lot of wiring and making sure that you have the clock, latch, and data wires connected properly. The hardest part was finding enough resisters to connect all the LED’s so they wouldn’t short out.

Here’s a photo of the prototype board, on the roof once again since the GPS module is having a hard time acquiring a signal from the satellites.

Prototype 3

 

Prototype 2 – Material & Blink Test

After successfully getting the GPS subsystem to a respectable place, I wanted to see what kind of size and shape of container would work.

wood-sample-02I’m interested in the lamp being sandblasted/frosted with the light bright and diffuse with the electronics hidden inside. I want to encourage people to touch the lamp, so the palette feels right to be a wood and glass combination, so where a human would grab the lamp, they would be touching a natural fibrous material. I don’t know what type of wood to use. Maybe a burl Maple or a Cherry carbonized. Right now, I’m interested in the base to be darker and more solid that the light emitting top.

The wood base will be an open item for a bit, so I took a large mason jar we have in the office, some tracing paper, an Arduino with a blink program running, and I soldered a bunch of LED’s on a stick.

 

Prototype 1 – GPS Module

This is the first time I have seriously worked with Arduino’s and physically building electronics, I wanted a way for me to remember what happened and document the many failures and few successes I will have.

Because the Lamp will have a series of different subsystems, I wanted to prototype and test out each one individually, because I don’t have a fully clear picture of what and how this project will evolve. I figure I have the following major subsystems:

  • GPS subsystem
  • Compass subsystem
  • LED lamp subsystem
  • LED directional subsystem
  • Power subsystem
  • Enclosure

I started with the GPS subsystem first, since I didn’t want to blow up anything messing with Lithium-ion batteries, and the GPS subsystem is the most important part.

I used an Arduino Pro Mini 328 – 3.3V/8MHz (buy: Amazon or Sparkfun) because I was worried about both size and power consumption. If this lamp was going to be the smallest and most portable lamp I could make, then I wanted to make sure that I wasn’t wasting space with the full Arduino shield.

GPS Prototype 1

With the choice of Arduino board my base voltage and speed was decided, I could then choose the GPS module. Sparkfun has a very nice GPS Buying Guide which helps put all their modules side-by-side. I chose the  GP-2106 SiRF IV with GP-2106 Evaluation Board to connect it to the Arduino based on current draw and size. One warning: this GPS module is very tiny with a tiny ribbon cable – through my testing both are a bit  fragile. The GP-2106 Evaluation Board is a nice way to connect the GPS module, but is also a bit finicky. That’s a technical term, but the problems I was having was to wake the GP-2106 up from sleep, which you theoretically can do by pulling the ONOFF pin on the GP-2016 Evaluation Board LOW then HIGH like thus:

void gpsSTARTUP () {
 digitalWrite(gpsPin, LOW);
 delay(1000);
 digitalWrite(gpsPin, HIGH);
 delay(5000);
 }

void setup() {
 gpsSTARTUP();
 }

It would sometimes work, but the GPS module needed unobstructed view to the skies to acquire a signal, which would often take between 60-120 seconds. Which is quite the bummer when you want to test your code, but on a nice summer NY day, and excuse to go to the roof is a good excuse.

Once I got a clear GPS signal, then it was bang-on easy to do something useful with it. This isn’t due to any competence on my part, but because of  the TinyGPS++ library by Mikal Hart which is just amazing. There are many examples included with the library, so it is pretty straight forward to take the example code and hack it to do something.

I was most interested in finding my exact location, then comparing it with a list of known coordinates, then lighting up a series of LED’s. In my case, the Mean and Median centers of population were the known coordinates. To do this, a quick FOR loop is sufficient to iterate though the 40 sets of coordinates and saving which one was closest so far. If I had a bigger dataset then this might not be the most efficient, but luckily the US has only been around for 22 censuses, and the data isn’t going to change with a quick velocity so I can kludge through it. It is super easy to get the distance and course to the destination using the TinyGPS++ library – there are simple hooks you can use to get all sorts of nice information from the GPS receiver.

Here’s the code:

 const int COORD_NUM = 40;
 double popArray[COORD_NUM][4] = {
 {0, 600, 600, 0},
 {1790, 39.27500, -76.18667, 0},
 {1800, 39.26833, -76.94167, 0},
 {1810, 39.19167, -77.62000, 0},
 {1820, 39.09500, -78.55000, 0},
 {1830, 38.96500, -79.28167, 0},
 {1840, 39.03333, -80.30000, 0},
 {1850, 38.98333, -81.31667, 0},
 {1860, 39.00667, -82.81333, 0},
 {1870, 39.20000, -83.59500, 0},
 {1880, 39.06889, -84.66111, 0},
 {1890, 39.19889, -85.54806, 0},
 {1900, 39.16000, -85.81500, 0},
 {1910, 39.17000, -86.53889, 0},
 {1920, 39.17250, -86.72083, 0},
 {1930, 39.06250, -87.13500, 0},
 {1940, 38.94833, -87.37639, 0},
 {1950, 38.83917, -88.15917, 0},
 {1950, 38.80417, -88.36889, 0},
 {1960, 38.59944, -89.20972, 0},
 {1970, 38.46306, -89.70611, 0},
 {1980, 38.13694, -90.57389, 0},
 {1990, 37.87222, -91.21528, 0},
 {2000, 37.69699, -91.80957, 0},
 {2010, 37.517534, -92.173096, 0},
 {2010, 38.472967, -87.410365, 1}, //begin median center
 {2000, 38.75644, -86.93074, 1},
 {1990, 38.96528, -86.53139, 1},
 {1980, 39.31667, -86.13750, 1},
 {1970, 39.79528, -85.52861, 1},
 {1960, 39.94028, -85.28333, 1},
 {1950, 40.00333, -85.03917, 1},
 {1950, 40.00333, -84.94750, 1},
 {1940, 40.07167, -84.66973, 1},
 {1930, 40.19778, -84.60973, 1},
 {1920, 40.19778, -84.73334, 1},
 {1910, 40.12583, -85.03333, 1},
 {1900, 40.05889, -84.81694, 1},
 {1890, 40.04751, -84.66694, 1},
 {1880, 39.95000, -84.12000, 1}
 };
 // 0 for Mean center, 1 for Median center

void loop() {
 for(int i = 0; i < COORD_NUM; i++) {
 unsigned long distanceKmToLocation =
 (unsigned long)TinyGPSPlus::distanceBetween(
 popArray[i][1],
 popArray[i][2],
 gps.location.lat(),
 gps.location.lng()) / 1000;

if(distanceKmToLocation < ClosestSoFar) {
 ClosestSoFar = distanceKmToLocation;
 ClosestIndex = i;
 ClosestYear = popArray[i][0];
courseToPoint =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
popArray[i][1],
popArray[i][2]);
}
cardinalDirection = TinyGPSPlus::cardinal(courseToPoint);
}

Once I had this, then getting the Arduino to do something with the data was fairly easy, in this case lighting up an array of LED’s depending how far away from the target coordinates we are:

GPS Prototype 1B

 

For those wondering at home, here is a breadboard view and a schematic view:

 

Prototyp1 bb Prototyp1 schematic

 

Some thoughts:

  • Gee is this GPS module a pain. I think I will have to try out a few different modules.
  • If I want a lot more LED’s I will run out of space on the Arduino soon. Looks like I need to find alternative means of driving a larger number of LED’s.
  • Prototyping on the roof can be fun, sometimes:

Rooftop Prototyping