Axe033 date/time problem ?

curry87

Senior Member
Hi ive set up an Axe033 with an 18m2 as per instructions.I have two problems though.Ok i upload and run the first code once to set the time and date and then upload and run the second code which constantly update the display.It displays the correct date/time for a while and then decides to reset back 00/00/00 00:00 etc completely randomly.The button cell battery is good as per multimeter and appears to be no loose connections.The strange thing is even when the displays says 00/00/00 00:00 the pulse output is still pulsing once every second.

When the lcd display decides to work and display the date/time there is some stange characters that appear an 'F' will appear and disappear at random at times so for example like this 12/07//12 0F:00.

Any ideas ?

First code
Code:
symbol out = b.0;to serial in pin on lcd 
pause 500

main:
serout out,N2400,(253,0,"09/07/12 15:21 ")
pause 1000
serout out,N2400,(0)


end


Second code
Code:
symbol out = b.0;to serial in pin on lcd 
pause 500

main:

serout out,N2400,(0)
pause 500

goto main
 

nick12ab

Senior Member
Have you put the button battery in the right way round? Also make sure that you have decoupling and bulk capacitors fitted.
 

curry87

Senior Member
Have you put the button battery in the right way round? Also make sure that you have decoupling and bulk capacitors fitted.
yup the button cell is the right round.Ive got a 1000uf and 100nf cap accross the 5v dc power rails.What do you mean by bulk capacitors ?
 

Bill.b

Senior Member
I had a similar problem with a AXE033 module. I found that the I2C Bus has a problemassosiated with the 8 pin socket for the RTC chip ( the OLED fidplsy worked OK). I replaced the socket which improved
the problem but did not rectifer it completely. In the end I relaced the module with a new one and all worked OK.


Bill
 
Last edited:

g6ejd

Senior Member
Have you write- protected the I2C bus to prevent random or other writes, see example code produced for data logger by the development environment.
 

cactusface

Senior Member
Hi Curry87,
Sorry but I don't understand your code at all!! Where do you send data to the DS1307 to set the time?? and even recall it, convert it to #Hex etc. I have done a few projects with this RTC and LCD but not using a Axe033, which might be the root of my lack of understanding. What do's this line do? serout out,N2400,(0)...

Here's some of my code. I wrote this for my own Shield design that uses a 20M2 and the 18M2 LCD driver, which you can find here http://www.picaxeforum.co.uk/showthread.php?21659-My-Shield

Hope it helps, regards.
Mel.

Code:
;
 *******************************
;    Filename: 	ShieldDataLogger
;    Date: 		29/06/2012	
;    File Version: 	
;    Written by: 	MS	
;    Function:	Greenhouse Data logger	
;    Last Revision:
;    Target PICAXE:My20M2Shield	
; ******************************* 


symbol light = b.0
symbol humid = b.1
symbol outtemp = b.2
symbol intemp = b.3
symbol All_clear=%00000000
symbol line1=128	      'Set up LCD line codes
symbol line2=192		'Start location for each line
symbol line3=148
symbol line4=212
symbol RTC=%11010000	'DS1307 Address
symbol MEM=%10100000	'EEprom Address
symbol MEM2=$8001		'2nd EEprom Address
symbol mintemp=MEM
symbol maxtemp=MEM+2
symbol sun=b0
symbol line_length = 16	; change to 20 for displays with 20 character lines
symbol baud=T2400		; Serial baud rate baud,N,8,1


pause 300			;Give system time to power up and stabilize?

serout c.0,baud,(255,%001)	'switch bcklight on
pause 50

Main:
gosub gettime
gosub convert
	 
serout c.0,baud,(254,line1,b12,b13,"/",b14,b15,"/20",b16,b17," ",b10,b11,":",b8,b9,":",b19,b20," ")'display current date & time

readadc light,sun 
gosub tempIn
gosub tempOut
gosub check
gosub keys

