build-log
An Introduction to Microcontroller Selection, by Someone Who's Never Selected a Micro Before
*edit: this page has been cross posted on the project wiki, and those who would like to help add to it are invited and encouraged to do so there. https://github.com/awkwardengineer/Clock/wiki/Microcontroller-Selection
For a while now, I've been kicking around the idea of a Voltmeter clock and I'm ready to get the project moving forward. I've built a prototype (one that at least moves the needles back and forth and looks kinda cool), which is up here.
At this point, I've found a source for the voltmeters themselves and a general idea of where to get the sheet metal case. Because the meters are customized, I've set a general goal of raising funds / selling a minimum of about 250 units, or the cost of the custom meters just isn't worthwhile.
A Brief Note on Open Source
After giving it some thought, I've decided to open source this project. Voltmeter clocks have been done before and will be done again, so there's not much IP in it. I mean, I was able to build a prototype fairly easily and I'm sure someone else could build one too, if they really wanted to. As such, I've decided to keep all the design, documents, and manufacturing files available in a Github repo. (I'm still squeamish about sharing price quotes and manufacturing sources, so that will be private for now, but I may change my mind in the future.)
Intro to Microcontroller Selection for the Voltmeter Clock
The general idea with microcontroller selection is to pick a component that's powerful enough for your application, but not too powerful, as that would end up costing more money than was necessary. The selection process for the Voltmeter clock relies mostly on peripheral knowledge that rubbed off from hanging around some electrical engineers and extrapolation from the prototype (which worked mostly because of blind luck).
If you're wondering what makes a microcontroller different than a microprocessor: What makes a micro special is that it has a lot of built in circuitry for helping it interact with the rest of the world, and well.. control things. There are internal timers, analog to digital converters, analog outputs, digit communication, and special inputs called interrupts that redirect the normal program flow in response to an event. All pretty cool stuff in a package that's smaller than your pinkie fingernail.
I'm aware of a few families of microchips, (Microchip, TI, and Atmel), and each maker produces a gazillion varieties of chips with different inputs, memory sizes, speeds, temperature ratings, and so on. To pick the right chip for production is a mix of art and engineering.
As a starting point, the prototype uses a Digispark, which is built around an Atmel ATtiny85 chip, which has 6 free pins available, and even gets double duty out of the pins, using a burnt-in program called a bootloader to switch some of the pins from programming inputs to whatever the end user wants to use them for.
Selection Decision 1: Stay with Atmel
Unfortunately, the 6 pins aren't enough if I want to add a proper oscillating crystal so the clock will stay accurate. (The ATtiny85 has an internal oscillator, but it drifts noticeably every hour.) I do however want to stay with Atmel, because the chips are cheap, readily available in small batch volumes, and the chips are well supported through the Arduino community.
The pin requirements:
Below is a block diagram of the clock circuit, which is followed by the pin requirements.
Pin summary
1 analog in to read selector switch / voltage divider
2 interrupts to read quadrature encoder
2 PWM outputs
3 digital outputs for am/pm light, alarm set, and buzzer
2 pins for external oscillator crystal
All together, this works out to 8 I/O pins, the 2 clock pins, and whatever is needed for In System Programming (ISP) pins, which can serve double duty. (If anybody would like to explain a general lesson for doing ISP without interfering with the existing peripheral circuits, I would love to get one.)
Atmel provides a somewhat overwhelming product selector, and if you set the number of input pins higher than 6, you see that next category of chip has at least 11 inputs. I also know from my prototype that the compiled code was 3kb in size, plus 2kb for the bootloader, so I need a chip with >5k memory. Using the selector, that narrows down to the ATtiny84, with
8kB memory [check!] Interrupts galore [check!] 2 PWM channels [check!] Digital channels galore [check!] External clock pins [check!]
Plus, it has support for ISP programming.
To expand on for next time:
Details of the chip pin outs, connecting the oscillator, ISP programming, and more.