As some of you have read I am making an analog meter clock. I finally got the clock running and the pwmout /pwm duty working and the seconds meter reads as it should but it jumps at points. Any idea why every 10 seconds or so it jumps a little? fir example it ticks as it should up to 9 then jumps to 13 and continues on to 20 or so and jumps again to 23 or so then at 30 jumps alittle agin or 40 it jumps then at 50 or so. I tried differnt meters and the jump is real. The pwm cycle and duty do not reset I checked that. I even made it only count to 50% duty during the period thinking that might be it. I also rem'd all the clock functions except the pwm functions and still the same. I changed osc speeds, etc....always the same. Even tried a cap to smooth the output. Now what I did not do is use an opamp as a buffer. Could I be loading the micro pin? The meter reads 0-20ma so I doubt that and it is 33 ohms coil with a 220 ohm in series to make sure I can't go beyond 20ma.
Ok enough babble ideas?
Ok enough babble ideas?
Code:
#picaxe 28x2
' Converted by X2 Conversion Wizard Version 2.0.5 (2010r4.1)
let dirsB = %11111111
let adcsetup = 0
'ANALOG CLOCK WITH LCD September 23, 2012
'Marc Rubin
'Set Clock
let dirsB = %11111111
let adcsetup = 0
setfreq m4
Pause 250
Symbol seconds = b0
Symbol mins = b1
Symbol hour = b2
Symbol day = b3
Symbol date = b4
Symbol month = b5
Symbol year = b6
Symbol control = b7
#rem
Let day = $01
Let year = $12
Let month = $09
Let date = $30
Let hour = $21
Let mins = $02
Let seconds = $30
Let control = %00010000 ; Enable output at 1Hz
'Write to Clock on I2C Bus
hi2csetup i2cmaster, %11010000, i2cslow_32,i2cbyte
writei2c 0, (seconds, mins, hour, day, date, month, year, control)
#endrem
'Meters pwm setup
PWMout c.1,99,0
PWMout c.2,99,0
PWMout b.5, 99,0
Main:
'Readout Clock on I2C Bus
i2cslave %11010000, i2cslow_8, i2cbyte
readi2c 0, (seconds, mins, hour, day, date, month, year, control)
'BCD to ASCII Conversion
BCDTOASCII hour, b8,b9
BCDTOASCII mins, b10,b11
BCDTOASCII seconds, b12,b13
BCDTOASCII month, b14,b15
BCDTOASCII date, b16,b17
BCDTOASCII year, b18,b19
'Determine day of week
IF DAY=1 THEN LET B20="S":LET B21="U":LET B22="N"
ENDIF
IF DAY=2 THEN LET B20="M":LET B21="O":LET B22="N"
ENDIF
IF DAY=3 THEN LET B20="T":LET B21="U":LET B22="E"
ENDIF
IF DAY=4 THEN LET B20="W":LET B21="E":LET B22="N"
ENDIF
IF DAY=5 THEN LET B20="T":LET B21="H":LET B22="U"
ENDIF
IF DAY=6 THEN LET B20="F":LET B21="R":LET B22="I"
ENDIF
IF DAY=7 THEN LET B20="S":LET B21="A":LET B22="T"
ENDIF
'Send to LCD
i2cslave $C6,i2cslow_8,i2cbyte
pause 10
hi2cout 0,($FE,$80,$20,$20,$20,$20,b8,b9,":",b10,b11,":",b12,b13,255)
pause 10
hi2cout 0,($FE,$C0,b20,b21,b22,":",B14,B15,"/",B16,B17,"/",B18,B19,255)
pause 10
'meters
w20=seconds*3
w21=mins*3
w22=hour*8
pwmduty c.1, w20
pwmduty c.2, w21
pwmduty b.0, w22
goto main