Posts Tagged ‘tech’

h1

I have an idea

August 13, 2012

About a decade ago, I had the idea to create a data logger, it would write data from a serial port to a USB thumb drive. I'd worked on a lot of devices that had serial output for their main interface or for debugging purposes. Normally, to get data, I'd have to hook a computer up to the gadget, hoping that the laptop batteries didn't die, that Windows didn't go to sleep, and that I didn't need to timestamp anything to greater than 4ms granularity (Window limitation). The ability to store days or weeks of data would be fabulous.

I chose the processor because it had the bare minimum I needed and a USB device. I got a wonderful and generous EE to help me choose the other components and make a schematic. I paid for it to get laid out, ordered all the parts, built kits, got boards fabbed, bought cases, worked with a model shop to get the cases cut for the boards. I learned a whole heck of a lot. The boards came in and came up ok but the vendor's USB library worked with only one or two thumb drives. I worked with the vendor to expand their library. Then I got a full time position and the frustrations of dealing with the vendor… well, I just finally got rid of the boards and cases recently (though not the completed one, there on the left of the pic). About two years ago, someone else built a data logger, one that I could just buy and it would do what I wanted.

About six years ago, I saw a product design contest and entered it with a neat new idea. I wanted microcontrolled Christmas lights, ones that I could put up and never take down because they'd change color to match the upcoming holiday. With a marketing VP friend, I wrote a complete business plan (summary: holiday decoration is a huge market). The software was easy to explain and the market was there but the hardware was difficult. The way the lights were to be controlled led them to have an unwieldy cable, making them expensive and essentially unmarketable.

