Author Topic: Clock - attiny85 - Thanks!  (Read 363 times)

0 Members and 1 Guest are viewing this topic.

Offline ehud42Topic starter

  • Newbie
  • Posts: 2
  • Country: ca
    • flying low
Clock - attiny85 - Thanks!
« on: February 11, 2023, 07:29:37 pm »
I poked at with a question about driving a coil direct from an ATTiny85. https://www.eevblog.com/forum/microcontrollers/driving-latching-relay-with-attiny85/

Well, thanks to the advice, the project is basically finished. It's a clock. https://www.flickr.com/photos/flyinglow/albums/72177720305936037

A couple "hacks" / clever bits:

I/O pins on a DigiSpark are 0.1" spaced. Using Pins 0 & 2 enables me to direct solder a screw terminal to the spark for connections to the coil.
The function to toggle the stepper is then simplified:

Code: [Select]
void Pulse() {
  static int p = 0;
  digitalWrite(2*p, HIGH);
  delay(32);
  digitalWrite(2*p, LOW);
  p = !p; // Toggle
}

To get the minute hand to take 1 full year to go around, I was aiming for 1 "tick" every 8,760 seconds. I experimented a bit with the ATTiny's sleep function, and after a bit of tweaking the loop timer, I got the second hand ticking once ever 8,765 seconds (average over 48 hours). Which turns out to take the minute hand 365.22 days to complete a loop. I'm "Leaping" for joy :-)

Running the clock backwards just requires the physical bar in the coil to be flipped over. This simultaneously fascinates and disturbs me. Electromagnetism is weird.

Based on some guidance from the above thread, and some tests with an oscilloscope, I added a couple 3.3v Zeners (3.3V were 1/2 the price of 3V at my local store) from each leg of the coil to ground.

Code: [Select]

     +--mmmm--+
     |        |
+->Z-+        +-Z<-+
|    |        |    |
|   P0       P2    |
|                  |
+--------+---------+
         |
        GND

Powered by an 18650 battery USB thing that provides 3.3V in addition to 5V. Plugged in for continuous operation with battery backup.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf