POV Clock.

shamu

Member
I work as a Science and Engineering Ambassador running an afterschool club with a small group of children. I saw a POV clock on YouTube and though what a wonderful project for my group of eleven year olds.

After a few iterations I arrived at the current design, the wand or disc is circular for safety, harder to chop a finger off!!

I have attached a PDF with a bill of materials, PCB masks and schematics. The code for the remote and 40X2 are attached, the main program is a bit rushed and will be improved over the coming months, any suggestions will be greatly appreciated.

It has taken many months to get this working and many people from this site helped along the way, for this I am eternally grateful, thanks.

Shamu.

Code:
#picaxe 40X2
#no_data
#no_table

setfreq em16 ' This line sets th clock speed to 16 MHz.
             ' A 16MHz resonator needs to be connected to pins 13 & 14.

let dirsA = %11111111  ' Set port A as all outputs.
let dirsB = %11111111  ' Set port B as all outputs.
'let dirsC = %11111001
let dirsD = %11111111  ' Set port D as all outputs.

'  This is the program for the 40X2 to read a decoded infrared signal on pin
' C.0 and place it in variable infravalue.

 high c.1 ' Pin 16 colour 1 
 high c.5 ' Pin 24 colour 2

SYMBOL spacingdelay = b0

SYMBOL thirddash = b1
SYMBOL fourthdash = b2
SYMBOL fifthdash = b3
SYMBOL sixthdash = b4
SYMBOL seventhdash = b5
SYMBOL eigthdash = b6
SYMBOL ninethdash = b7
SYMBOL tenthdash = b8
SYMBOL eleventhdash = b9
SYMBOL twelvethdash = b10

SYMBOL infravalue = b11 ; define an infra variable

SYMBOL cnt = b12
SYMBOL onerevtime = b13

SYMBOL secsdelay = b14
SYMBOL minsdelay = b15
SYMBOL hoursdelay = b16

' These variable are for the i2c interface with the DS1307.
symbol seconds = b17
symbol mins = b18
symbol hours = b19
symbol day = b20
symbol date = b21
symbol month = b22
symbol year = b23
symbol control = b24

SYMBOL clockmode = b25

' These are the variables used for the infrared. 
SYMBOL buttonone = B26
SYMBOL buttontwo = B27
SYMBOL buttonthree = B28
SYMBOL buttonfour = B29
SYMBOL buttonfive = B30

' These are the values for the infrared.
' Only use one set, comment out the ones not being used. 

' Pupil one.
;buttonone = 1
;buttontwo = 2
;buttonthree = 3
;buttonfour = 4
;buttonfive = 5

'Pupil two.
;buttonone = 6
;buttontwo = 7
;buttonthree = 8 
;buttonfour = 9
;buttonfive = 10

' Pupil three.
;buttonone = 11
;buttontwo = 12
;buttonthree = 13 
;buttonfour = 14
;buttonfive = 15

' Pupil four.
;buttonone = 16
;buttontwo = 17
;buttonthree = 18
;buttonfour = 19
;buttonfive = 20

'Pupil five.
;buttonone = 21
;buttontwo = 22
;buttonthree = 23 
;buttonfour = 24
;buttonfive = 25

' Pupil six.
;buttonone = 26
;buttontwo = 27
;buttonthree = 28
;buttonfour = 29
;buttonfive = 30

' Pupil seven.
;buttonone = 31
;buttontwo = 32
;buttonthree = 33 
;buttonfour = 34
;buttonfive = 35

' Pupil eight.
buttonone = 36
buttontwo = 37
buttonthree = 38
buttonfour = 39
buttonfive = 40

' This line resets the DS1307 to have the time read.   
  HI2CSETUP i2cmaster, %11010000,i2cslow_64,i2cbyte
setfreq em16 ' This line sets th clock speed to 16 MHz.
             ' A 16MHz resonator needs to be connected to pins 13 & 14.

SYMBOL pausevalue = w26

let outpinsA = %11111111
let outpinsB = %11111111
let outpinsD = %11111111

spacingdelay = 0
onerevtime =36
pausevalue = 50
high c.1 ' Blue when high.
low c.5 ' Red when high.

start:
  
spacingdelay = onerevtime / 12

thirddash = spacingdelay *2
fourthdash =  spacingdelay *3
fifthdash =  spacingdelay *4
sixthdash =  spacingdelay *5
seventhdash =  spacingdelay *6
eigthdash =  spacingdelay *7
ninethdash =  spacingdelay *8
tenthdash = spacingdelay *9
eleventhdash = spacingdelay *10
twelvethdash = spacingdelay *11

 ' Read the time from the DS1307

    readi2c $0,(seconds,mins,hours,day,date,month,year,control)
    ' Convert BCD values normal numbers.
    seconds = BcdToBin seconds
    mins = BcdToBin mins
    hours = BcdToBin hours
    
    if hours => 12 then 
      hours = hours - 12
    endif