Two years ago, GE came out with individually addressable LED strands (on the right in the pic). A hacker worked out the control protocol shortly thereafter. Anyone who wants to make my holiday lighting needs the $50-80 light strand, a $30 Arduino controller, and freely available program. Ok, so it is still expensive but it isn't impossible anymore. After I (and another wonderful EE) presented how to put this together at this spring's Embedded Systems Conference, I was accosted by an engineer for a lighting company asking if I had patented the idea (no, I just wanted someone to build it for me, I didn't want to block development). After a bit of searching, a generous patent agent friend found that Philips had patented “LED as applied to…” well, anything… including the “tidy bowl” application.

About three, maybe four, years ago, I got an idea for a video game called Shoe Shopping Adventure. The player would make life choices (i.e. career, friends vs. work) and that would translate into their need for different varieties of shoes, their available funds, and their time allotted for shopping. I learned a bit about iPhone programming, drawing shoes, and designing games. I tried to get Zappos involved because I was thinking that one way to avoid doing a lot of UI design is to use actual pictures of actual shoes. And as a revenue source, people who bought shoes in the game might want to see those same shoes for themselves later. Anyway, I only bugged one software friend and she mostly just had to listen to me babble one afternoon. Well, and my husband who has been supportive through all of these. So far, no one has made this game for me (yet) but I stopped development because it is a heck of a lot of work (and because I started writing Making Embedded Systems).

It isn't that I don't finish things. I do. I mean, I wrote a book (two, actually!). And I've shipped tens of products. But those have been for other people, for the companies that I've been employed by. The book was for myself but I had some external impetus there.

So it is with some trepidation that I say, once again, I have an idea. I wonder if I'm ready. And what I'll learn.

 

h1

Things you don’t pay me to do

July 19, 2012

As a consultant, I tend to bill 30 hours a week when I’m working full-time. Billing 35 hours in a week is an indication that I’m pushing it and feeling time pressure. More that that isn’t sustainable. But a client recently asked why I wasn’t working more when a project was falling behind.

The behind-ness wasn’t something more hours from me could fix, it was the dependencies that were failing. But there is something sincerely broken about the question.

Well, I get dumb when I’m tired. The more exhausted I am, the worse my code is. That isn’t true for the first week of too many hours, sometimes there is the lovely zone of intense concentration. But after that, well, I can write code but it won’t be good code. I much prefer to write good code. I just makes me happier.

I tried to explain to the client that they get things they don’t bill for, that they don’t see, that would be part of my “full time” if I worked for them. But it was on the phone and spur of the moment; I didn’t do a great job of it so, in good blog tradition, these are the things I should have said.

  • The 97 times a day I check my email when I’m not billing (e.g., shooting off a quick response at 7pm so the folks in Asia aren’t halted by a minor issue).
  • Conferences I attend and the reading I do to keep myself current in my field.
  • The gadgetry I buy (or, ahem, acquire) to evaluate new technology. These give me better understanding of users, new user interface design options, processor options, and sensor technology.
  • Chatting with coworkers around the water cooler (my watercooler is walking around the block with dogs and husband, clients only get charged for that if we spend the walk talking about problems that we need to work out, which is to say, occasionally).
  • Life chores such as those I often hear when in the office (e.g., two weeks behind deadline and now is when you conduct an intensive Craigslist search for a car?).
  • Not to work: 10 holidays, 2 weeks of vacation, 1 week of sick time = 25 paid days off. So if there are 52 weeks per year and 5 work days/week, that is almost one work day in ten that the company pays a full time worker not to work.
  • Surf the internet because I’m tired, bored, or sick.
  • Maintain my computer. If I drop or lose it, it is my problem to rebuild it. This includes my phone, assorted tools, email service and domain, and, of course, my laptop.
  • Eat cake because it is someone’s birthday. This is kind of sad for me. I miss the days that I got paid to eat cake, even crummy grocery story birthday cake.

So, there are a lot of things that are part of a job that aren’t part of my billing. I’m sure I missed some. 30hours really is a full week. Actually, I’d rather work 25, feel like a bit of a slacker, and have enough mental energy to work on my own projects.

Sadly, I don’t think these particular clients are savvy enough to understand that a well-rested and engaged engineer is more effective than an exhausted, burnt-out one.

h1

What is it like to program?

July 1, 2012

I compared algorithms to recipes not too long ago. But I wanted to write a post about test driven development (TDD) and how every time I rediscover it, I think that it is great. So I was thinking about how to explain TDD to someone who doesn’t work with computers. And that was when I realized that just explaining how to program is not that easy.

I think of programming as writing: writing a story that is supposed to evoke a particular response from a given audience. Let’s say you had a young girl and you wanted her to smile, giggle, gasp, cry and then smile (with eye crinkles!). Other than those five actions, you don’t care what she does, but you need all five in, say, 15 minutes.

Once upon a time, there was a princess. She looked a lot like you! Her name… sotto, what is your name? Violet? Oh, that is beautiful! And you know what, her name was Violet too: Princess Violet Purple Lavender!

Ok, so I bet I’ve knocked off the first two responses there. But I’d have to try it out. I’d have to find a girl (named Violet) and tell her my story-let. And then, if it didn’t work, I’d have to erase her memory and try again.  And let’s pretend I could keep erasing and keep trying out stories until I got my five small emotional outbursts, all in order, all in my allotted time.

I may have to learn more about her to accomplish my task? What makes her scared? Is that the best way to elicit a gasp?  This information may be useful in crafting other stories for other children (or it may not, Violet may be oddly singular). And how I choose to go about this is very personal to me. I’d rather she gasped in surprise than terror. Given the current specification, I have that option.

There are lots of other stories out there, I might crib information from some of them and I might admire the elegant solutions or particularly fine writing. If a story ending isn’t copyrighted and is good for eliciting big smiles, well, I may use it myself, either wholesale or adapting it to the rest of my tale.

When I write programs, I’m telling the computer a story to get it to do what I want. There are lots and lots of ways to do it. Some ways are easier, some ways are considered better (if your Violet is young enough, you might get a gasp by dropping the F-bomb randomly but how are you going to get back to a smile from there?).

Sometimes I do have to figure out how to trick the computer into the action I want, very much like a puzzle. And sometimes I have each action as a preformed Lego block from some other story and I just need to find a good way to hook them together. That can be a puzzle too, especially if they don’t quite fit together (this one has a dragon, that one has a sea monster).

Finally, when I write my story, I’m not only writing for my audience but also for other writers. That story drivel above is clear and understandable but it isn’t great literature. I don’t know that I want to write great literature. But something with a little more craft would please me and any fellow writers who have to read my stories (err… fellow software engineers who have to read my code). It is kind of like the Anamaniacs cartoon where there were jokes for the kiddies and then there was another level of humor for the adults watching. The programs are for the computers and for the other programmers. A lot of programmers forget that.

I could ride this poor metaphor pretty far, but does it make sense to you? I don’t think I’ve represented the square-hole-in-a-round-peg problem-solving and puzzle aspect of it well enough so maybe I need an entirely different metaphor or I need to work in the poetry aspect to it. But then getting a kid to do what you want is often a pretty big puzzle. Anyway, if you program, how would you describe it to someone who didn’t?

 

 

h1

Words are power

May 31, 2012

In school, I studied systems engineering. I went to an odd college where we learned how to put a system together mathematically, modeling just about everything as a resistor-inductor-capacitor circuit or a spring-mass-dashpot. Because it all boiled down to math that looked the same. This holistic view gave me fresh eyes and I love the hammer-like feel to it.

So when I got out of college, I started to look for nails. Oddly, I actual found some. That led to embedded systems where that same math becomes surprisingly important. I was really good at this! My niche education was going to be useful!

I was still a fairly junior engineer so I explained my plan and process for solution to a senior engineer. i described the math parts, showing a little of my work but glossing over areas that needed to be done. At the end of my show and tell, the senior engineer took all the fun parts away from me and told my manager I didn’t know what I was doing.

See, he called a part of the system the “plant” and I never used those words. And when he used them, I didn’t recognize what he meant. I was a couple years away from my systems courses so part of the problem was my forgetfulness but, at my school, the professors I had called that part the “transfer function”, “system”, or the “process”. The literature tends to use these somewhat interchangeably (not precisely interchangeable, a book usually chooses a term and sticks with it).

It took a long time and a lot of math (and working code) to show I did know what I was doing. Even after that, I didn’t like this senior engineer, he felt so petty. Now I kind of understand what happened- I waved my hands and he probably though the project was too large and important to leave in such untried hands.

This is why I get stressed out when people are nervous about not knowing words. I mean, there is jargon and certainly that plays a role in making people feel like outsiders (and idiots). But sometimes, the words don’t seem like jargon, they are just words and everyone else knows what they mean, I’m just too dumb to understand.

Ahem. No. Words have meaning. Learn the words; understand the meaning. Then you have their power.

Words have incredible power but the most amazing thing about the world today is how easy it is to learn what the words mean. So let’s look at the word algorithm. I’m not going to look it up on Wikipedia for you, feel free. I’m not even going to Google it so I could be wrong in some tiny piece of semantics that are to follow. Watch me not care, I understand the meaning of this word: an algorithm is the word a man uses to mean a recipe.

Oh, I should not read the feminist blogs before writing my own, especially since the connotation is not true. On the other hand, an algorithm tends to be technical, usually related to computers or math based things; a recipe is something one follows when cooking dinner But at the heart, they share a lot: a list of requirements, a list of steps in phrased for the skilled reader, an ideal outcome.

Say I wanted to make cookies. My lackadaisical cookie making method requires a ratio of somewhere between 1:2:3 (butter: sugar: flour) and 2:3:4. Add other things like eggs, salt, baking soda or powder (depending mostly on type of sugar but also other flavoring agents), flavoring agents (vanilla, chocolate chips, peanut butter, orange rind, etc.) to taste. Mix then bake for 5-15 minutes depending on cookie size at 300 to 365F (convection) depending on cookie size and desired texture.

That is neither a good algorithm nor a good recipe. It is a useful direction but not at all a destination. (If you ever want a cookie recipe from me, get it as soon as you can because I won’t remember a recipe the next day.) I’d call that description of how to make cookies a pattern. It is a very loose way to go about it, leading to generally good results. As design pattern: cookie it works pretty darn well (for me).

Of course, if you have no idea what you are doing, it will be a disaster, it assumes a lot of knowledge from the user, knowledge that usually comes from experience. (Ahem, even that mix step hides a ton of potential information though if you take it on the surface, just mixing the dough however you feel so moved, the results won’t be bad).

So as a recipe, a cookie recipe might be:

Simple vanilla cookies recipe

1/4c butter (softened)
1/4c white sugar
1/4c brown sugar
1 egg
3 tsp vanilla
3/4c flour
1/2 tsp salt
2 tsp baking powder

Cream butter and sugar. Beat in egg. Add vanilla. Add flour, baking powder and salt. Put on cookie sheet with silpat (or greased cookie sheet), each cookie should be about 1 tablespoon worth of dough, rolled and then flattened. Bake at 325F for 8-10 minutes.

Makes approximately 2 dozen. Suggest serving with small bowl of chocolate buttercream frosting for DIY inverse oreos.

I think there is a enough details there that just about anyone can follow that. I suppose I used the standard “cream butter and sugar” jargon and that might be meaningless to some. And I didn’t say to preheat the oven. I kind figured you’d know how to do that. That you maybe had made cookies at some point in your life. What an odd assumption on my part.

I could create an algorithm to create simple vanilla cookies. Let’s see. Since I write software, this is a lot like writing a program to tell a robot how to make cookies.

Simple vanilla cookies algorithm

 

1. Measure 1/4c butter, heat to soften.
2. Mix in 1/4c brown sugar and 1/4c white sugar until mixture is creamy and has no granular pieces of sugar of remaining.
3. Beat in one egg until fully mixed.
4. Add 3 tsp vanilla, beat until fully mixed.
5. Add 3/4c flour to top of bowl (do not mix in).
6. Add 1/2tsp salt and 2 tsp baking powder to flour.
7. Gently stir dry ingredients together then mix with wet ingredients.
8. Scoop a cookie, about 1 tablespoon at a time.
9. Roll dough into a ball, place on greased cookie sheet leaving about >1 dough ball worth of distance on all sides.
10. Flatten dough ball into a disk about 1/4in high.
11. Repeat 8-10 until all dough is used.
12. Place cookie sheet in preheated convection oven at 235F.
13. Wait 9 minutes, remove.
14. Serve with chocolate buttercream.

Ok, that is a little detailed in spots but you can see how it contains all the same information as in the recipe but in a different format. It isn’t a better format or a worse one, just different. I could have shown it as a flowchart and it would still have been an algorithm. In fact, anything you can represent as a flowchart is probably an algorithm.

Usually, though, algorithms lead to things other than cookies. In pure math, an algorithm might lead to an single answer. Say you want to give someone change… they buy 10 cents of lemonade and hand you a $5 bill. For one algorithm, you (or the cash register) calculates the difference between their purchase and then you given them the difference. It seems so simple, of course that is how anyone would do it. Well, no, the other school of thought for creating change (another algorithm that can be used) is to count up from their 10 cents, handing them pennies until they get to a number divisible by 5 (none), nickels until they to a number divisible by 10 or 25 (none), dimes until they get to a number divisible by 25 (four), quarters until they get to dollars (two), then the number of dollars (four). The whole time counting it out: lemonade was ten cents, twenty, thirty, forty, fifty, seventy five cents, one dollar, two, three, four, five.

Both of these change-creating algorithms are valid. They can both be proven to work. Ok, that is one area where algorithms are different from recipes: proofs. I mean, I can experimentally determine that my cookie algorithm works but doing it. But can I prove it will always make cookies? I don’t know how to start to show that given the conditions described, it will always work.

But in the math and computer world, an algorithm is usually developed so that it works under certain  conditions and can be considered optimal in some way. How it is optimal, that is an interesting question (fastest? least possibility for error? least memory used?). When people say they study algorithms, they not only learn all the different ways to sort through a list of data, they also learn how to determine how one way is better than another and under which circumstances.

Well, as usual, I’ve totally forgotten the point of this post. And I find myself strangely hungry for cookies. I hope there was a point. If not, well, I hope you have cookies too.

 

h1

Time flies like a banana

May 3, 2012

As we traveled east, many of the gadgets have not done well with the time change. The iPhone, teacher’s pet that it is, offers a near perfect user experience. As we crossed the time zones, the iPhone continues to display local time whatever that is.

For something so seemingly easy, that is incredibly difficult. None of the other gadgets come close.

The iPhone has four sources of time, let’s go through them and work through why the other gadgets don’t work as well. First, the phone, like many gadgets, has a clock. This is a crystal that counts how many ticks since it was booted. The ticks could be from a  32.768kHz crystal (a real-time-clock or RTC component that keeps a slow-for-a-computer heartbeat). Like any watch, all you need to do it tell it what local time is, and the RTC (or other crystal) maintains it. However, it will drift off from the correct time (particularly if it stays in a hot car for a long time or in a particularly cold room). So when your 1984 Star Wars watch would lose a couple minutes a month, that is why. The clock counts ticks from when you set it but if the ticks are off by 0.01%, you end up losing a minute a week.  Temperature extremes makes this worse.

Ok, so that is old, old method for doing it. But if you have nothing else, a gadget with a crystal will keep time reasonably well. Though, it can’t tell if you’ve crossed timezones. That is why we had to reset the car’s digital clock every day or two.

The iPhone also has a GPS which isn’t only for location. GPS provides very accurate time information. However, the time is not local time but UTC (Coordinated Universal Time) which, for this purpose, is the same as GMT (Greenwich Mean Time, from when Greenwich, England was the center of the world). In California, we were GMT-8. Well, sometimes; California has daylight savings time so the offset shifts depending on the season.

This is (nominally) to reduce energy consumption as people tend to be clock based. The time shifts so the bulk of the daylight is after people wakeup. Sunlight at 4am in’t that useful but by shifting the clock, that sunlight moves to 5am and the evening light moves from 7pm to 8pm, a reasonably big win for folks stuck in 9-5 jobs.

Gadgets hate daylight savings time. Well, the programmers of gadgets hate DST.  Not everywhere in the US has daylight savings time (ahem, Arizona!). So now, a gadget using GPS time needs to know how to map from location to time and whether that place uses daylight savings time. It also needs to know when DST begins and ends, which can change (thank you, President Bush), causing devices that you (the customer) end up having to change 4 times every year (correct DST, gadget’s faux correction; forward and back). Oh, but there are some counties in the US that vote on whether to do DST each year so it isn’t enough to just use the current protocol.

GPS provides a signal that is both good and bad: it is very accurate (the gadget can know how long a second is to nanosecond precision) but not very precise (the gadget can be hours off of local time but it would always know what time it is in Greenwich (gee, thanks, England!)). Since it is very accurate, I’ve used it in devices to time how long something took, was it 0.00011 seconds since the system heard a gunshot or 0.00013 seconds? As a stopwatch, the GPS clock is fantastic.

A GPS can also be used to keep a a crystal real time clock accurate. Every time GPS updates the time (every second), the gadget (microprocessor) counts how many ticks the RTC had. Now, it can predict for the next second how many ticks there will be (the drift associated with the crystal is relatively slow so this works well).

The user still has to set the time. And reset the time for daylight savings time. And change the time when the user moves to a new timezone. The GPS gave us accuracy but didn’t solve any of the other problems.

Ok, so the iPhone also has WiFi which can help with some of these. It can use the internet to contact a mainframe server and ask, “what time is it?” The gadget doesn’t really need a GPS for accuracy, it can use the standard servers and Network Time Protocol (NTP) to get accurate timing information (or Simple Network Time Protocol to get reasonably accurate time information). Unfortunately, this is UTC as well so it has all the disadvantages of GPS: it has to ask the user for their offset (usually they ask you to select a nearby city and the gadget figures it out; and all of the daylight savings time complexity). NTP is a general internet service, available using different servers. A gadget manufacturer can instead have the gadget call home to their own server which can provide more information than just NTP.

However, if the gadget has WiFi and GPS, it can contact a server with a query that essentially says, “I’m here, what time is it?”  The GPS isn’t completely necessary for the WiFi phone-home method to work. There are databases of WiFi networks and their location (the iPhone uses those to help locate you!) so the gadget can phone home with the WiFi network and probably get the time that way.

The server can have a much larger daylight savings time database than the gadget (and one more easily updated with the vagaries of humans). The weak point of this plan is the server… if the gadget can’t get there, it will act stupid.

In the car, the gadgets don’t have WifFi so things like the iPad don’t get updated until we get to a hotel and log on. Then, the iPad, disconcertingly, loses an hour sometime between I get used to it being wrong and when I look at it again and wonder how it got so late.

There isn’t  a standard for how to do this conversion from location to local time. Well, there is the Network Identity and Time Zone protocol but if you go look at that you’ll notice is isn’t exactly a networking protocol with the ubiquity of NTP. Instead, it is phone based.

The iPhone is actually a cell phone (yes, I know it is a somewhat terrible phone but it has cellular technology so we’ll give it the benefit of the doubt). As this gadget moves, it connects to the cell towers and asks, “Beg pardon, but do you have the time?” and changes to the new time if the cell towers give something different than the device’s current time.

So, all a gadget needs is a cellular modem and a contract with one of the major cell phone vendors. Then it can function as a reasonably accurate clock, always updating to local time.

Or the gadget can just assume its customer never leaves their home time zone and make them set the initial time. And then it can use a crummy real time clock and let the time drift. Not that big of a deal, the clock will be correct-enough 99% of the time. Since we want our gadgets to be cheap, not many things can afford to have all the supporting hardware.

(Thanks to Christopher White who complained enough about broken gadgets that I put this together._