Sunday, July 1, 2007

Instant Gratification

One of the things I like most about the lathe is the sense of instant gratification you can get from using it. If you're using a 3-jaw chuck, there's no indicating in your workpiece like there is on a mill. There's no touching off the corner to get your zero, there's just cut and hope you like what you get. Making pens on the lathe has got to be one of the best forms of instant gratification out there. In a couple of hours you go from bits 'n pieces to something you can hand someone, and actually have them appreciate it!

But no, I didn't use my lathe this weekend. I did do some programming. Friday night I had the realization that one of my favorite robot controllers didn't really have any provision for getting at the SPI pins. After some conversations on the support forum I found out I was wrong (thank goodness!) but that the work-around wasn't the cleanest thing when it came to wiring. Rather than get huffy or mess up an already tricky soldering job making the mods, I took the other route: I wrote a software SPI master implementation. And it worked!

It's the closest I've had to the lathe-like experience on a microcontroller. I read the spec (it's pretty straightforward, I'll grant you), I wrote what I thought would create that pattern on the I/O lines, aaaaand... it didn't work. But that's only because I did a for loop that went from 0 to 6 instead of 0 to 7 (bit counting.) Change a < to a <= and everything worked perfectly. Maybe not the first time, but the second time is just about as good. Whee!

Code's checked in, and I'm looking at writing software I2C next. (Nope, the I2C pins are tied up, too, though the work-around for that is a lot easier.)

Can't beat it! Instant gratification is good.

Tom

No comments: