RSS

Turn Signals, Malloc, and the Arduino

June 30

Late at night, while filtering the whole of the Internet through my fingers, I’ve identified a disturbing trend among those who would call themselves “roboticists” or “hardware hackers”. Its a trend that, I believe, will soon bring about the end of the casual EE.

Imagine a world not dissimilar from the one you know. Same styles, same social standards, same society. It looks, feels, and tastes exactly like the world you see when you walk out your front door, except for one small difference: the traffic laws have quadrupled. The right-of-way at a stop sign depends on the color and make of your car, not who arrived first. You must blink your turn signal four times before a turn, and seven before a U-turn. If you want to change lanes, blink twice, wait a full second, then twice more. You are only allowed to raise the volume of your stereo to 6dB above the ambient road noise, and you can only use your windshield washing spray if your view is obscured to less than 60% opacity.

Absurd, I know, but bear with me.

Because of all of these laws, you are required to get re-licensed to drive. It’s a much more complicated test, and an astonishing 80% fail. One enterprising DMV employee decides that the test is simply too complicated for more than 20% of the population to understand, so he builds a simulator. The simulator operates just like your car, but it makes all those new rules easier. The turn signal blinks automatically, a voice tells you when it’s your turn at a stop light, the windshield cleans itself when its dirty, and your radio volume is self-controlled.

This brings about an exciting new era in driving, suddenly hundreds of people can get their license! There are only a few additional rules you need to know, and everything else is just like before. Aunt Edna passed on her first try, and your club-hopping cousin, who has a cell phone glued to her ear, only takes seventeen attempts to pass. The DMV employee is lauded by the press for freeing the populace from the tyranny of government regulations.

Two days later, you get a call from your cousin: she’s in jail and needs you to bail her out. Apparently, after twenty-seven unpaid traffic violations, the police issue a warrant. Aunt Edna was pulled over just yesterday for listening to Hanson’s “MMMBop” too loud. In fact, you got a ticket this morning on the way to work because the barista forgot the cinnamon-jalapeno spread on your peach and raspberry bagel, so you made a U-turn, and blinked eight times.

Seems everyone is having these problems for some reason. Meanwhile, the 20% that passed the hard test are watching, and they’re laughing.

At you.

They know the truth: as cool as the simulator is, as much as it feels like, tastes like, and smells like driving, it isn’t driving. They know that its important to know how loud the road noise is, even if you don’t usually turn your radio up that loud. They know that the real reason you use your blinker seven times while making a U-turn is so that the traffic cameras don’t ticket you for running a red light. They know that using your windshield washer fluid before the 60% mark actually makes it worse. They know all this because they learned the real rules, the rules the real world is going to judge you by, not the simple rules the simulator uses so that you can get your license easier. It turns out, the devil is in the details, and to be a good driver, you need to know the details.

Now this is an absurd example, but you get my point: you can’t play in the big leagues using minor league rules. Some rules are aggravating, some have no point, some are even completely inefficient and only got passed because a senator’s son has a yellow fiat and never wants to wait at stop signs. The harsh reality, however, is that if you don’t follow the rules, you’ll get in trouble, and eventually, no one will ride with you.

This is what the incredible, exceptional world of hardware engineering has been reduced to.

I completely understand the draw of “computing platforms” like the Arduinio. I love the Lego Mindstorms, and they certainly have their place. But sticking two shields together and making your toilet tweet, is not the same as understanding the IP stack or chip-to-chip communication. And making a motion-detecting velociraptor is not the same as understanding sensor design or interrupt vector tables.

My ultimate point is that you don’t really want to make your toilet tweet, you want to see if you can make your toilet tweet. The hobbyist community is all about self- and community-education, and if you ignore the rules, you aren’t really learning anything.

