Brave Pedestrian Just another WordPress weblog, yo

31Oct/110

Torchlight Kiln Controller

Posted by Brandon

For the last couple months I've been working on a kiln controller for doing glass work. I got the idea to do this when I saw the pain that Kyle goes through to type in a program on our current interface. $400 gets you an LCD display and three buttons - up, down, and enter. Very similar to The Onion's Macbook Wheel. I still haven't entered a single program into that thing. I'm scared of the pretzels I will have to twist my mind into.

In contrast, I figured it would be easy enough to build a web application that runs on the phone and communicates with an Arduino chip to do the heavy lifting on the kiln side. Well... web apps are kinda what I do, so I'm biased. But I think the interface speaks for itself. From the Programs screen you can enter a series of temperature gradients, then press the Load button to upload it to the Arduino chip. Once that's done, go back to the main screen to see current status and Start/Stop/Pause the program.

On the Arduino side I've got an HTTP server running which accepts incoming GET/POST requests and responds with JSON. It can accept program step data, as well as the various commands that the HTML interface supports. Previously I had gotten a PID algorithm working and firing an electric burner via a Solid State Relay.

Thermocouple Shield
Thermocouple Readouts

The breaking news today is that I finally got the temperature readouts working, which completes the feedback loop and allows the PID to both monitor and control the temperature. Reading from a thermocouple was way more complex than I thought. I was originally planning to do the conversions in software (bah, everything can be done in software, why would I pay for hardware?), but after reading what's involved I opted for a hardware solution. Particularly the problem of measuring the temperature at the point where you connect to the thermocouple leads is a problem that requires a physical sensor. If you're going to get a chip to do that, why not just get one that performs all the hand waving and gives you a nice linear value? Seems like a no-brainer, just hope I can bring the price down when it comes time for production circuit boards.

The next step is to get the program steps working reliably, and to add in control of the rate of increase/decrease based on the program definition. If testing goes well I'll be using it with my kiln before Christmas.

21Jun/110

RVM Group Deleted on Dreamhost VPS

Posted by Brandon

Just ran into a gotcha with RVM/Ruby on Rails on a Dreamhost VPS. When I installed RVM on our server using the multi-user instructions, it created an 'rvm' group. All access to RVM pretty much hinges on this, since the files in /usr/local/rvm are owned by root.

The problem is that Dreamhost's web panel wipes out your user and group files whenever you add new ones. If any users or groups were added via the command line, they won't be remembered.

In order to clean up, you should add an 'rvm' group via the web panel, then `chgrp` all the files in /usr/local/rvm to the new group. The 'id' of the group will have changed, so even though it's named the same this step is necessary. You'll also have to re-add `root` and any users that need RVM to the 'rvm' group.

If everything's successful, you should be able to `cd` to a directory with an .rvmrc and successfully trust the file. RVM saves trusted files to /usr/local/rvm/user/rvmrcs, so if it can access that you're probably good to go!

Filed under: Programming No Comments
19Apr/110

How to Create a Product in a Day

Posted by Brandon

I've been thinking a lot lately about how to get customers - how to connect to some kind of audience and deliver value.  I've been talking with several innovators in the local community and I'm seeing a common pattern.  Good entrepreneurs don't waste their time building a product with no market.  They're putting food on the table with their work, and they need to make that count.  Consequently, they place a high value on information that tells them where the market stands.  Only if the stars align do they put their weight in that direction.

I also watched Seth Godin's talk on "Why marketing is too important to be left to the marketing department."  Great watch if you haven't seen it.  I pulled one really key idea from this: build something that people will talk about.

So now to the meat of it.  For a while now I've been mulling over an idea:

Wouldn't it be great if people could do odd jobs for each other, to reduce the bustle of a busy life, and maybe even build some community?  And what if we could connect that information network with the real world?

Cool.  So... build a site to let someone make an ad, print a QR code and post it on a telephone pole, and there you go.

Likely what's going to happen next is some tumbleweeds will blow past.  Who uses these things anyway?  Who's gonna scan the darn thing?  I put up that ad a month ago, and my lawn's still not mowed!

So how do you get people to talk about a QR code?  Those things are an eye sore.  The big barrier here is knowledge of what it is and how to use it.  In order to overcome that, people need to be interested and motivated enough to ask their friends, and to help each other figure out the mystery.  Well, what about posting it along side some art work - an icon that gives you a hint?  If people think it's cool, quirky, curious, will they figure it out?

The good news is, it was easy to build.  Last weekend I made up a name and logo and had some beers with a friend while I sketched out a wireframe.  Sticking to the basics, I was able to build the app and publish it over the course of Sunday.  It's dead simple, to be sure, but it works.  Now I have a model that I can test out in the real world.  I'll find out soon whether people are interested, and can start acting on real data instead of guesses about what the market wants.

Will this turn to tumbleweeds or customers?  Don't know, but it'll be an adventure!

Here's the app:

odjob.info

Try it out and hit me up on twitter @brandonjmason if you have questions or comments.

Thanks for reading!

17Nov/100

Assertion Class for Testing JSON

Posted by Brandon

I'm in the process of building a RESTful web service and had need of some decent assertion steps for testing JSON. I came across this discussion, and while the original poster opted for a conversion to XML, then xpath parsing, I quite prefer Michael Schuerig's method. I wrapped this up in an assertion class which should be reusable in other projects.

You can use it in a step definition like so:


Then /^I should find "([^"]*)" in the JSON$/ do |selector|
json = ActiveSupport::JSON.decode(last_response.body)
json.should have_json(selector)
end

Now you can do something like this:


Scenario: get some JSON
When I send a GET request for "/foo/1"
Then the response should be "200"
And I should find "foo/bar/baz=10" in the JSON

You get back a detailed message if it fails:


And I should find "foo/bar/baz=10" in the JSON # features/step_definitions/rest_steps.rb:70
Expected JSON to include: foo/bar/baz=10.
Closest node found: baz.
Test: 10 Actual: nil
(Spec::Expectations::ExpectationNotMetError)
./features/step_definitions/rest_steps.rb:72:in `/^I should find "([^"]*)" in the JSON$/'
features/requests.feature:45:in `And I should find "foo/bar/baz=10" in the JSON'

This makes it much easier to understand why a parsing error occurred. The "closest node found" alone can tell you whether you got no document, half a document, or just the wrong value at your target location. Then the test and actual values give you the details. Everything you need is in one place, so you don't have to go digging around your app to find more information.