Monday, June 30, 2014

Life Change

Today I successfully defended my PhD dissertation defense.  Except for some administrative paperwork, I have matriculated here at Wichita State University.

Today is also the day my wife gave notice at work.

Both of these events have been driven by the fact that a few weeks ago, I accepted a full-time position at Pacific Northwest National Lab in Richland, Washington.  The work I expect to do there is very similar to what I've been doing at Wichita State: research on the power grid.  Beyond that it is hard to say what my daily work will look like.

Landing the job at PNNL has been a series of divine interventions.  My relationship with the lab began during a class I took several years ago in which I ended up using a simulator they had been developing.  I emailed a number of times seeking help on using the software and ended up arranging a face-to-face with the developers during a conference we both attended that summer.  When I began looking for a job late this last spring, I emailed the developers and they pointed me towards a position that would be opening soon.  I applied, did a phone interview, and in just a few weeks, was flying up for an on-site interview.  Less than two weeks after that, I was told I had the job.

Life since then has been very full.  With a full-time position secured, I was highly motivated to finish up my dissertation.  My wife and I began scheduling all the various tasks and trips that needed to be taken before my start date in late August: moving company survey, house repairs before putting our house on the market, a house-hunting trip in Washington, camping trips with both sides of the family, moving company packing all our goods.... Some of these have taken place already, some haven't and the logistics never seem to end.

But there's been enough break in the action for me to write these few paragraphs. I'm incredibly grateful and thankful for the job and am glad that I'll be able to put my degree to use. My wife is thankful to be done working at her current company and looking forward to a new, job-free life.  We're both looking forward to the change in climate and the proximity to much more interesting geography.

In those regards, the change is good. Even without all the stress of the move, though, leaving is hard.  We have good friends and a strong community here.  Neither of us are extroverts and making new friends will be difficult for us.  There's a new town to get used to, a new way of life to establish, a new home to settle into. The accumulation of these challenges is not trivial and can be overwhelming to contemplate. So we don't.  By the grace of God, we've made it this far and I expect He'll carry us through the remaining difficulties. Its clear something is going on and we'll just have to wait to find out how it all plays out.

Monday, June 16, 2014

Ain't No Amazon

We've needed to replace our stall shower door handle since we bought this house.  It has been broken and corroded; barely functional and not pretty. Katie found a replacement at HomeDepot.com and to get free shipping we ordered a few other items were planning on picking up from one of there brick and mortar locations.  The order was placed with an expected delivery date on the upcoming Friday.  Not Amazon Prime but plenty fast enough.

The first sign of trouble came when I noticed the credit card transactions related to this purchase: five charges, one for each item.

When a package showed up Thursday I was impressed.  That is until I lifted it off the porch and realized that it did not contain my order, at least not all of it.  Inside that toaster-oven-sized box was one of the five items I had ordered: five fuses.  These fuses could have been sent in a padded envelope but they were instead bubble wrapped to fill the much-too-large box and shipped out to me.

Friday three boxes arrived and today, Monday, the final box showed up.  Five items, five boxes, five shipping charges that I didn't have to pay.  There is no way they made money on this transaction unless they have incredibly favorable shipping arrangements. My guess is that until they get their logistics more stream-lined, they are going to be losing money for quite a while with their online transactions.

Tuesday, June 03, 2014

Upgrading the Power Supply


In my dabbling in hobby electronics, my primary power supply is the one that I built in my third semester of my undergraduate education.  Building this supply was the primary task in Electronics Lab I (required at the time for all engineering students of every stripe) and it took around half the semester to complete.  The power supply was purchased as a kit that had been designed in-house for this course, making it simple enough to understand while we assembled it.  We soldered and screwed the supply together and then tediously measured its performance by the metrics we had been learning in class.

The supply itself is nothing fancy.  Its a linear supply with three independent outputs, two of them variable and one fixed at five volts. I've had to replace the transformer in the past and the paint is chipping off in many places. It still works fine and I no intention of replacing it any time soon.

The biggest pain in using it, though, is that it contains no displays indicating the voltage of the variable outputs.  Historically, I've used a voltage meter to set them. In searching for a simple digital voltmeter for another project, I realized I could use the same item to add displays to my power supply. For just a few bucks, I found the part on eBay and was able to graft them onto the supply.


There are a few more things I'd like to do in the future: add a 3.3V fixed output and add the current draw from each supply. I don't know if I have front panel real-estate but there is still plenty of room inside for such improvements.  Adding it to the list of things I'll probably never get around to...

Monday, May 19, 2014

Lorenz in Living Color: Part 6 - Testing the Combined Code

I've finally been able to integrate the two halves of my code: (differential equation solver and the LED light updater) and I'm happy to say that it works! Despite my initial testing with Processing to figure out an aesthetically pleasing choice of colors and timing, I needed to adjust some of these values once I was testing on actual hardware.  In particular, I messed around with the differential equation solver step-size (how far into the future it tries to predict the next state of the system) and added a delay in the main processing loop so that the lights didn't run along their path at a highly frantic rate. I also ended up adding in a general dimming factor, allowing me to make the whole string less bright.  At dimmer levels the saturation of the colors also improve.

I left the system running for 18 hours or so and it never stabilized into a steady-state (running only in the same lobe of the attractor); this is a good thing.  I suspect that this is more a feature of the Lorenz system than any indication of the power and accuracy of the Arduino to solve differential equations well. For my purposes, it doesn't matter; as long as the lights keep flashing and moving, I'm happy.