I’ve taken quite a few programming classes, and there are two major pass/fail moments in each student’s progress where you can tell fairly easily if they are going to cut the mustard. One is the concept of pointers, which tells you if they have the mental capacity for real programming, but to judge the heart of the programmer, ask them to build a stack using nothing but native types. Some will give up, “what do I need this for?” Some will complain that STL or Java already has a Stack class, “why do I need to build this when its already done?” But the true programmers will keep their head down and struggle mightily to produce working code. These students realize that the Stack isn’t the point of the exercise. The point is to teach you that you can build a Stack. Granted, the chances of you using it again when someone else has one pre-built that also takes into account templating and inheritance is slim to none, but it taught you about dynamic memory allocation. And someday you’re going to be able to laugh at a “programmer” who taught himself by reading Internet how-tos and is confused why adding  1000 elements to his stack takes so long. You’ll laugh and tell him about the wonders of malloc, and how memory isn’t flat or contiguous, and then hand him that Stack assignment you hated so much in college.

Sometimes the 80/20 rule actually works, and real-world problems are one example. Yeah, 80% of the time you’ll be able to ignore most of those pesky rules, but as soon as you try to do something interesting, you’ll need to know about traffic cameras and turn signal blink rates.

In closing, the Arduinio may seem like a great thing; for only a few dollars you can get an easy-to-use platform that makes rapid prototyping a breeze. But two projects later, after you’ve used your PS2 controller to blink LEDs, and changed the speed of a motor based on the humidity of the air, you’re going to realize that there isn’t a shield to do all the cool things you wanted to do when you started, and you don’t know how to build a shield. And if you ask online for advice on building a touchscreen, you’re going to get asked if its resistive, capacitive or inductive, and you’re not going to know the answer, or why it even matters. Do yourself a favor and start at the bottom; learn why a stylus doesn’t work on a capacitive screen. Its a bit more work at first, but you’ll be well served by it.

 

Posted by on June 30, 2009 in Rants

5 Comments

Tags: , ,

5 responses to “Turn Signals, Malloc, and the Arduino

  1. Anita Duncan

    June 30, 2009 at 6:13 pm

    I think you’re majoring in the wrong field!  You should be an Author, you have the flair for the dramatic and your quit gifted in they way you present it.  I don’t understand most of what you where talking about , (thank goodness I’m not an engineer) but it’s really impressive and humorous.  Good job, Love Anita 

     
  2. Leah Shanker

    July 6, 2009 at 9:22 am

    Or a teacher.

    We’re definitely on the same page about how things should be taught to novice programmers: good old fashioned bash-your-head-against-a-wall until you can actually implement a hard concept from the ground up.

    A juicy morsel from my UI Usability class last semester is the concept of matching an interface to a user’s “mental model” of the concept. Essentially, the premise is to design User Interfaces around the expectations of typical users and the way they understand the problem. A simulator for a car would probably feature a dashboard, for example.

    The big “tell” for whether a user interface matches the user’s mental model happens when you ask them to predict what will happen next or watch them try to resolve an error. I think this makes a great analogy to the points you make in your blog. Your average tradeschool programmer probably spends a lot of time copying and pasting code from the internet (Truer than you might imagine) in a measly attempt to cover up the underlying problem: lack of conceptual understanding.

    Great post, Anita’s right: you really have a gift for storytelling!

     
  3. Lukas

    February 12, 2010 at 8:24 am

    I think the Arduino is a great opportunity for people who have no clue about “technical stuff” to explore this world. Finishing Computer Science studies, I understand pointers and I had to programm a stack, BUT I don’t think I am a good programmer. The malloc tag confused me, because I was wondering about memory allocation for the Arduino. I found no answer, but a nice entertaining story, except the provacative malloc tag ;)

     
  4. Matthew

    February 16, 2010 at 9:40 pm

    Lukas, I think you missed the point of this post, which was that the Arduinio doesn’t require you to Malloc. It’s this abstraction away from the internals, without the honesty to say that the platform is not a hardware platform, that makes the Arduinio dangerous.

    The Arduinio is a mid-level software playground, specifically designed so that you don’t have to know low-level software or hardware, such as memory allocation or sensor interfacing.

     
  5. Austin

    April 30, 2011 at 9:41 pm

    Ha!  Ok.  I enjoyed this article but I found it for a rather ironic reason.  I am a software developer with a pretty strong background in C and C++  (no problem with that hand-made stack you mention) but I am really new to working with embedded hardware.  I actually ended up reading this article because I am trying to use malloc() on an Arduino to implement a stack and am coming up against some bizarre aspects of the Arduino platform.
    Anyway, I enjoyed the article and completely agree with the sentiment behind it.  Keep it up.

     

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>