I have been obsessed with this project for the last couple weeks, and just submitted my design for the Time of Day module to the Bit Lab for evaluation. It is similar to the prototype I made and proposed above.
Here are some pictures:
It works!
Here's what it looks like, close up:
That's a LOT of soldering. I needed this diagram to keep it all straight:
(I saw a dream bit asking for a fish. Do you suppose the above drawing would work for that? Squint if you don't see it!)
Used in a circuit, it looks like this:
The time used by this bit comes from the 16.00 MHz ceramic resonator. I had initially thought I would need a quartz crystal, but the resonator's resolution is fine for this application (and it reduces the number of components on the already crowded board by the two capacitors.)
Here is the updated schematic, with added protection of the time frequency circuitry, AND those opa4342, rail-to-rail op-amps that I got from ebay:
The ATTiny85 sketch is really simple. It looks at time as an 8 bit number, digitized from 0 to 240. This value is fed out through the pwm output, and hella-filtered (op-amped RC: 4700 ohms and 10 µF) to a steady analog voltage of 0 to 4.704. This gives a voltage:time conversion of 196mV per hour. Since this value is important for using the bit, I wrote it right on the circuit board. Here's the sketch:
// Time of Day
// precision = 1/10 hour (6 min)
// 072815 - clh timebit01.ino
// 080415 - clh made into a perf-board bit
// ------- declarations -------------------------
const int timeOutput = 0; // (pin 5)
const int setSwitch = 1; // (pin 6)
const int timeInput = A1; // (pin 7)
unsigned long previousMillis = 0;
unsigned long aTenthOfAnHour = 360000.;
byte outputCount = 0; // 0 is 12am & 239 is 11:54pm
// ------- setup --------------------------------
void setup() {
pinMode(timeOutput, OUTPUT);
pinMode(setSwitch, INPUT);
SetClock();
}
// -------- main --------------------------------
void loop() {
// Do this part every aTenthOfAnHour milliseconds
if (millis() - previousMillis >= aTenthOfAnHour) {
outputCount++;
if (outputCount > 239) {
outputCount = 0;
}
analogWrite(timeOutput, outputCount);
previousMillis += aTenthOfAnHour;
}
// Do this part every time through
if (digitalRead(setSwitch) == LOW) {
SetClock();
}
}
// ------------ subroutines ---------------
void SetClock()
{
outputCount = analogRead(timeInput) / 4;
analogWrite(timeOutput, outputCount);
}
If anyone is thinking of making their own real time bit, please discuss it here. I'd love to help, and also learn from your ideas!
ps, there's a project using this bit, the Functional Analog Clock.