We're getting close to the final system, very close.  I've got the bug in how I calculate which lights to turn on that I would like to clean up but all that remains now is final assembly.  I've got the front face plate to etch and the drilling on the LED mounting plate than all that remains is putting it back into the shadow box.

So very close...

Saturday, May 17, 2014

Lorenz in Living Color: Part 5 - Calculating the LED States

With the solution of the Lorenz system in place, the next task was to figure out how to define the color state for each of the 50 LEDs I'm using.  The first task: how to figure out which LED corresponds to the latest solution.

Assuming I'm projecting the 3-D solution space onto a 2-D plane (the X-Z plane in this case), I decided to divide the dual-lobed solution space radially into octants.  Based on the X and Z coordinates of the solution, I should be able to figure out which half of the attractor I'm in. Once I know that, I can pretend each lobe of the attractor is a circle and calculate the angle of the latest solution.  Using that angle, I can then determine which LED to light up. I planned on arranging the LEDs in the shape of a butterfly and with a little bit of work came up with this pattern.  (The numbers shown are the LED number.)




Each half of the butterfly shape the LEDs will be arranged in will have 23 LEDS (excluding the common center of 4 LEDs) and this angle will define which one of these LEDs corresponds to the latest solution to the Lorenz system.

But those four common LEDs that make up the body of the butterfly, those are a little tricky. They need to be considered in their own special way.  Once the solution is in this region, it could be taking a path as a part of either lobe in the attractor. Rather than try to figure out which half it is in, I decided to make a special rectangular region right down the middle.  If the solution landed in this area, I didn't decide which half it was in, I just figured out which of the four LEDs best matched the vertical position of the solution.

To keep it all straight I made a diagram.  I have referred to this often, especially as the development of this project has spanned multiple years and I've need to remind myself what all this means.  What you see below is the 3-D solution projected onto the X-Z plane along with all my annotations to remind me what was going on.


To increase the aesthetics of the project, I wanted to do more than just light up the LED corresponding to the current solution.  As I've already said, the LED was going to be colored based on the X, Y, and Z values of the solution.  But his solution would not necessarily progress smoothly from one LED to another.  To create that smooth transition, I needed to light up all the LEDs between the LED that was going to light up and the LED that was currently lit up, filling in any gaps with a gradual shift in color between the two. Looking at the butterfly pattern above, this works out neatly because most of the time, the path the solution takes is corresponds to an increase in the LED number.  If the current solution lights up LED 11 and the next solution lights up LED 15, I know that I need to also light up 12, 13, and 14.

Except for that center body portion.  If the solution is running around the left-hand lobe, it regularly needs to progress from LED 26 to LED 0.  Similarly, in the right-hand lobe from 50 to 23.  I realized the solution to this problem is that if the difference between the current LED and the next LED is negative, I'm dealing with the center section.  It took some trial and error but I figured out how to handle this special case.

To test out this portion of the code, since I didn't have the LED strands mounted in the butterfly pattern, I once again used Processing.  I had my Arduino program take a set of solutions for the Lorenz system (solved off-line in Excel) and, using the program I had just written, figure out the brightness and color for each of LEDs in the butterfly pattern.  Rather driving these LEDs directly, I had them written out and saved to a file.  Processing then used this file to create an animation simulating what I could expect the final project to look like.

Here's what that animation showed:


This is more or less what I was hoping for. The animation should proceed smoothly around either half of the butterfly and it is clear there are some glitches how the Arduino calculates all of this but it will work for a prototype.

Tuesday, May 13, 2014

Daylight Alarm Clock - Indefinite Development Hiatus

To put it simply: this isn't working for us.  The real-time clock was a nice addition and guaranteed some sense of normal time-keeping but the the truth of the matter was that both my wife and I found the daylight alarm click unhelpful.  We tried different locations.  I tried different schedules, different total brightnesses, a diffusing enclosure but it simply doesn't work for us.  Maybe we've spent too long with a beeping clock but we find that preferable waking up to a lit room.  

For now, the project is being cancelled.  If we want to try it again, it should be very easy to pick it back up. Until then, no more messing with it.

Wednesday, May 07, 2014

Daylight Alarm Clock - Real-Time Clock

My wife and I are not sure yet whether this whole daylight alarm clock thing is a good idea but I'm pushing ahead for now.  The light failed to wake us the one time we've tried it and the the little direct light that came our way (the lamp was pointed at the ceiling) was too intense for early in the morning.
The first change I've made is moving the light from the dresser across the room to my night stand and putting it under  "frosted glass" (heavy scratched now translucent plastic bowl). We'll see if this works any better.

The big electronics improvement for this test is the use of a real-time clock module, driven by a DS1307. If you don't do much with embedded systems like this, it may not occur to you that the Arduino doesn't come with a built-in clock; it literally has no idea what time it is. To solve that problem common problem, there are many readily and cheaply available modules that can be purchased and wired into the Arduino.  These modules can be queried to determine the time and data and have a battery back-up so that even when they are not being powered by the Arduino, they still keep track of time.  Program the module once with the current time and you never had to worry again.

(Never is an approximation.  At some point the battery will run out and the modules have a reputation of being not atomic-clock accurate. Time can drift several seconds per day.)

Before the inclusion of the real-time clock, I had to program the Arduino with the specific number of seconds from when I plugged it in at night to when I wanted to light to begin fading up the next morning.  Now, with the real-time-clock, I let it take care of worrying about keeping track of time and I just have to program in what time I want to the fade to start.  This is progress and a lot more accurate than my previous technique.

We'll give it a few mornings try and see if we like it any better.