isochronic Guru
 Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Posted: 11:00pm 15 Mar 2016 |
Copy link to clipboard |
 Print this post |
|
How robust are the time chips ?
eg a ds3231 or the spi version ds3234, can they be used
for mobile applications like bumping around in a car, or
vibration near windmills or engines and so on ? Do they
still keep accurate time ?
ed - a quick slice of code to get the values -
Console output ( late February - a leap year ) :
29:02:16 23:34:28
29:02:16 23:34:29
29:02:16 23:34:30
29:02:16 23:34:31
29:02:16 23:34:32
29:02:16 23:34:33
29:02:16 23:34:34
…
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C
PROGRAM spbytercsl
C
C Reads spi RTC and displays on console
C
C Input :
C RTC time
C
C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
INTEGER*1 secbyte, oldrec, outbyte, temp
INTEGER*1 sec, min, hour, day, mnth, year
outbyte = 0
secbyte = 0
oldrec = 0
DO WHILE ( 1 )
DO WHILE ( secbyte = oldrec )
SPSTRT
SPXWRD outbyte, temp
SPXWRD outbyte, secbyte
END DO
oldrec = secbyte
CALL gettime ( sec, min, hour, day, mnth, year )
FORMAT (I02,A,I02,A,I2,X)
WRITE (*,0) day, ":", mnth, ":", year
FORMAT (I02,A,I02,A,I02,/)
WRITE (*,0) hour, ":", min, ":", sec
END DO
END
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SUBROUTINE gettime ( sec, min, hour, day, mnth, year )
C
C Read rtc time registers via spi
C
INTEGER*1 recbyte, outbyte, temp
outbyte = 0
SPSTRT
SPXWRD outbyte, temp
SPXWRD outbyte, recbyte
sec = cdbcd(recbyte)
SPXWRD outbyte, recbyte
min = cdbcd(recbyte)
SPXWRD outbyte, recbyte
hour = cdbcd(recbyte)
SPXWRD outbyte, temp
SPXWRD outbyte, recbyte
day = cdbcd(recbyte)
SPXWRD outbyte, recbyte
mnth = cdbcd(recbyte)
SPXWRD outbyte, recbyte
year = cdbcd(recbyte)
RETURN
END
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
INTEGER*1 FUNCTION cdbcd ( dbcd )
C
C Convert twin bcd to binary
C
cdbcd = 10 * ( dbcd >> 4 ) + ( dbcd & 15 )
RETURN
END
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
Edited by chronic 2016-03-17 |