serout c.0,baud, (254,line2,"Inside Temp:",b9,b7,b6,".",b5,b4,"c")'display local (on board) temp.
serout c.0,baud, (254,line3,"Outside Temp:",b9,b7,b6,".",b5,b4,"c")'display local (on board) temp.
serout c.0,baud,(254,line4,"light value = ", #sun)

goto main
;-------------------------------------------
check:				;record MIN & MAX temps in memory.

i2cslave MEM,i2cfast,i2cword 
readi2c mintemp,(w12)
if w10<w12 then goto lowtemp
 
check2:
readi2c maxtemp,(w13)
if w10>w13 then gosub hightemp
return

lowtemp:
writei2c mintemp,(w10)
goto check2
return

hightemp:
writei2c maxtemp,(w13)
return
;--------------------------------------------
gettime:

i2cslave RTC,i2cslow,i2cbyte	'set up i2c DS1307 RTC
readi2c 0,(b0,b1,b2,b3,b4,b5,b6,b7)	'read Time and Date
return

convert:
bcdtoascii b0,b19,b20		'Secs Convert to ASCII
bcdtoascii b1,b8,b9		'Mins 
bcdtoascii b2,b10,b11		'Hours
bcdtoascii b3,b21,b22         'DayOfWeek
bcdtoascii b4,b12,b13		'Date
bcdtoascii b5,b14,b15		'Month
bcdtoascii b6,b16,b17		'Year
return
;--------------------------------------------------

tempIn:
Readtemp12 intemp,w10                                 'read in result from ds18b20 and convert to 0.06 RES                                        
let b9 =160                                       'Display space (32)
if w1 > 64655 then                                'info     - 55 degrees          = 64656
let b9 =45                                        'Display - (45) MINUS
w10 = - w10                                         'info   if - ie w1=1000   display   - 10.00 C
endif                                
w10 = w10 * 50 / 8                                  'info      + ie w1=8500   display     85.00 C
                                          
bintoascii w10,b8,b7,b6,b5,b4 
if b8 = "0" then : b8 = " "  :endif                       ' zero blanking b8
if b8 =  " "  and  b7 =  "0"  then : b7 = " "  :endif     ' zero blanking b7
return                       
;--------------------------------------------------
tempOut:
Readtemp12 outtemp,w10                                 'read in result from ds18b20 and convert to 0.06 RES                                        
let b9 =160                                       'Display space (32)
if w1 > 64655 then                                'info     - 55 degrees          = 64656
let b9 =45                                        'Display - (45) MINUS
w10 = - w10                                         'info   if - ie w1=1000   display   - 10.00 C
endif                                
w10 = w10 * 50 / 8                                  'info      + ie w1=8500   display     85.00 C
                                          
bintoascii w10,b8,b7,b6,b5,b4 
if b8 = "0" then : b8 = " "  :endif                       ' zero blanking b8
if b8 =  " "  and  b7 =  "0"  then : b7 = " "  :endif     ' zero blanking b7
return
;---------------------------------------------------
keys:
readadc c.1,b11
if b11=113 then goto job1
if b11=69  then goto job2
if b11=28  then goto job3
if b11=46 then goto job4
return
;---------------------------------------------------
ClearLcd:
serout c.0,baud,(254,line1,"                    ")
serout c.0,baud,(254,line2,"                    ")
serout c.0,baud,(254,line3,"                    ")
serout c.0,baud,(254,line4,"                    ")
return

;JOBS

job1:
gosub clearlcd
serout c.0,baud,(253,1)
wait 2
return

job2:
gosub clearlcd
serout c.0,baud,(2543,2)
wait 2
return

job3:
gosub clearlcd
serout c.0,baud,(253,3)
wait 2
return



job4:
gosub clearlcd
serout c.0,baud,(253,4)
wait 2
return
 

cactusface

Senior Member
Hi Curry87,
Sorry but I don't understand your code at all!! Where do you send data to the DS1307 to set the time?? and even recall it, convert it to #Hex etc. I have done a few projects with this RTC and LCD but not using a Axe033, which might be my lack of understanding. What do's this line do? serout out,N2400,(0)...

Here's some of my code. I wrote this for my own Shield design that uses a 20M2 and the 18M2 LCD driver, which you can find here http://www.picaxeforum.co.uk/showthread.php?21659-My-Shield

Hope it helps, regards.
Mel.

Code:
;
 *******************************
;    Filename: 	ShieldDataLogger
;    Date: 		29/06/2012	
;    File Version: 	
;    Written by: 	MS	
;    Function:	Greenhouse Data logger	
;    Last Revision:
;    Target PICAXE:My20M2Shield	
; ******************************* 


symbol light = b.0
symbol humid = b.1
symbol outtemp = b.2
symbol intemp = b.3
symbol All_clear=%00000000
symbol line1=128	      'Set up LCD line codes
symbol line2=192		'Start location for each line
symbol line3=148
symbol line4=212
symbol RTC=%11010000	'DS1307 Address
symbol MEM=%10100000	'EEprom Address
symbol MEM2=$8001		'2nd EEprom Address
symbol mintemp=MEM
symbol maxtemp=MEM+2
symbol sun=b0
symbol line_length = 16	; change to 20 for displays with 20 character lines
symbol baud=T2400		; Serial baud rate baud,N,8,1


pause 300			;Give system time to power up and stabilize?

serout c.0,baud,(255,%001)	'switch bcklight on
pause 50

Main:
gosub gettime
gosub convert
	 
serout c.0,baud,(254,line1,b12,b13,"/",b14,b15,"/20",b16,b17," ",b10,b11,":",b8,b9,":",b19,b20," ")'display current date & time

readadc light,sun 
gosub tempIn
gosub tempOut
gosub check
gosub keys

serout c.0,baud, (254,line2,"Inside Temp:",b9,b7,b6,".",b5,b4,"c")'display local  temp.
serout c.0,baud, (254,line3,"Outside Temp:",b9,b7,b6,".",b5,b4,"c")'display remote  temp.
serout c.0,baud,(254,line4,"light value = ", #sun)

goto main
;-------------------------------------------
check:				;record MIN & MAX temps in memory.

i2cslave MEM,i2cfast,i2cword 
readi2c mintemp,(w12)
if w10<w12 then goto lowtemp
 
check2:
readi2c maxtemp,(w13)
if w10>w13 then gosub hightemp
return

lowtemp:
writei2c mintemp,(w10)
goto check2
return

hightemp:
writei2c maxtemp,(w13)
return
;--------------------------------------------
gettime:

i2cslave RTC,i2cslow,i2cbyte	'set up i2c DS1307 RTC
readi2c 0,(b0,b1,b2,b3,b4,b5,b6,b7)	'read Time and Date
return

convert:
bcdtoascii b0,b19,b20		'Secs Convert to ASCII
bcdtoascii b1,b8,b9		'Mins 
bcdtoascii b2,b10,b11		'Hours
bcdtoascii b3,b21,b22         'DayOfWeek
bcdtoascii b4,b12,b13		'Date
bcdtoascii b5,b14,b15		'Month
bcdtoascii b6,b16,b17		'Year
return
;--------------------------------------------------

tempIn:
Readtemp12 intemp,w10                                 'read in result from ds18b20 and convert to 0.06 RES                                        
let b9 =160                                       'Display space (32)
if w1 > 64655 then                                'info     - 55 degrees          = 64656
let b9 =45                                        'Display - (45) MINUS
w10 = - w10                                         'info   if - ie w1=1000   display   - 10.00 C
endif                                
w10 = w10 * 50 / 8                                  'info      + ie w1=8500   display     85.00 C
                                          
bintoascii w10,b8,b7,b6,b5,b4 
if b8 = "0" then : b8 = " "  :endif                       ' zero blanking b8
if b8 =  " "  and  b7 =  "0"  then : b7 = " "  :endif     ' zero blanking b7
return                       
;--------------------------------------------------
tempOut:
Readtemp12 outtemp,w10                                 'read in result from ds18b20 and convert to 0.06 RES                                        
let b9 =160                                       'Display space (32)
if w1 > 64655 then                                'info     - 55 degrees          = 64656
let b9 =45                                        'Display - (45) MINUS
w10 = - w10                                         'info   if - ie w1=1000   display   - 10.00 C
endif                                
w10 = w10 * 50 / 8                                  'info      + ie w1=8500   display     85.00 C
                                          
bintoascii w10,b8,b7,b6,b5,b4 
if b8 = "0" then : b8 = " "  :endif                       ' zero blanking b8
if b8 =  " "  and  b7 =  "0"  then : b7 = " "  :endif     ' zero blanking b7
return
;---------------------------------------------------
keys:
readadc c.1,b11
if b11=113 then goto job1
if b11=69  then goto job2
if b11=28  then goto job3
if b11=46 then goto job4
return
;---------------------------------------------------
ClearLcd:
serout c.0,baud,(254,line1,"                    ")
serout c.0,baud,(254,line2,"                    ")
serout c.0,baud,(254,line3,"                    ")
serout c.0,baud,(254,line4,"                    ")
return

;JOBS

job1:
gosub clearlcd
serout c.0,baud,(253,1)
wait 2
return

job2:
gosub clearlcd
serout c.0,baud,(2543,2)
wait 2
return

job3:
gosub clearlcd
serout c.0,baud,(253,3)
wait 2
return



job4:
gosub clearlcd
serout c.0,baud,(253,4)
wait 2
return
 
Top