Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:23 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Maximite SM1 RTC Sucess

     Page 2 of 4    
Author Message
pcaffalldavis

Senior Member

Joined: 17/10/2011
Location: United States
Posts: 187
Posted: 07:00pm 01 Nov 2011
Copy link to clipboard 
Print this post

My RTC's arrived yesterday. I got them working just fine last night. I hard wired them into the DonTronics SD1 and glued the RTC on the Maximite board right where the other poster showed. Looks like it was designed to fit there. I had trouble for a couple hours with the write and read basic clock programs until I realized the jumper was not set to BAT. As long as you set the jumper to VCC it will forget everything you wrote, and when you try to read on a new boot you will get the error codes noted by others in line 446.

1) Set the Date$ & Time$

2) Run the basic program that sets the times and date to the RTC

3) Make sure the RTC jumper is on BAT

4) Cycle the Maximite off & back on

5) Run the basic program that reads the RTC.

Since my plans for each Maximite are auto running without a keyboard or monitor I decided to make the read RTC program the autorun.bas default. Then where the basic program that reads the RTC date and time usually ends, instead I have it RUN the default program for which this Maximite is intended. Works Like a CHARM! Thanks eveyone.

Now I'm off to learn how to drive a 3 digit floating decimal LED. Maybe I'll do the 16x2 LED first since we already have instructions for that one.

Cheers!
We're all here 'cause we're not all there.
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 06:55am 02 Nov 2011
Copy link to clipboard 
Print this post

I just fitted the eBay RTC to the Maximite EV.
Works very well and looks good.
Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
jwettroth

Regular Member

Joined: 02/08/2011
Location: United States
Posts: 71
Posted: 07:51am 02 Nov 2011
Copy link to clipboard 
Print this post

I2C on the Maximite isn't as simple as I first thought or completely debugged. I am looking into this in more detail. I think that 2.7a and the hardware will support most purposes but there are still some hidden bugs or at least things that are not understood yet. Stay tuned.
John Wettroth
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 01:13pm 02 Nov 2011
Copy link to clipboard 
Print this post

Hi, I've been trying to add the weekday to the RTC.
Here is what I’ve done to the code to write to the RTC.
10 CLS
16 PRINT "PLEASE TELL ME WHAT TODAY IS?"
18 PRINT "0. SUNDAY"
20 PRINT "1. MONDAY"
22 PRINT "2. TUESDAY"
24 PRINT "3. WEDNESDAY"
26 PRINT "4. THURSDAY"
28 PRINT "5. FRIDAY"
30 PRINT "6. SATURDAY"
32 PRINT "ENTER NUMBER"
34 INPUT A
40 IF A=0 THEN 60
42 IF A=1 THEN 61
44 IF A=2 THEN 62
46 IF A=3 THEN 63
48 IF A=4 THEN 64
50 IF A=5 THEN 65
52 IF A=6 THEN 66
54 PRINT "INVALID SELECTION!"
56 PAUSE 2500
58 GOTO 10
60 wday=&h0
61 wday=&h1
62 wday=&h2
63 wday=&h3
64 wday=&h4
65 wday=&h5
66 wday=&h6


600 cls ' Get time from time$ and date$
610 tempdec = VAL(LEFT$(TIME$, 2))
615 GOSUB 1100
617 hours = hex
620 tempdec = VAL(MID$(TIME$, 4, 2))
625 GOSUB 1100
627 minutes = hex
630 tempdec = VAL(RIGHT$(TIME$, 2))
635 GOSUB 1100
637 seconds = hex
640 tempdec = VAL(LEFT$(DATE$, 2))
645 GOSUB 1100
647 day = hex
650 tempdec = VAL(MID$(DATE$, 4, 2))
655 GOSUB 1100
657 month = hex
660 tempdec = (VAL(RIGHT$(DATE$, 4)) - 2000)
665 GOSUB 1100
667 year = hex
670 ' rtcctrl = &h10
680 rtcwday=wday
690 ' Write Time to RTC
700 i2caddr = &h51 ' PCF8563 I2C address
710 I2CEN 100,100 ' Enable I2C
720 I2CSEND i2caddr, 0, 1 , &h0
725 I2CSEND i2caddr, 0, 10, 0, 0, 0, seconds, minutes, hours, day, rtcwday, month, year
730 I2CDIS
770 ? "0=ok 1=nack 2=timeout"; MM.I2C
780 END
1100 ' Convert to Hex
1110 hex = FIX(tempdec / 10) * 16
1120 hex = hex OR ((tempdec / 10) - (FIX(tempdec / 10))) * 10
1140 RETURN

