A P P L I C A T I O N S
J O U R N A L
Rapid Application Development:
Race Against the Clock
by Robert Severson, USBmicro
Tueday Evening, 8:30 p.m. Client call
I received a call from a long-time client of mine. He was in a bit of a bind. He needed a way to do a little bit of data gathering for a demonstration of part of his system for his customers. Iunderstood his system well, most of it was either original work that I had done for him, or earlier design work that I maintained. Some of the work that I do for him involved creating designs that became volume products; other work was one-of-a-kind test equipment. It was the latter that he was interested in. He wanted a piece of hardware that would have probably a one-time use. “It can be heldtogether with duct tape, for all I care,” he told me. “Just a quick design for you.”
So in the morning I will need to quickly assemble eight A/D chips, a set of screw terminals, and the USB to SPI board. This will mainly be made from rummaging through my parts bins. No problem. As they say, ignorance is bliss. Had I made an effort to check my stock of converters before going to bed, I probablywould have tossed and turned all night. But, I slept like a baby, oblivious to how my plans would be irrelevant come dawn.
Wednesday, 7:45 a.m. Frustration
My search turned up only a single A/D part. Some other project had consumed the other parts. I looked at several circuit boards imagining that I could steal enough A/D devices to make up for the missing seven parts. Nothing was found. Myplans would need to change. I couldn’t order additional A/D parts: even an overnight delivery would be too late for this fast-turn development effort. My plan changed to using a multiplex chip to read the eight analog values with the single A/D converter. I can use the digital lines on the U401 to control the mux.
We’re interested in your experiences in working with the AVR. Please send your tips,shortcuts, and insights to: firstname.lastname@example.org, and we’ll try and print your submissions in future issues.
He told me that he needed something that would operate on a laptop and gather about six different light levels. The device would need to sample about once a minute and log the data to the laptop hard drive. He described his plans. From what he told me I was making mental notesabout this little project’s specification. A simple set of photoresistors would suffice for the levels of light that he would want to measure. Six different channels - better make that eight, just to make sure – of measurement. The range and precision would not need to be great. For the relative measurements he was talking about 64 levels would suffice. Eight bits of analog to digital conversionwould certainly work nicely. His laptop only has a USB port, no serial or parallel ports. No problem, I was thinking. In fact I said this to him on the phone. He asked that I incorporate the data logging into a PC application that I had designed for him earlier. “No problem!” I repeated. “My demo is Thursday morning, I need hardware Wednesday by 4:00, he said.” “No problem!” I’m not sure who saidthat, but it sounded a lot like me.
Wednesday, 9:00 a.m. Eureka!
While rummaging through bins to find a suitable multiplex chip, I had a stroke of luck. I bumped into an application note on SPI design for the Atmel AVR. I had used the AVR quite a bit to talk to the SPI A/D devices as a master. This app note was an intro to using the SPI on an AVR as a slave. I was immediately filled withthoughts. Why not use a single AVR in place of the eight A/D converters? (Or what became a single A/D and a mux.) The AVR would be a slave SPI device, just like the A/D devices. There is an AVR that has eleven A/D pins. I used the ATTiny26 not so long ago.
Tueday Evening, 8:40 p.m. First plan
Perhaps it really wouldn’t be too bad. I know that I have some phototransistors in my junk bin for...