Thursday, September 18, 2014

What I'm Learning About Insurance - Part 3

Its close to a year after I started writing about it and now that my case is settled and I have a tiny bit of free time, I've decided I'm going to try to close out my mini-series on what I've been learning about insurance. Let's pick things back up and discuss a little weirdness with liability insurance.

When I introduced liability insurance, I framed it as protection for you, the policy holder, when you do something that causes damage to somebody else.We buy this insurance because, particularly in the case of driving automobiles, it is very easy to cause a lot of damage to somebody or their property. Rather than being financially obligated to directly pay for all of the damage directly out of your pocket, liability insurance comes in and covers those payments for you (up to a certain amount).  Insurance companies do this in exchange for a relatively small monthly fee which, according to the big piles of data they have after doing this a long time, is big enough to allow them to make a profit even after paying out for all this destruction that people cause with their cars.

There are a few tricks they use to make this work. One, they are relatively selective about the type of people they insure.  There are a bunch of people at insurance companies (or people the insurance companies contract out to) called actuaries, whose job it is to figure out what kinds of things are indicators of bad and good drivers.  Past auto insurance claims?  Tickets?  Age?  This type of information allows them to asses just how risky it would be to enter this kind of liability agreement.  Furthermore, using even more data and math, they are able to make an educated guess at how much they should charge you for your monthly payment to them (your premium) in exchange for taking on this risky.  The riskier a bet you are (because maybe you've told them you always drive two times the speed limit), the higher your monthly premium will be.

The second trick to making this whole insurance thing work is to insure tons of people.  Lots and lots and lots of people, hopefully people who always signal, drive the speed limit, and have never gotten a ticket.  By being selective and pooling all those monthly premiums together, it is possible to pay for whatever destruction is caused and still make money at it. Its all statistics, a numbers game. There are no guarantees but with a good screening process and lots of people, the actuaries can find a way to make it work.

(Until recently, health insurance worked the same way.  In fact, some health insurance companies were such sticklers about only letting in healthy people that if you did end up seriously sick, they worked very hard to find a way to weasel out of the contract they made with you.  This is called "recidivism"and its one the things Obamacare  has been trying to fix.  This sneakiness and legal legerdemain on the part of the health insurance companies would be unnecessary if we had a single-payer system where there was only one insurance company; everybody would be covered by default.  Requiring everybody to have health insurance is a step in that direction but still provides some incentives for health insurance companies to try to off-load their sickest policy-holders to somebody else.)

Liability coverage is the most fundamental type of insurance and it extends to more than auto liability insurance. Ice skating rinks, home-owners, water parks, schools, fast-food restaurants, everybody has liability insurance because anybody can sue anybody at any time for causing harm or damage.  Liability insurance makes it possible for businesses to not have to hoard a huge stockpile of cash just in case they get sued for damage they may or may not have caused. During the process of transferring our home and auto insurance during our move we were asked if we wanted a general liability policy, covering our whole lives, essentially.  When I briefly owned my own legitimate window-washing business I had liability insurance in case, you know, I dropped a squeegee on somebody's head or something. Liability insurance gives us all the ability to sue for damages while allowing businesses to not exist one lawsuit away from bankruptcy.

So liability insurance is a good thing for us auto-drivers. But what happens if I have a $100,000 liability policy but I drive into an art museum and destroy their $100 million Van Gogh?  The agreement I have with the insurance company says they will pay the first $100,000 (ignoring the deductible) and the rest is on me.  Things are looking bad because, even after the my insurance company pays out the full policy limit, I will still have approximately $100 milllion to pay.

There is another catch in the law that can prevent my life from being one of poverty henceforth and this is the concept of recoverable assets.  Even though I am still on the hook for $100 million and the museum can sue me to try to recover their losses due to my careless driving, they are not able to take all of my worldly wealth to do so.  There are only certain assets which can be recovered by the museum in a lawsuit. In Kansas (working from memory of what my lawyer told me), the museum could not take:
  • My home (primary residence)
  • One car per adult in my household
  • My retirement savings
For most adults, most of their earthly treasure falls into these categories.  If the museum were to sue me, the amount of money they might win is probably going to be relatively small, even by the standards of a typical household. If the museum has some reason to believe I have a bunch of money, they can search the public records and find out what property I own and how many cars I have registered in my name but they can't look at my bank accounts or ask to go through my house to see if I happen to have any Van Goghs. Based on whatever information is publicly available, they have to decide if it would be worth the time and expense to sue me.  

In the the case of the person who hit me, though I don't believe we did a public records search, we had good reason to believe she was a normal person that probably didn't have piles of cash laying around, at least not $100,000 worth.  What about her salary? There is a possibility of garnishing wages (legally forcing part of her future income to be sent to me) but enforcement is tricky.  Its a lot like child support in that even though I might be legally obligated to that income, enforcing those payments can literally be more expensive than they are worth. Even though she was 100% at fault, the cost of personally suing here would in all likelihood result in lower compensation for me.

It kind of stinks. The combination of a Kansas' low liability requirement ($25,000) and the lack of recoverable assets most of us have means that it is very easy to be completely without fault in a collision and still receive very little compensation for the damage caused.  I could have lost much more than the ability to walk pain-free and the payment I would have received in compensation for my losses (and to pay for future medical care) would have been unaffected.  This is why having uninsured and underinsured policies are so important, particularly in Kansas.  They set a lower limit to the payment amount regardless of the other party's insurance policy.  

To be clear, I really like the idea of protecting what you might call "essential assets" from lawsuits.  Even if I had been able to, I would not have felt good about taking a house, car, or life savings from the gal who hit me. I am very convinced that there was no negligence on her part and that this was entirely an accident.  Unfortunately for me, I am bearing most of the consequence for her mistake but this is exactly why liability insurance should exist.  And this is also why requiring so little liability coverage in Kansas is such a tragedy.  The people who really make out well in this situation are the insurance companies.  They are only on the hook for $25,000, assuming their client buys the state minimum.  If it weren't for the under-insured policy with MY insurance company, everybody but me would have been happy with how things turned out.  That policy made the pool of money in play big enough that lawyers and insurance companies paid attention.

In case it is not clear, here are my recommendations for buying auto insurance:
  • Be responsible and buy a lot of liability insurance.  You may be able to skate by with less but this is the primary mechanism by which people are made whole by the damage you cause.  The amount of havoc that can be wrought by a car is tremendous and as such, your liability coverage should be high.  You don't want to be responsible for any unpaid moral debt.
  • Buy as much uninsured/under-insured coverage as you can afford.  With my insurance company, this was less than 10% of the yearly premium I pay. This extra policy ensures that you won't be left out to dry when somebody else makes a mistake and doesn't have the appropriate amount of insurance.

Thursday, September 11, 2014

One Year Anniversary

A year ago today I was hit by a car while riding into school on my motorcycle.  Today, I can walk and though there is pain in every step, most days it is not much more than what you might experience with a sprained ankle or pulled muscle: annoying but not debilitating.

Thankfully most of what I do is with my mind and and not my body because if the former was the case, things would not be so cheerful. As I have been fixing up our new house, I have found that the flurry of home improvement on Saturday has consequences on Sunday.  I take an ibuprofen and do as Christians have done for centuries; I rest.

I am fragile.  I have always heard those older than me talk about youth and their invincibility.  It wasn't true; how could they say that? It is true. This injury has prematurely aged me and made it clear that this is not simply a statement of the carelessness of youth but more specifically, the lack of necessary care, the lack of premeditation in every step, jump, sprint and turn.  When I approach a large step I become an old man, carefully easing my way down the twelve, fourteen, twenty inches. I remember when I would have eagerly jumped off and landed in a sprint. Now this step is a reverse Himalaya for me, the seasoned mountain climber.  I have history and knowledge that I can conquer this but not without effort and the outcome is uncertain.  There will be pain. I will persist.

I am not young, closer to forty than thirty. About a decade ago I injured my back and over the many months of treatment I was able to more-or-less recover to my pre-injury state.  The physical therapist told me that though I was asymptomatic, I would only stay that way through regular exercise.  The injury would never heal and the pain of my nerve impingement was only millimeters away.  I was young and I generally ignored her.  I have had several minor "re-injuries" since then and still don't do the exercises as often as I should.  My muscles get soft and fail to keep my back in line; I hurt.

Life changes quickly.  I was putting up a picture of Katie and I and it was clear to see they were taken when we were younger, several years ago.  It doesn't seem that like we should look so different.  How long ago did we get married?

This has been a full year for us.  The injury lead to three months of bedrest and three months of physical therapy destroying any plans I had of graduating in May. By mid-June I had a job offer and the process of relocating our lives has filled so many of the days since then. I managed to complete my degree somewhere in there.  It feels like every day from that first phone interview was full with the seeds and fruition of this move; the days feel like weeks. My mind tells me it has been a year since we left Wichita for good.

A legal settlement between all the relevant parties was reached shortly before we left and I do intend to finish my "series" on insurance and what I've learned of the legal system through this incident.  The money was helpful in buying this house but I would trade it back for the ability to run and hike without care again. The only basketball I can play on the huge concrete pad in our backyard is free throw practice.

I write all of this to affirm the platitude: life goes fast and we are not promised tomorrow.  There are many, many who have more than my share of difficulty and trouble through no fault of their own. What I write is not statement of pain and pity but one of grief for the ways things were and never will be again. In the same we that funerals remind us of our mortality and motivate us to consider our life choices, let this short eulogy of my days of youth push all of us to make the most of every day in which we wake up. It is a gift.

Let me end with this. These are words commonly attributed to the Biblical King Solomon of Israel, a man whose life was extravagant, impressive, and devastating enough for our modern media tastes, a man who knew the pleasure and pain of this world so well:


"You who are young, be happy while you are young, and let your heart give you joy in the days of your youth. Follow the ways of your heart and whatever your eyes see, but know that for all these things God will bring you into judgment."

Amen. May it be so.

Thursday, August 14, 2014

Household Detritus

When the mover's had completed their job, our house was virtually empty with only the items we ourselves were taking in our car remaining.  By that Friday afternoon when we were leaving town, the house was virtually bare: the only things we knowingly left behind were paint for the rooms and exterior and the extra tile we had used in the kitchen and bathroom.  And a few air fresheners.

The house we have purchased and have been moving into these past few days was not so thoroughly expunged.  Here are just a few of the abandoned items of which we have recently gained custody.

Anti-stress medication for a cat.


Art used to decorate one of the bathrooms.



Fish candle decorating the same bathroom.


Mystery key.


Very large first-aid kit.


Art decorating the kitchen.


Tiny wrench.


Dog-bone keychain.

There's more, such as the drawer littered with cough drops, the 90's vintage radio and cd player in the garage, and a half-bottle of rubbing alcohol. Most of this will go away but if the fish watercolor is not a print, I think I'm going to fight for it. I don't know where I would put it.

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.

Sunday, May 04, 2014

Leather Seat Repair

We recently acquired a very used car that had leather seats.  All of the leather was in very good condition except the driver's seat; worn and with a large tear on the side:


The price for a full repair (including two other panels that were well worn) was $300.  Given the age of the car, we didn't think it was worth spending that kind of money on a cosmetic repair. Our primary interest was in containing the damage, not so much making the seat look new.  We talked over several bad ideas (duct tape, glue, switching driver and passenger seats) before we came up a repair idea that would look OK and keep the tear in check.

We decided to buy a piece of leather of the appropriate color (eBay), cut it to fill in the area behind the tear, and glue the tear down onto the backing piece. So that's what we did.

The trimming and fitting of the leather took longer than I expected and the numerous leather flaps from the compound tear did not want to lay neatly down.  We got it more or less in place and then used paint tape (low adhesion) to apply a small amount of pressure while the glue dried.


Twenty-four hours later, we pulled the tape off and got a good look.


Far from perfect but more or less what we were looking for.  The flap on the far upper right didn't get glued very well so I'm redoing it but everything else seems to be working fine.  We'll see how the special leather flue holds up; I already know from a test on a swatch of the backing leather that it is very flexible when cured. We'll probably need to re-glue it and we may eventually decide to have the panels professionally replaced.  For now, we're calling it "good".


Tuesday, April 29, 2014

Daylight Alarm Clock - Proof of Concept

Have you heard of these daylight alarm clocks?  You set the alarm for your normal wake-up time and a the clock controls an attached light to gradually illuminate the room, reaching its full brightness at the alarm time.  Given that we Hardy's need to wake up early during the week, I've thought about giving the idea try to see if it can make the mornings less difficult.

I've decided to build a bare-bones system that will allow us to determine if there is any use in continuing down this path. If we like it, I expect to include a real-time clock module and a method of setting the time; for now, we're doing none of that.  I'll be using the not-necessarily-accurate internal oscillator on the Arduino to count the number of milliseconds from when the board get's powered up to when I want to light to start to ramp up.

The lamp I'll be using is a 12V LED lamp used in things like track lighting.  Control of the brightness is accomplished using the Arduino's pulse-width modulation for its analogWrite function.  The output from the Arduino pin runs through a 2 kohm resistor and into the base of a MPSA14 transistor. Since this is an NPN transistor, I'll be using low-side switching to pulse the ground leg of the lamp with the high side directly wired to 12V.

Based on my previous experience with LED lighting, I know that the relationship between input signal and output brightness is very non-linear.  Thankfully, somebody had already figured out a good sequence of input values that would a smooth change in brightness.  Take a look for yourself, it seems to work pretty well:




I'm going to move Arduino, lamp, and breadboard to an appropriate place in the bedroom tonight (after programming it so that it "goes off" at the correct time tomorrow morning) and we'll see how we like it. 

Thursday, April 17, 2014

Dissertation Simulations Continue

A month ago, I projected that I would be done with all the computer number crunching in just a matter of a few days.  I was very, very wrong.  My few day estimate turned into three weeks.

A week ago, I discovered a mistake in my program.  In looking through the results I noticed a particular value, which I knew was always a sum of a bunch of fractions, was always coming out as a whole number. I investigated and found the obvious error I had made.  It had take me a lot of time writing the code that would generate those very significant fractional values and I was accidentally throwing it all away, choosing to round them all up to one and add that up instead.  These fractions are an important part of the simulation and drive a lot of the results; incorrect values here mean my overall results were invalid.

My bad results were saved (because hard drive space is cheap) and the simulations were restarted. Oh, and another sixteen cases were added, bringing the total up to forty-eight.  After letting my main computer at school work at it for a week or so, I surmised it was going to take a long, long time to get through all the simulations. We had just recently cleaned the lab and taking an unused machine, I spent a day getting it set up and put it to work. It is not near as powerful as my main computer but every little bit helps.

Monday afternoon, as I was watching results slowly trickle in, I began racking my brain for where I could get more computing power.  There was another souped-up computer there in the lab just like mine that probably wasn't getting used much but it was assigned to another student.  Maybe she'd let me get on and run my simulations in the background?  There were plenty of other older computers around but, besides not having the desk space and network connections, they looked much less capable than the one I commandeered. Where could I get the number-crunching machines I needed?

My home computer.  It is new, relatively high-powered, and I had most of the software already installed. It took me a few hours to get it up and running and right before bed the other night, I set it to work.

In the morning I looked at the results and there is no two ways about it: this machine is a monster. I've compiled results from all the runs that have completed so far and I'll let the graphs do the talking:


Each bar is one case that was simulated.


There are two significant differences between my school computer and home computer: my home computer has processors running at almost twice the speed and it also has a solid-state hard drive.  My simulations write out to disk a lot, constantly logging results and reading back in logged values to make calculations.  I wrote the simulations this way so that I could stop and start them at will, giving them the ability to always pick-up right where they left off. (The more fundamental motivation was due to Matlab, the simulation environment I'm using, silently crashing on my school computer.  I have no idea why it does this and wish it would stop.  Having the crash recovery has been essential in getting simulations done and it has given me a lot of flexibility in scheduling the simulations.)

A solid-state drive is MUCH faster for disk writing and reading, giving my home computer a big advantage.  My school computer only has a conventional spinning-disk hard drive and, to make matters worse, it runs eight of the simulations in parallel, each constantly trying to access the disk.  I've done testing during development that showed the per-simulation time increases as the number of simulations being run in parallel increase.  Its still faster overall to run as many as I can in parallel but they definitely get in each other's way.  My computer at home is only running four simulations in parallel but I bet the solid-state drive presents virtually no roadblock to any of them.

The graphs above aren't a purely apples-to-apple comparison but it is clear for even moderately disk-heavy tasks like my simulations, the solid-state drive goes a long way.  Even though my home computer got in on the action a week late, I'm betting it will end up completing half of the simulations itself.  Why didn't I think of this last month?

Saturday, March 22, 2014

Bicycle Lights

One of the things that drew me to Breezer bikes, the brand I currently ride, is the integrated lighting system.  A generator driven by the rear wheel and pre-mounted and -wired lights for the front and the back meant I never had to worry about running out of battery power.

After riding for several years, though, and dealing with being hit by a car (during the day) while on my motorcycle, I have come to the conclusion that brighter is better.  These integrated lights are nice but if I'm serious about riding my bike at night, I need to do more so that I can ride safely.

For a while I had a helmet-mounted light powered by a battery on the frame but wiring was a pain to deal with at times. I had to run the cord down my back and plug it into a I had installed jack beneath the seat.  It worked pretty well and it was nice to have a light the followed the direction I turned my head.  The light fixture I had made for the helmet and wiring were not durable enough, though, and it became clear a better solution was needed.

While I was convalescing I came up with an improved solution, ordered the parts, and yesterday I finally put all the pieces together.




Two LED "headlights" up front, one always pointed the same direction as the wheel and the other the direction of the frame (straight-ahead).  




These rear lights are some LEDs that I have had for over a decade and I think I've finally found the perfect home for them. They started as some night-time dim light for my bedroom in Boise and were previously used at my nerd desk before I upgraded the lights there.  These lights are clusters of red and green LEDs and for rear lights I'm not powering the green ones.  The canisters for the lights were just a little bit too large to fit into the milk-crate grill and had to be filed down.



This is the main junction box for the system.  The red/green/white wires are coming up from the rear lights and enter the box through a hole in the bottom.  The switch powers both front and rear lights.



Just below the junction box is the battery for the system, strapped on the bike rack and the milk crate.  It is well beyond the needs of lights in terms of capacity but it means I won't need to charge it very often.  Speaking of charging, the yellow terminal sticking out the bottom of the junction box is used to do just that; there is a matching terminal on the other side.

UPDATE:  Here's a view of the lights at night.  Note that the headlight is illuminating the area directly in front of the bike as well as to the left, where the front wheel is pointed.







Thursday, March 20, 2014

Even Better Fix for the Temperature Shifts

As I discovered previously, the load of the relay coil was causing Vcc (which is used as the analog reference voltage by default) to droop when the coil was being driven to provide power to the heating pad.  This caused a shift in the measured temperature whenever the coil opened or closed. The problem was significant when the Arduino Uno was powered by USB and less but still noticeable when powered through the DC jack.

There's an even better fix, though, and it hinges on the fact that the temperature sensor I'm using, the TMP36, has the same output over a wide voltage range (2.7V to 5.5V).  By default, the Uno uses the 5.0V regulated voltage as the ADC reference voltage (AREF).  It is possible, though to wire an external voltage to the AREF pin and use that voltage as the ADC reference.  As it so happens, the Uno has a second regulated voltage on-board: a 3.3V supply.  I verified that whether the relay is open or closed, the supply provides 3.3V.  

It was a simple matter to make the hardware change and wire the 3.3V pin to the AREF pin. I also added a capacitor across AREF and ground to help stabilize the voltage, something I should have done before.  I left the temperature sensor on 5V; it puts out the same voltage whether powered by 3.3V, 4.93V, or 5.03V. The software changes were also straight-forward: tell the Uno to use the externally provided voltage on the AREF pin as the ADC reference and change one line of code used in converting the ADC value, having it use 3.3V instead of 5.0V in the calculation.

The proof is in the pudding, as they say:



No big shift when the green trace hits the temperature control limits. Looks like the problem is solved.



Tuesday, March 18, 2014

Root Beer Temperature Controller Under Load

I finally have done some testing using bottles actually filled with...

... water.  Didn't even cap them.


Note the time scale on the bottom: hours.  With all the "thermal mass" of the water, it takes a lot more energy to cause a temperature shift in the chamber.  With air the temperature would swing out of control band in minutes; with water it takes hours and really doesn't ever venture outside the target range.  You can still see the temperature shift when the relay turns off, the temperature moving up a few tenths of a degree.

(Incidentally, from a conversation I had with a guy who used to design appliances, this is why burners on ranges don't have temperature settings on their control knobs, just generic levels (like "1" to "10" or "Low" to "High").  Without knowing the type of pan being used (aluminum, cast iron, stainless steel...) and what is being cooked (grilled cheese, bit pot of water for boiling pasta, steak...) it is virtually impossible to design a control system that will keep the item being cooked at the required temperature without taking forever to reach that temperature or wildly over overshooting the temperature (that is, burn the food).)

I think we're ready to give this a shot.  I'll check my supplies but I hope to have a batch of root beer going by the weekend.  Expect pictures, though they will probably not be very exciting.

Friday, March 14, 2014

Temperature Shifts

Where we last left off, I had been able to use a relay-actuated electric heater and a temperature sensor to act as a simple thermostat to regulate the temperature for use when allowing root beer to ferment. Yesterday I upgraded the system to use a transistor to control the relay rather than driving it directly from one of the Arduino Uno microcontroller pins.  It looks like this may have solved some problems with losing serial communication to the Arduino IDE (at least the problem hasn't shown up again) but the trouble-shooting process revealed another: a temperature shift whenever the relay opens or closes.

I actually observed this problem the first day I was doing testing on the system:



If you look at the "Heating Pad on High" plot (the green one) you see that as soon as the chamber temperature hits the lower limit (and the relay closes to turn the heating pad on), the temperature shifts down almost a full degree.  Oddly this behavior doesn't show up for the "Heating Pad on Low" curve which is at least a little bit odd. 

My immediate guess, which turned out to be correct, is a sagging Vcc.  With all voltage supplies, as the amount of current being drawn increases, the voltage at the output will decrease.  Supplies that have very little voltage drop are considered "well-regulated"and there are various metrics that can be used to quantify this degree of regulation.

So I pulled out my multi-meter and measured the 5V supply:

Relay closed: Vcc = 4.93V
Relay open: Vcc = 5.03V

That 0.1V shift messes with the on-board analog-to-digital converter (and the math I do in software to convert the measured value to temperature).  The converter and math think they are working on a 5V scale but some of the time its actually a 4.9V scale.  Not a huge difference except that my temperature sensor measures from -40'C to 125'C and the temperature differences I'm trying to measure are less than 1'C.  In this application, very small changes in supply voltages can cause trouble with the temperature measurement.

Since I discovered the problem, I have though of three different solutions in succession:
  1. Op-Amp Range Adjustment - Use a rail-to-rail op-amp (like the MCP6002 which I have used before and have on-hand) to magnify the output of the temperature sensor so that at say, 100'F the sensor/op-amp combination effectively put out 5V.  This would effectively increase the resolution of the sensor around the temperatures I care about at the cost of not being able to read temperatures over the whole sensor range.  Any temperature above 100'F would all produce the same 5V value.
  2. Constant Load - If the changes in load are causing the voltage supply to drift, why not do something to keep the load constant?  Using a PNP transistor and a fixed load (something like this), I could provide a constant load on the voltage supply whether the relay was engaged or not. When the relay was open, a dummy load would be switched in through the PNP transistor (using the same control signal for the relay coil) and when the relay closed, the dummy load would get switched out and the relay coil would load down the power supply.
  3. Change the power supply - It took me a while to figure out why, in the above graph, the "Heating Pad on High" showed this problem but "Heating Pad on Low" didn't.  The amount of power the heating pad draws does not affect Vcc on the Arduino; it is on a completely separate circuit. I eventually realized I had effectively changed the power supply to the Arduino between these two experiments.  When the heating pad was on low, I had been supplying power through the DC power jack and when I had changed the heating pad setting, I had unplugged this power supply for some reason.  Without the external power, the Arduino was being powered by the USB bus it was attached to and it doesn't surprise me that the voltage regulation was not near as good.
Obviously, solution 3 is the easiest to implement, though it didn't come to me until the next day.  I had already planned to power the Arduino from an external supply when the system was actually in use as it would be operating stand-alone, apart from a computer.  With the external supply in place I get the following Vcc measurements:

Relay closed: Vcc = 4.99V
Relay open: Vcc = 5.00V

This is probably within the range of error for my meter and should be good enough for my purpose. Here's what the thermostat performance looks like under USB power compared to external DC power:


The shift under USB power is very obvious and it is clear that there is also a slight problem still when being powered by the DC jack (the little squiggle at the lower control limit).  By the way, this data is when the heating pad is on high; way over-shooting the target temperature range.  But more about that next time.

Thursday, March 13, 2014

Transistor Controlled Relay

Today I was having some problems with the temperature controller not sending information out to the serial port for viewing on the serial monitor in the Arduino IDE.  I don't know if I solved the problem but in the midst of trouble-shooting I decided to upgrade the system to using a transistor to control the switching of the relay.

Previously I was using a single digital IO pin to drive the relay coil directly.  By using a high enough series resistance I was able to get the coil current down to 36mA and despite the fact that the datasheet would not guarantee my relay would work under such a situation, it did. (The Arduino site says I should have been safe at 36mA, just below the 40mA absolute rating. Still, not a good place to be.)  The serial communication problems seemed to go away when I didn't plug the relay in and draw so much current so it seemed like a good idea to bite the bullet and use a transistor to drive the relay coil.  This would reduce the load on the digital IO pin and allow me to drive the relay coil with enough current to operate within the datasheet specifications.  Two birds, one stone.

The circuit I used is simple (and readily available):



And here's what it looks like all built up:


The blue connector on the bottom right is switched in and out by the relay directly above it.  In the picture it is wired into an outlet that the heating pad is plugged into. The header in the center bottom provides 5V and ground to the temperature sensor as well as running the output from that sensor back into an Arduino analog input. In the top center is the transistor used to drive the relay coil.  I used a header here as a socket so I could easily replace the transistor. This is was a good idea as the first transistor I tried was dead.

(I didn't bother trying to connect to that off-pitch header.  They seriously need to fix that.)

Building this "shield" seems to have helped with the serial communication bug but now I've got another problem.  Every time the relay closes or opens the temperature sensor output shifts.  I think I know what's going on here and I have an interesting solution.  Stay tuned for more details.

Monday, March 10, 2014

Root Beer Temperature Controller

As I was continuing to clean my nerd desk this weekend and get the basement cleaned up after months of neglect, I ended up sinking a few hours into a side project. It was all started by the downsizing of my root beer bottle collection.  I have two or three times as many bottles as I typically used and I was in the process of throwing them out to make shelf space for some of my wife's stuff. Seeing all the dust on the bottles made me realize it had been a while since I had made root beer which further reminded me that my root-beer process was highly variable and what those in the business call "out of control".

The big uncontrollable factor is the temperature at which the bottles sit while the yeast eats up the sugar to provide the carbonation.  After making root beer for several years I have some idea how long this process should take but the margin of error is still very wide.  I usually end up opening test bottles to see the carbonation is progressing and it often takes two or three before I consider the bottles ready for refrigeration.

I remember my mother saying when they made root beer they used an electric heating pad to provide a more consistent temperature and as I was cleaning out these bottles, that sounded like a great idea to me.  In fact, I could go one step further and use one of my Arduino Unos and build a thermostat to control the temperature in the "fermentation chamber" (probably just a plastic cooler).  I already had all the hardware I would need to make this work and most of the code already written as well.

The idea is simple.  Put a temperature sensor in the fermentation chamber where the heating pad and root beer bottles are.  When the temperature drops below a certain temperature, switch on the heating pad and when it gets too hot, switch it off; basic thermostat.  I already had a few extra temperature sensors from my home temperature measurement project and the code to take a bunch of measurements with the on-board ADC, average them, and convert them to a Fahrenheit value.  Stripping down that code to work with one sensor instead of six was not difficult.

The hardest part was figuring out how to switch the heating pad.  These pads plug into the wall outlets which run at a much higher voltage.  I wouldn't be able to directly switch that voltage on Uno but I could probably control a relay that was capable of providing that switching.  I scrounged through my relays and found one (and only one) that was designed with a 5VDC coil (the voltage the Uno uses) and could switch the 120VAC that comes out of the wall.  The the Uno doesn't provide enough current to switch coil at 5V, by putting in a series resistance I was able to get the current under control and the relay still switching properly.

Rummaging through the garage I found an old outlet and outlet box I could use to mount the hardware.  Though the circuit is simple, making sure that everything is done correctly and safely took a little work. I didn't have the heating pad yet so I used an incandescent light bulb (there still good for something) as my heat source when I tested the system.

After only a few hours, I got it working!  The light bulb heats up the sensor to 82 'F and then the Uno shuts off the light via the relay.  When the sensor cools back down to 80 'F it turns the light back on.  I made a little movie showing an animated graph of the measured temperature with an inset clip of the lamp being turned on and off as dictated by the controller.  The synchronization between the animation and live-action recording is not perfect but you'll get the idea.



There is always room for improvement.  My bare-bones control algorithm does not guarantee that the temperature will stay between 80 'F and 82 'F as the temperature in the chamber may continue to rise even after the heating pad is turned off as it is cooling down. It would be nice to log the temperature so I could see how it actually ends up behaving.  I could try using some radios I purchased for the home power measurement system that is under development and tying it into the temperature measurement system; I doubt that will happen any time soon.  I also have some external flash memory I could write to and then read back after the batch was processed.  One of those data-logging shields would be nice right about now.

None of these limitations is going to keep me from using this immediately. Once the heating pad arrives from Amazon, I'll be ready to brew up a batch and see how well this works. I'll keep you posted on how it turns out.

Sunday, March 09, 2014

Christmas Board Games (Part 2)

Its taken some time but I've finally been able to try out a few more games that showed up for Christmas.




Coup is designed to be a short, simple game of bluffing and conspiracy.  Each player has two hidden characters with special abilities and using these abilities, attempts to remove the characters the other player's control. And, since nobody knows who your characters are, you can bluff and act as if you are any character at any time. Of course, if you get caught, things won't work out so well. At no point in the game will you every know which character's the other player's hold and every play is a gamble.  They call this kind of game a "social deduction" game as it is somewhat possible to infer who might be what character based on how they (and everybody else) is playing.

The games tend to go quickly and I enjoyed them, even though I lost most of the time. And you can't beat the feeling of lying through your teeth and getting away with it.  The worst part of the game is that players are eliminated one at a time; if you're the first to lose in a six-player game, you'll have a bit of sitting to do.  Not too long, though, as the games are over in about 15 minutes, usually.






Space Cadets Dice Duel is a follow-on game to the original Space Cadets, a cooperative game.  In that game, each player has a role on the ship and to contribute to the success of the mission, he/she must complete his/her own mini-game.  Space Cadets Dice Duel is similar in that each player has their own role but rather than a mini-game each rolls a special set of dice and rather than all working on one team cooperatively, two teams play against each other.

There are lots of dice and lots of rolling.  There are no turns per-se and the only cost to an unfavorable roll is that the dice end up being rolled again. Each team ends up with multiple players rolling their dice simultaneously in an attempt to position their ship into advantageous firing positions or avoiding and preventing their opponent from doing the same.  The game is almost literally non-stop; when our pilot took a break mid-game to grab a snack, we were sitting ducks just hoping the other team wouldn't be able to get their act together.

I was attracted to this game because it seemed like it might be simple enough for many non-board-gamers to understand and exciting enough for them to enjoy.  I haven't been able to really test it in such a scenario but I will say my more strategic and nerdy board game group did enjoy it.  We picked it up quickly and the we were able to play three games in about 90 minutes.  Its more of a tactical game than strategic but we got good enough in a short amount of time that we got past the dice-rolling random-ness and were trying to execute specific movements and attacks.  I suspect it will make a repeat appearance at game night.

Thursday, March 06, 2014

Dissertation Simulations

As of this morning, I have begun what I hope to be the official simulations for the work on my dissertation. I have 33 separate cases to study and this morning I queued them all up to run on my school computer over the weekend.  For exactly this reason, the machine I get to use has eight cores and 48GB of memory so it should be able to handle the workload; nevertheless I don't expect it will be done for several days.

I've been working since summer 2013 on the development of the computer code that is being run in these simulations.  I started with a model of the electrical grid in the western US and have been working on a way to add energy storage (a battery) to a specific location in the grid.  It was important for my research that the simulated behavior of the battery should wear out over time (like batteries do) so a bit of my work was getting that implemented. A week or two ago I started putting the individual pieces together and began testing the system as a whole, making sure everything was behaving as expected.

When the final development test results came back this week with the system appearing to function I was faced with a startling realization: I was ready to run the simulations with the specific conditions I wanted to study.  Though the difference between these "real" simulations and the test ones I had been doing involved only changing a few lines of code, the psychological hurdle was immense.  I'm actually doing it; I'm almost there.

These simulations will take a while to complete.  They have to figure out, for a given set of demand for electrical energy in the western US, the output level for each generator in the western US that will provide this energy for the lowest cost.  And it has to do this for every hour of the year (8760 of them).  In half the cases I'm simulating, it has to do this for five years in a row.  

I hope everything will be done when I come in on Tuesday.  When I left, all eight cores on my computer were maxed out and I expect they will stay that way for a number of days.

The completion of the simulations is a significant milestone but I still have plenty of work even after they are done. Analyze data, make graphs and tables, and write the several hundred page document that PhDs traditionally have to write. I won't be done this semester but I'll be very close.


Sunday, February 23, 2014

Dropbox Arbitration

Dropbox just recently updated their terms of service and one significant change is the inclusion of an arbitration clause.  Arbitration clauses are used by many companies to avoid the hassle and complexity of resolving disputes through the legal system.  Instead, the two parties use a neutral third party (the arbitrator) and agree to abide by what he/she decides.

General speaking, arbitration clauses are not good for consumers.  The arbitrators are almost always chosen by the corporations and most of the "rulings" are in favor of the corporations.  If the arbitrator doesn't decide in your favor, you are without recourse.

Besides, don't we already have neutral third parties to settle our disputes?  I think they're called "judges" and the entire civil legal system is designed to handle such cases.  It can be expensive and time consuming and the issue of "how much justice you can afford" is real but in the very least it is unbiased and therefore more likely to be fair.

It may seem silly but the ability to sue someone is an important legal right.  Civil courts are an expression of democracy, where social status or power are diminished and two parties are put on equal footing before a judge to resolve a dispute.  Even a system like ours which appears at times to have serious flaws is better than the alternative: one where justice is truly up for sale and might equals right.

Dropbox has made this easy for us.  If you don't want to go to arbitration to settle a dispute with them, you can opt out of this arbitration clause.  You don't have to stop using the service and find an alternative.  Just opt out.  By doing so, you give yourself the option of settling any dispute you may have with them in front of a judge not some arbitrator.

Take it from me, a guy who was hit by a car, is glad he doesn't have to sue as a part of the settlement process, but is glad that the option exists.

Saturday, February 08, 2014

Light Renovation

Over the past few days I've been adding lights to some much needed locations.

Under the kitchen cabinets...


... at my nerd desk...





... and in our storage closet



Sunday, February 02, 2014

Preparation for the Storm

The never-wrong weather-man says we're looking at many inches of snow starting in the early hours of Tuesday morning.  Rather than keep the SUV we're borrowing out in the driveway (making clearing the driveway very difficult and effectively trapping the vehicle in), I undertook the herculean task of cleaning up the "shop" half of the garage while my wife was making lunch.  With effort, our two-car garage now holds two cars.  Thankfully one of them is no an SUV.


Saturday, February 01, 2014

Breaking Madden: The Machine is Bleeding To Death

Through customizing the two teams in the video game Madden 25, an adventurous soul sought to create the most lopsided football game in history.  For example:



Letting the computer control the underpowered team resulted in some rather inexplicable behavior.  When you play this far outside the lines of normal, its hard to predict how the AI will respond to such overwhelming circumstances.



As my wife can attest, I've not laughed this hard in quite a while.

Seriously, read the whole thing.

Tuesday, January 28, 2014

First Day of School (Again)

The doctor has cleared me to return to school, good friends are able to give me ride in the morning, and I'm mobile enough that I can get around campus. Its time to get back to work!  Now what was I doing again?

I return to find that the printer is out of toner. In fact, its out of both yellow and black.  I'm betting his means the color printer was effectively a black-and-white printer until the black toner ran out, at which point it became effectively broken.  Last time we ran out of black I was the one that ordered the new toner and the first thing I did when I got in was order a complete set of cartridges.  When later installing them one of my lab-mates commented, "That thing has been broken since December."

My desk is like an archaeological site, with artifacts of the former occupant's life covered in a fine layer of dust. That former occupant is me and though this is all my stuff is mine, I hardly remember it at all.  I see a complex colored diagram I did of some of the system power flows and I remember thinking how useful it was but I look at it now and it puzzles me.  What was so important about this?  I see other scraps of paper with notes on them; are any of these worth saving? What's the number for the phone at my desk again?

I'm recounting the story of being hit by a car with my lab-mates and one of them mentions a class that he is taking this semester.  Its highly related to my research and I think it would be a great class to take.  Is it too late to enroll?  Do I want to officially enroll or just sit in to learn what I can?  I'm not very interested in doing homework and taking tests again and I'm really trying to get done with this degree but how can you pass on a class that is over half of your dissertation? For this week, I'm going to be sitting it in and see how it looks. How do I enroll in a class as an audit?

The clock in the lab isn't working.  Battery ran out?  Actually broken? Its high on the wall over a doorway so getting to it to diagnose the problem could be tricky.

Somebody unplugged/turned off the fridge over the weekend and everybody's food rotted. It stank in the lab until we were able to drag it out into the hallway and let everything air out. Now the microwave, which was on top of the fridge, is living in a chair in a semi-level fashion.

Really, we are all working on graduate degrees here.  I promise.