Tuesday, April 5, 2011

POV Clock

POV CLOCK
This is my second post here and as i said in my previous post this is about a POV(Persistence Of Vision) clock.
First let us understand what is persistence of  vision.Well we've all seen the effects of persistence of vision in action when we watch a movie,a cartoon or a flip book.
Persistence of vision is the property of the human eye whereby an image leaves an impression on the retina for about 1/23 second.This property is used in movie theaters,displays etc. to give the perception of motion to the viewer.This can also be used to create a persistence of vision display with the help of mechanically scanned LED's.
Flip books use this principle. If the book is flipped at a fast enough speed, the illusion of smooth motion is created.

Ok, enough talk let's get down to business.
Now to build one of these babies you don't need much but the list of things  is given below:-
  • 12V DC motor (with RPM higher than 1500) x 1
  • 12-0-12 transformer x 1
  • 1N4007 diodes (used for rectification) x 2
  • PIC 18F4520 (I used this but you can use any of the other microcontrollers from pic 18f/16f series or atmel microcontrollers) x 1
  • Crystal Oscillators (4 Mhz and 32.768 Khz) x 1 each
  • Capacitors (22pF and 27pF) x 2 each
  • LM7805 (Voltage regulator) x 1
  • A 9V battery
    Most of the parts can be obtained easily, if not, their replacements can be easily found.

    The basic requirement is to perform LED blinking.That said it's not that easy to get everything right to create the effect of a number being displayed.
    The basic idea is to create numbers as shown in the picture.

This has to be done in such a manner that the number appears as a solid image.
Now our first aim is to get the numbers displayed and we'll worry about them being the time later.
As you saw in the requirement list that a motor with RPM higher than 1500 is required,let us see why so?
According to persistence of vision the time for which an image lasts is about 1/24 of a second.That can be achieved if the LED's pass a point 24 times in a second i.e 24 revolutions per second.
That comes out to be 24x60=1440 revolutions per minute hence the motor having RPM higher than 1500 is needed.
Assuming we are using 5mm LED's let us calculate the delay needed between two consecutive columns being displayed
The linear velocity of the arm will be 
V=ωr
where v=linear velocity of the arm
ω=angular velocity(lets say we choose a motor with 1800 RPM ,then 1800 will be the angular velocity)
r=length of the arm(9 cm for my )

V=30x9x10^(-2)
V=2.7 m/s

Time taken to cover 5mm distance is=5x10^(-3) /2.7
=0.001851 seconds
=1.851 milli seconds

So every consecutive column should have a delay of about 1.8 seconds between them.
I used a pic 18f4520 for this project so i used a timer(Timer 0 to be specific) to get the desired delay.
One digit=5 columns
One colon(:)=3 columns
Total digits =6
Total colons(:)=2
Distance covered by LED's while displaying 6 digits and 2
Colons(:)= (5*6) + (2*3) =36 columns
One column=5mm
Thirty six columns=36*5=180mm
Total distance travelled by LED's while displaying the time in Format (hh:mm:ss) =180+20
=200mm
5mm i.e. One column is left as space between two consecutive numbers, four such gaps constitute the extra 20mm.
The time must be displayed only once in a revolution, if there is no delay between two consecutive transmition results in difficulty in differentiating between two consecutive images.
One way of doing this is using a IR or LDR sensor and source on the board and providing an obstruction between them at a particular point,this would cause a signal to be sent to the microcontroller and the transmission starts.
Another way to do this is to switch off the LED's after one complete image for a predefined delay. This delay is calculated using the concept that the total angle at the centre of the circle is 360 degrees.
The angle subtended by the time image is calculated and subtracted from 360 to get the rest of the angle.
The total angle subtended at the centre by the 200mm image is =2.22 radians or 127 degrees.Hence the remaining angle is 4.06 radians or 233 degrees
The time for which the LED’s must be off is 135.3 milliseconds
Timer0 is used for the delays as timer1 is already being used as an RTC.Since the crystal used is 4Mhz the machine cycle is 1Mhz hence a pulse is generated every 1μsec.
The delay of 1.85 msec requires 1850 instructions pulses and since the timer used is 8 bit and the maximum value before it overflows is 255 prescaling is required.

1:8 prescaling ratio is used with the register initialized with an initial value of 24 to achieve a 1.85 msec delay.
The second delay is also achieved from timer0 in a similar manner.

Once the numbers are displayed,the time is fairly easy to show.
The 32.768 Khz crystal at TIMER1 creates a 1second delay if the high register for timer 1 is given the value 0x80.
After getting 1 second,a minute and hour can be easily detected.The 'C' code explains this much better.

The code for the microcontroller is available here.Everything else can be seen clearly from that.
The chip settings used are:-

  • High Speed Oscillator (4 to 20 MHz)
  • Fail-Safe Clock Monitor disabled
  • Oscillator Switchover mode disabled
  • Power-up Timer Enable disabled
  • Brown-out Reset disabled in hardware and software
  • Brown-out Reset Voltage Minimum setting
  • Watchdog Timer Disabled



Now let's get to my favourite part “Hardware”.


I made the project as a combination of two pcb's.A main board and an LED board,the schematics for both of which are given as follows


LED board


The RD0 and RD7 lines are connected to the PORT D of the microcontroller directly.
Make sure the LED's used have good brightness and if you use a microcontroller other than PIC you should make sure if the controller needs pull up's they are connected.

Main Board


The Lines left unnamed are PORT D lines and are connected to the led's in the LED board.
Q1 is the 4Mhz crystal with 22pf capacitors and Q2 is the 32.768 Khz crystal with 27pf capacitors.

I made the schematics and boards using a CAD program called EAGLE which has a freeware version for both Windows and Linux.

The coding was done in MPLAB using C18 compiler which works in Windows and also fairly well in Linux using Wine.

If you have any questions about anything in this project you can contact me at k_preet_singh@yahoo.com
I hope you like the post and please do comment.

And here's a video of it in action,well the video is not too good but that's all  I have for now.



 

No comments:

Post a Comment