Three weeks before the Houston Maker Faire Chris came to me asking if we could whip up a low cost giveaway for the faire. I wanted to giveaway something more than a blinky LED badge since that is the typical electronic swag at Maker Faire. It had to be something that the person would wear and would want to show off to other Makers to spread the word about MacroFab. Blinking LEDs are always necessary though. The budget was set to under $3 a unit and I was given only three weeks to prototype, design, and manufacture the giveaway.
The Macro Watch stemmed from those constraints. I picked the PIC16F527 microcontroller by Microchip to be the core of the watch because it was the cheapest MCU I could find that had enough I/O and I knew at least a little bit about it in terms of writing code for and programming. The watch shows time in binary since doing so requires less LEDs to display time than the usual watch patterns, driving the cost down. The least expensive SMD 32.786KHz crystal on Mouser (part # ABS25-32.768KHZ-T) was used to make the PIC16F527 run in “LP” mode (Low Power Crystal Mode) and help increase the accuracy of the timekeeping without blowing through the battery quickly. MacroFab House Parts were used to fill in the rest of the passives and switches. For the wrist strap, I ordered ESD wrist straps from China in bulk.
The plan was to spend 1-week prototyping and designing the board, 1 week for parts to arrive, and 1 week for assembly and packaging. An aggressive schedule on the R&D side but doable. What could possibly go wrong?
Stephen had an old PICDEM Lab prototyping breadboard so I ordered some PIC16F527-E/P components which are the DIP version of the microcontroller I was planning to use. A couple of days later I popped it into the PICDEM Lab breadboard, plugged in a PICkit 3 programmer, and was talking to the PIC16F527 right away. Unfortunately, that was where the luck ran out.
The first was to get an LED to blink. Easy no? I plugged an LED in the RA0 port and wrote a small blinky program. LED did not blink. I was not very familiar with this chip and figured it had to be some kind of configuration issue. A couple of hours later, after triple-checking my hardware and code, I came across table 6-1 “PORTA PINS ORDER OF PRECEDENCE” which lists the priority of how the configuration registers use the pins. I knew about setting the ANSEL registry to 0x00 but there was “C1IN+” listed on RA0. This PIC had comparators that were enabled by default! The register CM1CON0 had to be set to 0x00 as well before RA0 could be used as a digital GPIO. Finally success! Blinking LEDs!
With the idea prototyped I quickly moved on to the schematic and layout of the watch.
The PIC16F527-I/ML is the QFN version of the PIC16F527 and I used it as it was the smallest package available. To power the watch a CR2032 battery holder was picked — it’s a standard size battery and has decent capacity for a coin cell. To reduce the board area and further drop the cost I chose to use one dropping resistor for the entire LED bank. The idea was to matrix through the LEDs one at a time. This will come into play later as being a bad idea. The schematic took only a couple of hours to fill out with most of that spent designing the PIC16F527-I/ML and battery holder in Eagle. Parts were finalized and orders placed at our part distributors.
The layout was a typical two-layer PCB. I made sure a standard 20mm wrist strap would fit inside the cutouts this was the width of an ESD strap. The copper pour around the cutouts strengthens the board.
We panelized the Macro Watch in 5 by 5 panels and a week later they arrived. Black solder mask and white silkscreen.
With the boards in we had 6 days to build the boards and finalize the firmware. we built a test panel before moving onto the production run. More issues! First, the PIC16F527-I/ML only comes in tube and so it would have to be hand placed, because someone was already using the tube feeders. Everything else went on the pick and place for assembly. I did not test Low Power Crystal Mode on the bread board and when I enabled that mode on the production board I could not matrix the LEDs fast enough to prevent flicker. The only fix was to drive the LEDs on all the time. This has the side effect of the LEDs getting dimmer when the seconds LED blinked. Trying to save $0.10 on the BOM forced me to run the LEDs improperly.
I changed the resistor from the specified 470ohm to 100ohm to reduce the impact of the seconds LED flashing which helped a bit. After changing out the resistor on the pick and place we ran the rest of the boards building a total of 150 Macro Watches in an afternoon. Assembly went really well with no rework needed on any of the boards. With only 5 days left till Maker Faire it was time to wrap up the code.
The code works by using Timer0 on the PIC16F527 to time keep. Using the 32.768kHz crystal and no timer prescaler (by setting the prescaler to work on the WDT instead of Timer0) the Timer0 ISR happens 32 times a second. The ISR counts 32 times and then adds one second to the current time. The pad labeled RA2 on the Macro Watch is high when ISR starts and goes low when the ISR finishes.
The main loop of the code is a small state machine that keeps track of what mode the watch is currently in. The first state is the idle state where the watch polls the switch and awaits user input. Once the button is pressed it moves to the second state which calculates how long the watch will display for and then it moves on to state three. State three does the bulk of the work by branching based on how much time the display has been on for and what the user is currently doing. The watch is also driving the LEDs in this state. If the user has held the button for more then 3 seconds the watch goes into state four. State four advances the time. The longer the button is pressed the faster the time advances.
I wanted the main loop of the code to sleep when the watch was in the off state but on this particular PIC Timer0 actually turns off in sleep mode. The only way to wake up from sleep mode is toggle the reset pin, a Watch Dog event, or an outside pin change driven interrupt. Both not ideal for time keeping.
Three days left till Maker Faire and the code is finalized and programmed onto all 150 Macro Watches. At this point my desk is full of Macro Watch panels, CR2032 coin cells, and packaging.
Then disaster struck. The ESD wrist straps I was going to use as watch straps were stuck in customs and would not arrive until the day after Maker Faire. Chris scrambled and found some inexpensive NATO style wrist straps and overnighted them to the fab and they arrived on the Friday before Maker Faire. This blew my budget of $3 a unit but we were back on track!
Packaging consisted of a small bag, some basic instructions with a URL to the github repository, the NATO wrist strap, and a Macro Watch with a CR2032 battery installed. All 150 watches where finished Friday afternoon.
The Macro Watch was a huge hit at Maker Faire. I think I explained how to read binary over a hundred times that day! Everyone really enjoyed the watch. The kids seemed to pick up on how to read it faster then the engineers that came by the booth. The watch is 100% open source and you can find all the code and hardware at the MacroFab Github Repository. There is more information about the watch and instructions on how to use one there.
So what did I learn from all this? Budget more time for R&D then you think. With 2 more weeks of time I would have been able to get a working prototype done first before jumping into 150 production units. I was able to scrape by with some code changes and swapping a single resistor out but anything more complicated would have required a new panel spin and we would have missed Maker Faire. Extra time would have allowed us to get the ESD straps in time so the project could have come in on budget. Less stress is also a benefit.
Going forward I am looking at replacing the PIC16F527 with a Silicon Labs MCU (like the EFM8BB10F2G) for cost and power reasons. Most of the code should be able to port over to the new MCU. Fixing the LED issue is also a priority. I am hoping to have the next revision of the watch done by the start of next year.