Propeller Clock with ATmega328P
This propeller clock is powered from 4x AAA Eneloop 1.2 V battery. An ATmega328P microcontroller is controlling the LEDs. 2 buttons are used to set the time, another button for resetting the cpu and a switch for power on. A magnet and a hall effect sensor (SS411P) is used to tell the microcontroller when it is at the starting position.
Working principle
The fan is spinning at 15 Hz, so 15 full revolutions every second. One revolution is 65 ms time. A timer interrupt is generated every 200 us. (65 ms / 200 us = 325) so in one revolution the timer interrupt is called 325 times. Another timer interrupt is used to count the seconds to track the time accurately. Meanwhile if no interrupt occurs the processor is calculating the LED patterns for the display in the main routine. If the hall effect sensor passes by the magnet a pin change interrupt is generated on PINB3. This interrupt resets the display to the home position. So the microcontroller knows that it is in position 0. From now on when ever a timer interrupt occurs the controller displays the next pattern of the LEDs only one column. This process is so fast that our eyes see all the patterns to show up at once, but in reality only one LED pattern is lit.
The LED patterns are stored in a 16-bit array. These LED patterns are outputted through PORTD, PORTB and PORTC. The 16 bits of the pattern are outputted as follows: The lower 8 bits 0-7 through PORTD0-7, bits 8-14 through PORTC0-5 and bits 15-16 through PORTB0-1. Hall sensor input pin is PORTB3. Button 1 input is PORTB4, button 2 input is PORTB5. PORTB2 can be used for infra red remote control.
Position sensing
For defining the home position I use a strong magnet which I took out from an old DVD writer. I mounted the hall effect sensor with a cable tie to the bottom of the wooden plate, where the propeller clock is mounted on. I soldered the sensor to a small piece of PCB and soldered the 3 wire of the 3 pin connector. Then I fixed the pcb to a piece of wood Just a little under the sensor I glued the magnet with a hot glue gun, so whenever the sensor passes by the magnet it sends a digital low level to the microcontroller. This low level generates a pin change interrupt.
For balancing the rotating clock I put a screw with heavy nuts and washers to the other side of the wooden plate so when it is spinning it doesn't get vibrating.
Powering the device
The powering is really tricky because the device is spinning around so you have three possible solutions:
1. Sliding contacts.
2. Wireless power transmission.
3. Battery on the rotor.
1. Sliding contacts are a bit complicated to make, also the contact have to be perfect so that's not an option.
2. I tried to make wireless power transmission based on a Youtube video. I made exactly the same coils and same circuit but it didn’t give as much power as what was in the video.
3. Batteries are heavy, so it is not so easy to position it on the rotor. It is best to place the batteries in the middle of the rotation axis so that the rotor does not come out of balance while rotating fast.
I chose the third option, powering the device from 4x 1.2 V 750 mAh AAA Eneloop battery. I planned and 3D printed a battery holder that fits perfectly on the rotor axis so the batteries are in the middle of the rotation point thus everything is in balance.
Rotating the propeller clock
I used a 30 cm diameter desk fan to rotate the device. I removed the propeller and turned the motor 90 degrees upwards and then fastened it to the support. I cut a piece of wood and made a hole for the axis then I screwed the two pcb-s onto the wood plate with some screws.
Part list:
330R resistor array x2 (RN1, RN2)
5 mm diffused red LED x16 (LED1-16)
2x10 IDC ribbon cable socket 2.54 mm x2
2x10 female IDC connector 2.54 mm x2
20 position ribbon cable 1.27 mm 15 cm
10k resistor x1 (R5)
CR2032 battery holder x1
Eneloop 1.2 V AAA battery x4
DIP-28 IC socket x1
ATmega328P-PU x1 (IC1)
8 Mhz crystal oscillator x1
22 pF ceramic capacitor x2
100 nF ceramic capacitor x1
100 nF 1206 smd capaitor x2
push button 6x6 mm tact switch x3
2 way DIP switch 2 position 4 pin 2.54 mm x1
SS411P Hall effect sensor x1
small magnet x1
6x1 female pin socket straight 2.54 mm x1
2 pin JST XH 2.54 mm connector with wire x1
2 pin JST XH 2.54 mm socket x1
3 pin JST XH 2.54 mm connector with wire x1
3 pin JST XH 2.54 mm socket x1
Single sided PCB 135x40 mm x1
Single sided PCB 128x56 mm x1
Jumper wires
M3 screws
M3 nuts
M3 washers
plywood
30 cm diameter desk fan
3D printed battery holder
Schematic diagram
Schematic Diagram of the microcontroller circuit
Schematic Diagram of the LEDs circuit
PCB
Microcontroller PCB
Comments
Post a Comment