Basic Stamp: The Awakening

During my early years as a software guy, while still in college, I worked for a division of COSI in Columbus, Ohio. The group I worked with designed and built the interactive exhibits in the COSI museums as well as other museums that wanted specialty projects built.

After struggling with some hardware designs I was fortunate to get paired up with the guy working on a machine designed to show reflex delays. The machine basically lit up lights in non-predictable patterns. When a specific light was lit a timer was started and the visitor was supposed to hit a button. When the button was pressed the timer would stop and show the visitor how long it took them to react. If you tried to predict the light and hit it too soon, a buzzer would notify you of your mistake.

I was curious how it worked since most everything I’d seen up until that time was just using 555 timers, some relays and a few buttons. This project was much the same but housed something more interesting to me. The more complicated projects were all based on the BASIC Stamp II microcontroller from Parallax. The stamp was a tiny board with many I/O pins, built in storage and memory and a processor programmed in BASIC.

For this exhibit, the stamp was doing a lot of work. It was generating tones to play for each light that was lit, pseudo-randomly choosing which light to turn on, and when the key light was lit, start a timer all the while checking to see if a button was pressed. That’s not too shabby for a tiny, single threaded chip. Except it wasn’t working correctly.

The problem was that despite having multiple I/O lines, the stamp could only do one task at a time and to detect input, lines had to be polled. There was no interrupt-style triggering. That wouldn’t normally be a problem except while the lights were lit, a tone was being played using a built-in command called SINOUT (sine-wave out). While generating the sine wave, the stamp couldn’t do anything else. This meant the button press wouldn’t register unless the button was pressed during the short interval between light and sound events.

Since I wasn’t doing so well with the hardware projects, I was asked to take a look at the code for the stamp. Within a couple hours of first learning about its existence, I had figured out what was happening and fixed it. The answer was to chop operations up into small chunks. A mechanical button pressed by a visitor would trigger on the order of 100ms-1000ms depending on how long the visitor held it down. With that I decided to cut the tone generation into small chunks run in a loop to get the same total duration of time but with polling the button pin to see if it was pressed as well. I found a good balance that would poll often enough to catch the button being pressed while still pushing out enough sine wave that it sounded constant and smooth.

It took a few trial-and-error runs of uploading the program to get everything just right. When the others in the office came by to check out what I’d done, they were all surprised at how smooth it was especially after I explained how I accomplished it. It turns out the input problem was a common one they’d been running into and wanted me to take a look at another project that had been sitting for months. It took a day to get that one running right and it required interfacing with an Alcorn McBride sound machine.

I’m not sure at what point I became hooked on embedded controllers but I do know a new world opened up to me even if my bank account didn’t grant me an all access pass. It would be years before I rediscovered a love for microcontrollers. I’ll talk about that soon.

Ciao for now,
-Erik

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s