I’ve read with interest the difficulties that users of Stalker V2.0 are having writing stable code for the RX8025 RTC. Users have experienced the RTC “sticking” or producing rubbish dates intermittenly. There are posts from Raider suggesting that the Wire library is at the cause and I’ve had all sorts of problems trying to get to the bottom of this problem.
I have loaded the Stlker_Logger_AM06_Serial firmware to four Stalker V2.0 cards using Arduino V023 and it all went well until all cards finally failed with rubbish date values or the program hanging somewhere leaving the LED on. An example is attached below. I’ve tried using Arduino 1.0 but the code does not compile as various features have changed since V0023 such as the .send and .receive functions. I did change these to their new functions in V1.0 (.write and .read), but the RTC still failed. Next I have tried to impliment the I2C library as suggested by Raider, but I have not got that running either, and I suspect I have not coded the RX8025.cpp code correctly (see attached).
I’m determined to sort this out as I have a big pile of Stalker v2.1 modules that will otherwise have to go in the bin. Can anyone please save my grief by sharing some code that actually makes the Rx8025 on the Stalker v2 work?
RX8025.cpp code modified for the I2C library (but not working)
#include <I2C.h>
#include “RX8025.h”
//********************************************************************
//===============================================
#define RX8025_address 0x32
unsigned char RX8025_Control[2]=
{
0x20,0x00
};
//============================================
uint8_t bcd2bin (uint8_t val)
{
return val - 6 * (val >> 4);
}
uint8_t bin2bcd (uint8_t val)
{
return val + 6 * (val / 10);
}
//===============================================
void getRtcTime(void)
{
unsigned char i=0;
I2c.read(RX8025_address,0x00,7);
RX8025_time[0]= I2c.receive();
RX8025_time[1]= I2c.receive();
RX8025_time[2]= I2c.receive();
RX8025_time[3]= I2c.receive();
RX8025_time[4]= I2c.receive();
RX8025_time[5]= I2c.receive();
RX8025_time[6]= I2c.receive();
year = bcd2bin(RX8025_time[6]&0xff);
month = bcd2bin(RX8025_time[5]&0x1f);
date = bcd2bin(RX8025_time[4]&0x3f);
week = bcd2bin(RX8025_time[3]&0x07);
hour = bcd2bin(RX8025_time[2]&0x3f);
minute = bcd2bin(RX8025_time[1]&0x7f);
second = bcd2bin(RX8025_time[0]&0x7f);
}
//===============================================
void RX8025_init(void)
{
I2c.begin();
I2c.write(RX8025_address,0x0e,0x20);
I2c.write(RX8025_address,0x00);
//setRtcTime();
}
Sample from DATA.log showing intermittent rubbish dates. This used the Wire library.
10/11/11/Thursday 9:21:31
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:33
tep102_temperature = 32.63
CH_charging battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:35
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:37
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
165/25/4545:85:38
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:41
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:43
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:45
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:21:47
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:21:49
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:51
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:21:53
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:21:55
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:21:58
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:22:0
tep102_temperature = 32.63
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:22:2
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:4
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:6
tep102_temperature = 32.63
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:8
tep102_temperature = 32.56
CH_complete battery voltage = 4.17
--------------next–data---------------
10/11/11/Thursday 9:22:10
tep102_temperature = 32.56
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:12
tep102_temperature = 32.56
CH_sleeping battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:14
tep102_temperature = 32.56
CH_complete battery voltage = 4.16
--------------next–data---------------
10/11/11/Thursday 9:22:16
tep102_temperature = 32.56
CH_complete battery voltage = 4.16
--------------next–data---------------
165/25/4545:85:18
tep102_temperature = 32.56
CH_complete battery voltage = 4.16
--------------next–data---------------