Here's the second half of the design notes on the card. I've hopefully covered most of the design decisions made, but if you've got any other questions, feel free to ask.
Clock software is written in C using Atmel Studio 7.0, and compiled with the Atmel supplied compiler.
The software running on the clock is pretty dumb. Almost everything runs off the Timer Counter 0 interrupt, which rolls over at a 256Hz rate and generates 3 interrupts:
- TC overflow: turns off current tube anode
- TC compare 1 - selects cathode for next tube
- TC compare 2 - enables next anode, then does "clock stuff":
- Detecting falling edges on the RTC /INT output, and counting the current time
- Debouncing the buttons - done with simple up/down counters.
- Handling button pushes for incrementing hours and minutes, and writing the new time to the RTC.
Timer Counter 0 uses the SAM20's OSC32K internal oscillator as a clock source.
In addition to the timer, the main() loop is used to provide a basic text menu for fiddling with the clock's internal bits.
To allow calibration, Timer Counter 2 is clocked from GCLK1, which is sourced from the CAL input on the card. The 1PPS input from the RTC is fed through the external interrupt controller and event system on the SAM, and is used to capture the value of TC2. This basically makes a frequency counter.
The schematic and layout were done in Eagle. The combined PCB panel size (160x70mm) is too big for the freeware Eagle tools, but I have one of Cadsoft's non-profit licenses which allows 160x100mm dimensions and up to 6 layers. I've been using Eagle as long as I can remember for hobby projects and have a huge number of parts created.
For safety reasons, no high voltage track is present on the bottom layer of the control PCB. This means I can leave the bottom of the PCB exposed, and make the base slightly thinner in the process.
The PCBs were ordered from dirtypcbs.com - I've ordered from these folks several times now and they've never let me down. For some reason ENIG only ended up costing $2 more with this order, so I went with it - gotta say I love the look of ENIG and black solder mask together.
I'm Canadian, which means I work in a bastardized combination of imperial and metric units. I apologize.
Each card is 6.25" x 1.25" in size, or about 160x32mm. The distance between the two cards as 1/4" or 6.35mm. The two boards are 1.6mm (1/16") thick, which results in an overall sandwich thickness of 3/8". I could have used thinner PCBs but wanted the boards to be fairly rigid.
Pin sockets are Harwin H3184-01. These are 6mm tall, with 5mm of that length extending into the PCB. Subtracting the 1.6mm PCB thickness, they protrude 3.8mm into the 6.35mm clearance between the two PCBs - this means that any parts on the bottom PCB must be at most 2.95mm tall. I set the rule that any parts underneath the pin sockets must be 2mm high at most.
Finding pushbutton switches was a challenge. Typical right angle switches are too tall to fit between the boards, and I wanted a protruding activator that pokes through the side of the case so I wouldn't have to fabricate pushbuttons. I also wanted a through-hole switch for mechanical rigidity, which ruled out SMT options. Ultimately I ended up finding a TE branded switch with suitable dimensions and cut back the top PCB to clear the switches.
To connect the two boards, I chose a 20-pin AMPMODU 50/50 connector with a 0.250" board-to-board stack height. This connector wasn't chosen for any real reason other than it fit.
The case was designed in Sketchup. The eventual plan is to machine a case out of aluminum bar stock - I'm currently trying to figure out Sprutcam, however I may just manually machine it on the Bridgeport at work.
For a mechanical prototype, to make sure everything fits together nicely and all my holes are in the right place, I had a case 3D printed. I used the 3dhubs.com service and had it 3D printed by a local guy with a 3D printer. The surface finish on the clock isn't perfect (I had it infilled to save a few dollars) but hey, it's a prototype.