I run the code and it seems to work.

So I've tried to alter the wr8563.bas to read the weekday, but...
I'm just not getting it
100 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year
200 DIM RTCbuff(255)
220 i2caddr = &h51 ' PCF8563 I2C address
250 I2CEN 100,100 ' Enable I2C
260 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2
265 I2CDIS
270 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits
280 GOSUB 1000
290 sec$ = STR$(decimal)
295 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits
300 GOSUB 1000
305 min$ = STR$(decimal)
310 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits
315 GOSUB 1000
320 hours$ = STR$(decimal)
325 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits
330 GOSUB 1000
340 day$ = STR$(decimal)
342 BCDTEMP = RTCBuff(4) AND &H3F
344 GOSUB 1000
346 wday$ = STR$(decimal)
348 GOSUB 1200
350 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits
360 GOSUB 1000
370 month$ = STR$(decimal)
380 bcdtemp = rtcbuff(6)
390 GOSUB 1000
400 year$ = STR$(decimal + 2000 )
440 t$ = hours$+":"+min$+":"+sec$
442 D$ = day$+"/"+month$+"/"+year$
445 TIME$ = T$
446 DATE$ = D$
450 ? "Time has been set to ";TIME$
460 ?"Date has been set to ";DATE$
470 ?"Today is ";weekday$
500 END
1000 ' Convert to Decimal
1010 Decimal = FIX(BCDTemp / 16) * 10
1020 Decimal = Decimal + (BCDTEMP AND &hF)
1030 RETURN
1200 IF wday$ = 0 THEN LET weekday$="SUNDAY"
1202 IF wday$ = 1 THEN LET weekday$="MONDAY"
1204 IF wday$ = 2 THEN LET weekday$="TUESDAY"
1206 IF wday$ = 3 THEN LET weekday$="WEDNESDAY"
1208 IF wday$ = 4 THEN LET weekday$="THURSDAY"
1210 IF wday$ = 5 THEN LET weekday$="FRIDAY"
1212 IF wday$ = 6 THEN LET weekday$="SATURDAY"
1214 RETURN

I get an error "error line 1200: incompatible types in expression
Something for me to think about. Back to the MMbasic Manual....

Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 02:20pm 02 Nov 2011
Copy link to clipboard 
Print this post

Hi,

I saw your post so gave it a quick bash and fixed your code so it works, there were just a couple of little mistakes that stopped it working, like it always being Saturday when you run your program ;P, ;) a nice idea but impractical :) read through the code and you will kick yourself, the incompatibility error you got was simply fixed by putting quotes around the wday return values, you were using a string.

I am pretty sure there is a cleaner way of doing all this but I simply adjusted your code so it works now.

by the way, is anyone else having trouble with the accuracy of these clocks, I have noticed that both the maximite and the rtc clocks gain seconds at about 10 or so a day.. is there anyway to compensate in the rtc to fix this ??

here's the fixed code :

setting the day/time etc...

10 CLS
16 PRINT "PLEASE TELL ME WHAT TODAY IS?"
18 PRINT "0. SUNDAY"
20 PRINT "1. MONDAY"
22 PRINT "2. TUESDAY"
24 PRINT "3. WEDNESDAY"
26 PRINT "4. THURSDAY"
28 PRINT "5. FRIDAY"
30 PRINT "6. SATURDAY"
32 PRINT "ENTER NUMBER"
34 INPUT A
40 IF A=0 THEN 60
42 IF A=1 THEN 62
44 IF A=2 THEN 64
46 IF A=3 THEN 66
48 IF A=4 THEN 68
50 IF A=5 THEN 70
52 IF A=6 THEN 72
54 PRINT "INVALID SELECTION!"
56 PAUSE 2500
58 GOTO 10
60 wday=&h0
61 GOTO 600
62 wday=&h1
63 GOTO 600
64 wday=&h2
65 GOTO 600
66 wday=&h3
67 GOTO 600
68 wday=&h4
69 GOTO 600
70 wday=&h5
71 GOTO 600
72 wday=&h6
600 CLS ' Get time from time$ and date$
610 tempdec = VAL(LEFT$(TIME$, 2))
615 GOSUB 1100
617 hours = hex
620 tempdec = VAL(MID$(TIME$, 4, 2))
625 GOSUB 1100
627 minutes = hex
630 tempdec = VAL(RIGHT$(TIME$, 2))
635 GOSUB 1100
637 seconds = hex
640 tempdec = VAL(LEFT$(DATE$, 2))
645 GOSUB 1100
647 day = hex
650 tempdec = VAL(MID$(DATE$, 4, 2))
655 GOSUB 1100
657 month = hex
660 tempdec = (VAL(RIGHT$(DATE$, 4)) - 2000)
665 GOSUB 1100
667 year = hex
670 ' rtcctrl = &h10
680 rtcwday=wday
690 ' Write Time to RTC
700 i2caddr = &h51 ' PCF8563 I2C address
710 I2CEN 100,100 ' Enable I2C
720 I2CSEND i2caddr, 0, 1 , &h0
725 I2CSEND i2caddr, 0, 10, 0, 0, 0, seconds, minutes, hours, day, rtcwday, monr
730 I2CDIS
770 ? "0=ok 1=nack 2=timeout"; MM.I2C
780 END
1100 ' Convert to Hex
1110 hex = FIX(tempdec / 10) * 16
1120 hex = hex OR ((tempdec / 10) - (FIX(tempdec / 10))) * 10
1140 RETURN

