Little victories

A while back I played with using a CueCat to try to do a book inventory (OK, so I just wanted to play with barcode scanning). It went .. badly because it turns out the free CueCat was a crappy bar code scanner. A few weeks ago, a friend on Waterpoint pointed out surplus barcode scanners for sale from allelectronics.com. It’s just the gun part of a gun-shaped red LED barcode scanner. The catch? It outputs RS-232 rather than RS-232C. This essentially means that instead of -12V to +12V it uses 0 and +5V for signalling. It can’t be hooked up directly to a PC serial port. He gave me a list of parts to buy to assemble something that would convert it.

Last week I finally followed through. I’ve been wanting to play with with some kind of embedded development and/or hardware. I wanted something that was relatively easy to get started with and would let me play with a bunch of different things.

I ordered the barcode scanner and all the parts Ben suggested. Later that night, I came across a site about photography from R/C planes. He had described how he built a little timer to trigger the digital camera with a BASIC Stamp. It reminded me I also wanted to play with a microcontroller. I looked around a little at some inexpensive dev kit options. It had to have a simple, quick dev environment install for Windows. It had to be relatively cheap (in case it turned out I hated embedded development). I ordered a Parallax BASIC Stamp kit on the strength of a) that guy’s story and b) the Parallax web site’s easy to understand documentation and clear path to getting started. I may eventually seek other controllers to play with such as a PIC.

All of these parts arrived this week. I opened them up and poked around and paged through manuals and data sheets but didn’t feel like diving in to start anything. Until a few hours ago. I lay there in bed and suddenly realize that the interface that the barcode scanner had was exactly the interface that the BASIC Stamp was set up to read/write on any of its I/O pins and the power output on the demo board for the BASIC stamp was exactly right for powering the barcode scanner. I had to know if it was possible.

I cheerfully ignored the intro documentation that I carefully selected this kit in order to have and poured over the reference manual and data sheet that came with the barcode scanner. It looked too simple. I connected the power and ground from the barcode to the obvious places in the demo board and then connected the data in and out pins to i/o pins on the BASIC stamp while merrily ignoring the little voice that suggested not connecting strange hardware to my shiny new demo board without even doing any of the tutorials and not really knowing enough about this hardware to have very much confidence that I wasn’t going to somehow zorch things. The barcode scanner documentation and the BASIC Stamp reference material seemed to pretty clearly indicate that I was at least on the right track for how to hook things up, but it was much easier than I imagined it would be when I first had the idea to try this.

It worked. I figured out enough PBASIC to instruct it to read bytes into a “string” until it saw a CR (the barcode scanner sends DATA\n for each code it reads) and it just worked.

This is precisely the kind of little victory I needed to convince myself to attempt a much more ambitious project. It’s sort of a shame the uncontrollable urge to start this and see it go came over me at nearly three in the morning after I had already gone to bed. It might have been better if the documentation for either the STAMP or the bar code scanner had been a little more opaque so it didn’t look so easy. And then I then spent another 2 hours poking at it some more and writing this.