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 1 of 4 | |||||
Author | Message | ||||
jwettroth Regular Member Joined: 02/08/2011 Location: United StatesPosts: 71 |
I noted on the SM1 schematics and board that there is a place for an RTC. I studied the schematics a bit and thought that it would be a matter of populating the parts and writing a little I2C hack in basic. Unfortunately unlike the SPI mode, the I2C commands only address pins 12 and 13 directly. It also looks like the designer of the board thought he was connecting to an alternate SDA and SCL but made an error and used one line but not the other. I considered hacking something in assembly and recompiling, etc., etc. but came up with something simpler. I put the RTC chip down on the board and then connected it to the regular I2C port that is supported by basic. Due to some fortuitous routing and placement of via's, this is a pretty clean mod. I ordered a PCF8563 and populated the other parts as in the schematic. I kluged up a coin cell holder from some brass stock I had laying around as can be seen. (it works...). <see photo- RTC Long Shot> I then cut the track from the SDA and SCL lines on the back of the board. <see RTC Track CUTS>. There are via's at both ends of these tracks so if I want to restore thing later, I can run a jump from the respect via's. Finally I connected the SDA and SCL line to the standard I2C. This could be done at pin 12 and 13 on the connector- but there are two via's close by as shown in the top side picture. <see RTC WIRES DRAWN and RTC WIRES> I then can use the code that was contributed on the forum for the internal I2C board that was bought on EBay and used the PCF8563. It works well. Also note that since I2C is multidrop, having one thing hanging on it doesn't really hurt anything as long as there is no address conflict. Thanks to the group for all you sharing and I hope this will be enjoyed. John Wettroth |
||||
jebz Regular Member Joined: 13/06/2011 Location: AustraliaPosts: 79 |
Very well done! |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
does geoff`s firm 2.7a work with this rtc mod as i have 2 complete kitsets for the sm1 boards...regards sparkey.../// technicians do it with least resistance |
||||
jwettroth Regular Member Joined: 02/08/2011 Location: United StatesPosts: 71 |
@Sparkey- I see no reason why not assuming that your boards are the same as production SM1's as far as the schematic goes. I think these were slightly different mechanically. When you've finished with my mod, you'll simply have an 8563 RTC connected to the standard Maximite I2C port. I'm using it with 2.7a. The software required is just a basic program in MMBASIC and I believe was working with V2.6 or earlier. To be more explicit about the basic code to use. The following code was written by jman. There is a 5 page thread that started on 17 October called "Internal RTC". The first mod is for a Dallas/Maxim DS1307 RTC that is not compatible but similar. The thread continues and covers a small board which uses the 8563 that people bought on Ebay and installed internally. jman revised his code to use the 8563 and posted his code. I've included it below to keep it simple. 8563 Clock code by jman- works with this mod. 2011-10-30_230759_2011-07-28_171338_PCF8563.zip Its quite well done. I hope this clears things up. John Wettroth |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
my question is simple that buy doing your mod an adding the components will the rtc after setting the time ..that the rtc will work with on its own then...regards sparkey.../// technicians do it with least resistance |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
http://www.thebackshed.com/forum/forum_posts.asp?TID=3790&PN =2 This is the link to the RTC topic. Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
thanks matthew...///.../// well the origanal pins from the chip get taken out to the "U11" sckt on the ev board and from what you are suggesting that the origanal cct is wrong there for i think it may be a simple matter of removing of the two resistors on the ev board and running the two wires from the smi board where u have suggested to the ev board where your wiring goes and just adding the 5v line and joining the earths together ...i think thats it technicians do it with least resistance |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
i dont get it once the "rtc": has been installed ...dont you just enter the date and time from the command li8ne....or does your program acess the "rtc"chip i dont want to have to include these programs into my other programs just to get the time or is this for display purposes...um a little confused...///.../// technicians do it with least resistance |
||||
Greg Fordyce Senior Member Joined: 16/09/2011 Location: United KingdomPosts: 153 |
Hi Sparkey, I haven't tried this yet, but in the Zip file a few posts up, use program wr8563.txt to set the time and date in the rtc chip. You should only have to do this once. Then whenever you power up the MM, run the read8563.txt to set the time and date in the MM. You should only need to do this when first powering up the MM. If you rename read8563.txt to autorun.bas and save it to the root directory of drive a: or b: then this will be done for you automatically on power up. hth, Greg |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
i am getting a error in line 446 says invalad date ...any help and iam also not shure whic wire joins on pin 3 and four time clock is not keeping time and i dont know the correct value for c-15 i think its 100n but not shure sm1 cct does not say its value and i am also running the rtc on the sm1 board i have isolated the cct as fas i know but also getting "nack" error dont know what this means.../// i am running a ev board if you check my "spot u can see what i have done.../// technicians do it with least resistance |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
Just a quick question to all the guys running a RTC. With the RTC connected to the I/O pins of the Maximite, and assuming I run the read8563.bas code in the AUTORUN.BAS, can the I/O pins that are used on the RTC be assigned to whatever in my code to run as digital in's or out's? Or once I have elected to use the RTC I have to give up these two I/O pins? Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
i think u would because they are being used it makes sense that you would have to give them up to the rtc but dont quote me on this .../// technicians do it with least resistance |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
OK. I'm getting an error. Error line 445: Invalid time Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
OK. I'm now able to set the time and date to the RTC! BUT, when I run the read.bas in my autorun to set the time and date, I get the following error. Error line 446:Invalid date Hmmmm, what's going on? Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
OK! I finished reading the thread and found the problem! The RTC is working A OK! Maybe next time I will read ALL of the info and not just skim over everything. Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
jman Guru Joined: 12/06/2011 Location: New ZealandPosts: 711 |
The RTC use's I2C So once you have the correct time and date and if you no longer need I2C issue a I2CSDIS command and this will allow you to use the pins for normal I/O but dont forget they are pulled high by the 2 resistors Jman |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
A lot of great work has been going on with this clock so here's a challenge for the interested... Is it possible to get the time from a GPS (I've done this with my GPS clock a few posts back - See my post on 26 Sept "GPS Clock") and get it to set the clock? My idea is you read the NMEA string from the GPS through a comm port and parse the time and date. This I’ve done. Then you can manipulate the data to fit a particular format. Then the challenge is to feed it into the clock. You only need to do this once – or occasionally to reset the clock. And… Is it possible to get the clock to increment on an external pulse like a PPS from the GPS? And one more… Is it possible to read the clock so that it can be displayed on the LCD? Regards Talbit Talbit |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
i am still getting the error 446 line in valid date ..but when i run the write prog it comes up ok ..have tried setting the time manuly and dat but still comes up with the same error ...thanks.../// technicians do it with least resistance |
||||
sparkey Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 819 |
i finally cracked it ...///.../// technicians do it with least resistance |
||||
VK6MRG Guru Joined: 08/06/2011 Location: AustraliaPosts: 347 |
OK. Here is the working code for the RTC in an Altronics Maximite using an eBay RTC (8563) that has been mounted directly onto the ICSP header with the two tracks to the PIC32 cut and two wire links to I/O pins 12 and 13 (SDA & SCL). The time and date needs to be set first using DATE$="DD/MM/YYYY" and TIME$="HH:MM:SS" Use the PRINT DATE$ and PRINT TIME$ commands to confirm the time and date. Next run the WR8563.TXT file. I renamed the file to SETTIME.BAS and I have it below. 600 ' 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= &h1 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, mont h, 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 This includes the changes mentioned in another topic! Once this has been done, turn off and on the Maximite. Check the time and date as before. (PRINT DATE$ and PRINT TIME$ commands to confirm the time and date). If it shows the correct time and date, you're good to go. If you want to have the correct time and date set and shown on startup, you will need to add some extras to your AUTORUN.BAS file. Here is mine as an example. 10 ' Sample AUTORUN.BAS file
20 ' 30 ' set the programmable function keys 40 OPTION F1 "RUN"+CHR$(13) 50 OPTION F2 "SAVE"+CHR$(13) 60 OPTION F3 "LIST"+CHR$(13) 70 OPTION F4 "EDIT " 80 OPTION F5 "RUN "+CHR$(34) 90 OPTION F6 "SAVE "+CHR$(34) 100 OPTION F7 "LIST " 110 OPTION F8 "PRINT " 120 OPTION F9 "IF " 130 OPTION F10 "ENDIF" 140 OPTION F11 "FOR " 150 OPTION F12 "NEXT " 160 ' 170 ' set the prompt to show the current drive 180 OPTION PROMPT MM.DRIVE$ + "\>" 190 RUN "readtime.bas" 200 'END OR NEW, BUT THIS NEEDS TO BE ADDED TO THE READTIME.BAS FILE I have renamed the READ8563.TXT to READTIME.BAS so you can follow what is going on. The working READ8563.TXT code for my Maximite is below. 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) 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$ 500 END 1000 ' Convert to Decimal 1010 Decimal = FIX(BCDTemp / 16) * 10 1020 Decimal = Decimal + (BCDTEMP AND &hF) 1030 RETURN I have the AUTORUN.BAS and READTIME.BAS in my A: drive. And this is what it looks like. Hope this helps. Its easier to ask forgiveness than to seek permission! ............VK6MRG.............VK3MGR............ |
||||
Page 1 of 4 |
Print this page |