and reading the same....

100 ' I2C RTC based On PCF8563 Secs,Mins,Hours,Day,Date,Month,Year
200 DIM RTCbuff(255)
220 i2caddr = &h51 ' PCF8563 I2C address
250 I2CEN 100,100 ' Enable I2C
260 I2CRCV i2caddr, 0, 7, RTCbuff(0), 1, 2
265 I2CDIS
270 BCDTEMP = RTCBuff(0) AND &H7F ' Mask unwanted bits
280 GOSUB 1000
290 sec$ = STR$(decimal)
295 BCDTEMP = RTCBuff(1) AND &H7F ' Mask unwanted bits
300 GOSUB 1000
305 min$ = STR$(decimal)
310 BCDTEMP = RTCBuff(2) AND &H3f ' Mask unwanted bits
315 GOSUB 1000
320 hours$ = STR$(decimal)
325 BCDTEMP = RTCBuff(3) AND &H3f ' Mask unwanted bits
330 GOSUB 1000
340 day$ = STR$(decimal)
342 BCDTEMP = RTCBuff(4) AND &H3F
344 GOSUB 1000
346 wday$ = STR$(decimal)
348 GOSUB 1200
350 BCDTEMP = RTCBuff(5) AND &h1F ' Mask unwanted bits
360 GOSUB 1000
370 month$ = STR$(decimal)
380 bcdtemp = rtcbuff(6)
390 GOSUB 1000
400 year$ = STR$(decimal + 2000 )
440 t$ = hours$+":"+min$+":"+sec$
442 D$ = day$+"/"+month$+"/"+year$
445 TIME$ = T$
446 DATE$ = D$
450 ? "Time has been set to ";TIME$
460 ?"Date has been set to ";DATE$
470 ?"Today is ";weekday$
500 END
1000 ' Convert to Decimal
1010 Decimal = FIX(BCDTemp / 16) * 10
1020 Decimal = Decimal + (BCDTEMP AND &hF)
1030 RETURN
1200 IF wday$ = "0" THEN weekday$="SUNDAY"""
1202 IF wday$ = "1" THEN weekday$="MONDAY"
1204 IF wday$ = "2" THEN weekday$="TUESDAY"
1206 IF wday$ = "3" THEN weekday$="WEDNESDAY"""
1208 IF wday$ = "4" THEN weekday$="THURSDAY"
1210 IF wday$ = "5" THEN weekday$="FRIDAY"
1212 IF wday$ = "6" THEN weekday$="SATURDAY"
1214 RETURN

rgds,

Andrew
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 07:48pm 02 Nov 2011
Copy link to clipboard 
Print this post

thanks for that andrew i will give it a try out later ....regards sparkey....i have not been kepping a clse eye on the seconds but will keep it in mind i only got mine running yesterday so its a little early to tell...///...///Edited by sparkey 2011-11-04
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 08:25pm 02 Nov 2011
Copy link to clipboard 
Print this post

there is an error in line 725 should it be .. 0.0.0.0
you have 0.10.0.0
technicians do it with least resistance
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 09:05pm 02 Nov 2011
Copy link to clipboard 
Print this post

Yes, I'm kicking myself. Thank you for fix this up for me. It was late and I was i a rush to get off as I have an early start.

I have also found the RTC running slightly fast. Not sure what’s going on, maybe the quality of the components used in the RTC PCB itself. At $9 delivered I'm not surprised by it's lack of accuracy.

Thanks again for sorting out the code. I’m still learning Basic, but that was a beginners mistake. I possibly would have picked it up tonight when I was planning on getting it finished.

Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 09:52pm 02 Nov 2011
Copy link to clipboard 
Print this post

  sparkey said   there is an error in line 725 should it be .. 0.0.0.0
