iButton
johnny_b
Posts: 28
Remember this?
"Hi,
Does anyone have a code for tranlating hh/min/sec time from a Dallas 1994 iButton?
Just want to have an RTC addition to the project (BS2p40 with serial LCD), and I have
some iButtons on the shelf...
thanx, johnny"
well, so far I can get the time data, in a form of incrementing sec counter,·but....
OWOUT OWpin, %0001, [noparse][[/noparse]SkipROM, ReadMemory,2,2]
OWIN OWpin, %0010, [noparse][[/noparse]SPSTR 5]
GET 1,temp.LOWBYTE
GET 2,temp.HIGHBYTE
SEROUT LCD_serOUT, LCD_baud, [noparse][[/noparse]27,4,DEC2 (temp/3600),58,DEC2 (temp/60)//60,46,DEC2 temp//60]
(first byte:1/256th seconds, next four bytes are the sec counter)
so something like this, but the 16 bits are not enough to count 24 hours in seconds, so I would need the
next 8 bits also from the stream. (GET 3, ....)
anyone got a nice solution or idea?
Johnny
"Hi,
Does anyone have a code for tranlating hh/min/sec time from a Dallas 1994 iButton?
Just want to have an RTC addition to the project (BS2p40 with serial LCD), and I have
some iButtons on the shelf...
thanx, johnny"
well, so far I can get the time data, in a form of incrementing sec counter,·but....
OWOUT OWpin, %0001, [noparse][[/noparse]SkipROM, ReadMemory,2,2]
OWIN OWpin, %0010, [noparse][[/noparse]SPSTR 5]
GET 1,temp.LOWBYTE
GET 2,temp.HIGHBYTE
SEROUT LCD_serOUT, LCD_baud, [noparse][[/noparse]27,4,DEC2 (temp/3600),58,DEC2 (temp/60)//60,46,DEC2 temp//60]
(first byte:1/256th seconds, next four bytes are the sec counter)
so something like this, but the 16 bits are not enough to count 24 hours in seconds, so I would need the
next 8 bits also from the stream. (GET 3, ....)
anyone got a nice solution or idea?
Johnny
Comments
·· Tech Support recently answered this question in another thread (In fact it was you who asked for the same code before), but I will repost the link here for you.· We have a book available as a free download in PDF format from our website that has code for the BS2p for this device.· You can find it here:
http://www.parallax.com/detail.asp?product_id=70001
Page 172, according to another Tech.· Also see Page 179.· Good luck!
The original thread is here: http://forums.parallax.com/showthread.php?p=535514
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
So I ask it an other way: how to handle a 32-bit counter with the BS2p?
thanx, johnny
·· Jon has provided you with the information you need in addition to what's in the book.· You're going to need some math.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Hope I'll find some·guidelines there...
By the way, I prefer the iButton over the 1302 (which I don't have yet...),
it contains the backup battery already, and only needs 1 communications pin.
And easier to mount on a proto board.
Just have to find a way to translate 32-bit counter into 24h clock (Date is
not necessary...)
greetings, johnny
·
· hours = counter / 3600
· mins = counter / 60
· secs = counter // 60
When the counter rolls past the 12-hour mark of 43,200 you can "fix" the clock by doing this:
· counter = counter // 43200
· ampm = ~ampm
... then write the counter back to the DS1994
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
They have a RTC with YYMMDDHHMMSS format...
(Well, actually, it's in BCD format, so is REAL easy to transfer to an LCD, but a bit more work if you want to do any calculations)
Accuracy is given as +/-2minutes/month.
The 512Bytes general purpose memory is just a bonus...
I also have one on the shelf...
Thanx for the idea!
Jon,
This is the way I approached, except after the sec and min divisions
I shifted the 16 bit number by 1 bit to the right, and shifted in the
first bit from the next byte, to have 24 hr counter.
Before doing this, I had to add an offset, to the counter, to have the
correct time. But this did not work...
Your point is good though, to WRITE BACK!!!! This should solve it.
Start from 0, no offsets, just basic divisions.
When I'm done with both this, I'll post it ;-)
br, johnny
·
Hope I can do it ;-)
Self-trained iButton guru-ness, here I come!
johnny