AXE033 LCD with RTC in I2C mode problems

JeremyCorkery

New Member
Has anybody had problems setting time and retrieving time from a DS1307 when it's in the AXE033?
I have the AXE033 in I2C mode and can send text to it, but can't get a response from the DS1307.

I'd put a DS1307 in the AXE033 and I've been trying to set the time and retrieve it (using sertxd first). Instead of values I'm just getting ?? (question marks)
I'm using a 28X2 as my micro.

I don't believe the clock is being set at all, because I'm not getting pulses out on AXE033 board. I have a 3v battery coin cell from a working PC. I don't think it's the Vbat.

If I take out the DS1307 and wire it up it elsewhere on the bus and it works fine.

I used the sample code written by BCJKiwi as he had done all the BCDtoAscii work, http://www.picaxeforum.co.uk/showthread.php?t=8078
.. using the first example.

I was a little unsure of the function of the clk jumper (I was robbed of a jumper in the kit too!). I thought it might also be a R / RW function with the DS1307 so tried a program just to set the time with this jumpered and not jumpered. Still not getting any results, so leaving this out as instructed in i2c mode.

Have I got a faulty AXE033? I've been searching the forums but haven't found any similar problems.
 

JeremyCorkery

New Member
Just thinking.. the DS1307 doesn't have any pins for R / RW function so that wasn't very smart... but the clk jumper was worth a shot.
 

westaust55

Moderator
Noting that BJCKiwi code that you have cloned is outputting via the SERTXD command to the PC, have you placed the mode link (next to the power link) to put the AXE033 into i2c comms mode?

The Clk jumper is to set the AXE033 to display the time directly to the LCD module – in that mode it does nothing else.

Suggest that you still post your own code so members can look for any errors.
 

JeremyCorkery

New Member
Vehicle detection code

Operation: I have a remote IR break beam at the front of the farm transmitting via ASK RF modules to a 28X2 when triggered. (vehicle passing through gate). Some of this test code is related to that and is just counting the number of times the beam is broken and displays that on the LCD. Not really useful.. just proving the concept.
I'd like to be able to timestamp this vehicle detection event, display it on LCD and store it in eeprom.
First I'd just like to get the RTC to work while sitting in the AXE033. This is why I'm using sertxd to my pc to check it works before even trying to send it out even to the LCD. It is in I2C mode. The DS1307 subroutine is the copied code from BJCKiwi mentioned before. The only change is in this on some of the reads from the i2c bus I specified the device [%11010000], thinking this might make a difference.
Is it correct that you only need to specify the device in this manner when changing which device you are talking to?
cheers.
 

Attachments

westaust55

Moderator
A couple of quick comments:

1. you cannot (usefully) have a series of hi2csetup commands such as:
hi2csetup i2cmaster, $C6,i2cslow,i2cbyte ' set up i2cslave for LCD
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
Only the last setup command is actioned/valid.

I do however note that you have the new slave address parameter set in the RTC read commend.

2. You do not have any code that I spotted to write the time, date and control functions to the DS1307 chip.
When the DS1307 first has power applied or after both power and back-up battery are disconnected you need to write the time, date and control code to the RTC chip.
You say that you have the DS1307 operating separately but if you then transferred the same RTC chip to the AXE033, you again need to write the data to the RTC.
The lack of any output pulse suggests the RTC is not setup and working although it is through the control code possible to turn that pin off or set higher frequencies.
 

JeremyCorkery

New Member
what is the best way to deal with multi i2c devices?

I'd taken the set time part of the code out and ran it as a separate download, when I was playing around.
So I've organised my hi2csetup commands wrongly?
So I take it i issue the hi2csetup commands everytime before writing or reading to an i2c device?
From reading the picaxe manual, I couldn't quite make sense of the newslave addr parameter. I just had a guess from BCJkiwis code that you could jump from slave device to slave device without using hi2csetup over and over again... funny that I'm having problems then. Does anyone know the correct use of the newslave parameter? What is the best way to deal with multiple i2c devices?
 

westaust55

Moderator
As I understand, the "new slave addr" parameter is good for changing to another device with similar other parameters. Since both the LCD and RTC use i2cbyte and i2cslow, believe the method you have used should work.

When there are distinct blocks of program code, you could alternatively just have one hi2csetup before all of each section of code.

At this point however, if you have a control word of $10 as per the standard RTC setup in the AXE033 datshseet and many exples on the forum, the output pin will operate at 1 Hz.

Note this is open collector so it is like a switch that when closed/on is a bridge to 0V and when open/off leaves the pin floating. So you need to test or wire a n LED with series resistor form +5V to the DS1307 input.
If you are not “seeing” this 1Hz signal the DS1307 has not been correctly set up.

I have found in the past that it has sometimes taken some time after I have written to a DS1307 before the clock a[appears to start. From memory, Rev Ed response to myself was that the AXE033 module only updates the time available to the PICAXE once every 30 seconds. Recall I found it may take a minute for me to see results.

Can you also post your separate code for the RTC setup.
 

JeremyCorkery

New Member
setfreq m4
hi2csetup i2cmaster, %11010000, i2cslow, i2cbyte
pause 500
hi2cout 0,($00,$25,$16,$03,$13,$10,$09,%00010000)

is this correct? I've been looking on the datasheet, I'm not quite clear what to set the day value to. It's currently $03... does this equate to an actual day or is it something you sort out in your program on the PICAXE?

I also read a post that mentions that you can run the LCD in serial mode and still use the RTC on the AXE033 in i2c mode - is this really correct? Might be worth a shot.
 

westaust55

Moderator
If you have a read of the datasheet for the DS1307 you will possibly better understand the DS1307 registers and various bits therein.
http://www.sparkfun.com/datasheets/Components/DS1307.pdf

The Programming Editor also has a wizard that can help you set up the RTC. (it may be aprt of the Datalogegr Wizard – not home to check right now).


hi2cout 0,($00,$25,$16,$03,$13,$10,$09,%00010000)
(1) If you are going to be using a value greater than 11 for hours, then you must also set bit 6 to indicate you are using a 24 hour clock mode.
So $16 OR $01000000 = = > $56.
(2) If you are going to use 12 hour clock mode you must set bit 5 instead for a PM indicator
So $16 chances to $04 OR $00100000 = = > $24.
(3) With control byte = $10 you should see a 1Hz pulse once the clock is correctly set.

So to see if you can get the clock running, try
hi2cout 0,($00,$25,$11,$03,$13,$10,$09,$10)
The Day value is just a value form 1 to 7. the clock increments each 24 hours and after 7 it rolls over back to 1.
So you can define Sunday = 1 and thus 3 = Tuesday. Up to you . . .



I also read a post that mentions that you can run the LCD in serial mode and still use the RTC on the AXE033 in i2c mode - is this really correct? Might be worth a shot.
Yes that possibility was advised recently. I have not tried it myself and suggest that you prove your i2c comms to the clock first then try other possibilities.
 
Last edited:

JeremyCorkery

New Member
The original problem was I getting ?? instead of values from the DS1307 real time clock when it was seated in the AXE033

Thanks for you help. This problem with the RTC was resolved when I tied Vin and Vout to GND. I also experience the same problem with RTC when I'd changed the supply voltage (4.5v) and wasn't getting enough voltage to the AXE033. Using J2 will fix the volt drop problem temporary, but I like the idea of diode protection.
 
Last edited:
Top