you have 0.10.0.0


This is deliberate, if you read through the other RTC thread you will see this is the reset command ,It returns the registers to the default state. I and others were having trouble getting it to work here with the standard command changing this line fixed it. I think it has to do with if you made a mistake when first initializing the RTC the registers become invalid and this returns them to normal.

It should work just the same anyway does it not work for you ?

Andrew
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 11:35pm 02 Nov 2011
Copy link to clipboard 
Print this post

no as i reported i get an error for this line.725 i think i have not tried it since i referd back to the old code but when i get a chance i will run it again ...///..regards sparkey
technicians do it with least resistance
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 01:40am 03 Nov 2011
Copy link to clipboard 
Print this post

using the older code not the code on this page my time seem`s fine but the date is not turning over i had error messages from the new code ...i dunno..regards sparkey...///...///
technicians do it with least resistance
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 01:44am 03 Nov 2011
Copy link to clipboard 
Print this post

Which position is he jumper on the rtc card in ?


Andrew
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 01:51am 03 Nov 2011
Copy link to clipboard 
Print this post

i am using a SM1 board from don its also running my ev although all the "rtc"cctry is on the sm1 board i have wired it and isolated it from the sm1 board and ran wires to the ev board i am not using any card bought from the net and an 8563 chip if i got that pt code correct....///
technicians do it with least resistance
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 01:56am 03 Nov 2011
Copy link to clipboard 
Print this post

Ahhh yes, sorry, I forgot.

Do you get the 0 Ack return when you communicate with the chip ?

Andrew
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 01:56am 03 Nov 2011
Copy link to clipboard 
Print this post

also i am waiting on the parts to come in so i can populate my brand new sm1 board i have the chip and the battery at present when i get the discretee components it will be all running on the straight out SM1 board i only set the "ev" board up on one of my blown up sm1 boards to se if i could actully do it and yes i did but using the earlier code the date wont turn over ....???...sparkey im not to fussed because when i get the parts i will be running it on a working SM1 boards...///...///
technicians do it with least resistance
 
VK6MRG

Guru

Joined: 08/06/2011
Location: Australia
Posts: 347
Posted: 08:01am 04 Nov 2011
Copy link to clipboard 
Print this post

Andrew, Do you get the day displayed when you run the code?
I just get "Today is" and nothing else.
Any clues?
Its easier to ask forgiveness than to seek permission!

............VK6MRG.............VK3MGR............
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 08:13am 04 Nov 2011
Copy link to clipboard 
Print this post

i am still in the process of patching together the code but i did run it as it was and it did report that it was monday ...and yes i get a return of zero so the cct is functioning ..will update my "spot as soon as i get it all happening ...///...///
technicians do it with least resistance
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 02:22pm 04 Nov 2011
Copy link to clipboard 
Print this post

  VK6MRG said   Andrew, Do you get the day displayed when you run the code?
I just get "Today is" and nothing else.
Any clues?


Yes, after the changes I made it was all working fine, Unfortunately I dont really see the point, as in order to use it you will have to "pass" the day of the week variable to any program that needs it, you might as well just write a few lines of code that keeps the day of the week in the aplication that you are running, by setting it once and then using either the turnover of hours to 00 to reset it or perhaps a tick based interupt.

Anyway I will take another look and just make sure that I didnt miss another bug, you saw the one about the extrqa line 720 right ?

Andrew
 
Vikingboy
Regular Member

Joined: 23/09/2011
Location: Australia
Posts: 82
Posted: 02:45pm 04 Nov 2011
Copy link to clipboard 
Print this post

OK,

I was sure I gad it working yesterday, dunno what happened, maybe I was using a differernt version of the read file, got lots of versions laying around now.
Anyway, you are right as posted it dosnt display the weekday, add this line and all should work, decimal to binary math etc isnt my strong point so its a bit of a hack but it wworks fine:

347 wday$ = right$(wday$,1)


Hope it does what you need now :)

Andrew
 
sparkey

Senior Member

Joined: 15/06/2011
Location: Australia
Posts: 819
Posted: 02:47pm 04 Nov 2011
Copy link to clipboard 
Print this post

hey mr viking boy i still carnt get this to run in twelve hour mode ..maybe the chips i got came from the states ...lol...i dunno and its late here maybe i did not get the code right ..i will go over later but i think that i did it right ...well...//..//
technicians do it with least resistance
 
     Page 2 of 4    
Print this page
© JAQ Software 2024