hoursdelay = hours * 5 

' This loop waits for a signal from the hall effect 
do until pinc.2 = 0
	
loop

gosub clockdisplay

goto start

clockdisplay: ' This is the routine triggered by the Hall effect on C.2
  
  let outpinsA = %01111110
  pauseus 500
  let outpinsA = %00000000
  pauseus 50
  let outpinsA = %01111110
  pauseus 500
  let outpinsA = %11111111
   
 for cnt = 0 to onerevtime
       
      if cnt = spacingdelay then
        let outpinsA = %00000000
        pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = thirddash then
        let outpinsA = %00000000
        pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = fourthdash then
        let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %00000000
        pauseus 50
        let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = fifthdash then
        let outpinsA = %00000000
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = sixthdash then
        let outpinsA = %00000000
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = seventhdash then
        let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %00000000
        pauseus 50
        let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
      if cnt = eigthdash then
        let outpinsA = %00000000
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
     if cnt = ninethdash then
        let outpinsA = %00000000
         pauseus pausevalue
        let outpinsA = %11111111
      endif
      
     if cnt = tenthdash then
         let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %00000000
        pauseus 50
        let outpinsA = %01111110
         pauseus pausevalue
        let outpinsA = %11111111
     endif
      
     if cnt = eleventhdash then
       let outpinsA = %00000000
        pauseus pausevalue
       let outpinsA = %11111111
     endif
      
       if cnt = twelvethdash then
        let outpinsA = %00000000
         pauseus pausevalue
        let outpinsA = %11111111
      endif
   
        ' This block displays the seconds pointer.
      if cnt = seconds then
        low c.1 ' Blue when high.
        high c.5 ' Red when high.
        let outpinsA = %00000000
        let outpinsB = %00000000
        let outpinsD = %00000000

        pauseus pausevalue 
        let outpinsA = %11111111
        let outpinsB = %11111111
        let outpinsD = %11111111
        
        high c.1 ' Blue when high.
        low c.5 ' Red when high. 
      endif
            
      'This block displays the minutes pointer
      'if cnt = 20 then
      if cnt = mins then
        low c.1 ' Blue when high.
        high c.5 ' Red when high.
        let outpinsA =%01111111 
        pauseus 5
        let outpinsA =%10111111
        pauseus 5
        let outpinsA =%11011111
        pauseus 5
        let outpinsA =%11101111
        pauseus 5
        let outpinsA =%11110111
        pauseus 5
        let outpinsA =%11111011
        pauseus 5
        let outpinsA =%11111101
        pauseus 5
        let outpinsA =%11111110
        pauseus 5
        let outpinsA =%00000000
        let outpinsB =%00000000
        let outpinsD =%00000000
        pauseus pausevalue
        let outpinsB =%11111111
        let outpinsD =%11111111

        let outpinsA =%11111110
        pauseus 5
        let outpinsA =%11111101
        pauseus 5
        let outpinsA =%11111011
        pauseus 5
        let outpinsA =%11110111
        pauseus 5
        let outpinsA =%11101111
        pauseus 5
        let outpinsA =%11011111
        pauseus 5
        let outpinsA =%10111111
        pauseus 5
        let outpinsA =%01111111
        pauseus 5
        let outpinsA =%11111111
        
        high c.1 ' Blue when high.
        low c.5 ' Red when high. 
      endif
           
      ' This block displays the hours pointer.
      if cnt = hoursdelay then
        low c.1 ' Blue when high.
        high c.5 ' Red when high.
        let outpinsB = %00000000
        let outpinsD = %00000000

        pauseus pausevalue 
        let outpinsB = %11111111
        let outpinsD = %11111111
        
        high c.1 ' Blue when high.
        low c.5 ' Red when high. 
      endif
    
  next cnt
 
 irin [0,povdisplay], C.0, infravalue ; read input C.0 into infravalue
  
  If infravalue = buttonone then
       pausevalue = pausevalue + 10
  end if

  If infravalue = buttontwo then
    pausevalue = pausevalue - 10
  end if
  
  If infravalue = buttonthree then
    clockmode = 2   
  end if
  
  If infravalue = buttonfour then
    ' This block increments the minutes by 1.
    ' This line sets up the DS1307 for write, so the time can be put in. 
     
    inc mins 
    mins = BinToBcd mins
    writei2c $0,(seconds,mins,hours,day,date,month,year,control)
  
     end if
  
  If infravalue = buttonfive then
   ' This block increments the hours by 1.
   
    inc hours 
  
    writei2c $0,(seconds,mins,hours,day,date,month,year,control)
        
  end if
        
return

povdisplay:
' This sub routine displays the dashes around the outside.
' I think this routine is needed for the irin command, even though it does nothing!

return
 

Attachments

Top