Clock Module 28X2 Pins

jopooze

Member
I've been trying to connect the DS1307 clock module to a 28X2 on the experimentation board. I connected the module properly on a 18M2 IC however for some reason it doesn't appear to be working with the 28. Can anyone tell me where to put the SDA, SCL and OUT pins into the 28X2?
 

hippy

Ex-Staff (retired)
If using PE6 the "Input/Output Table" option in Workspace Explorer will bring up a diagram and listing of pins. For the 28X2 -

Leg 14, C.3, I2C SCL
Leg 15, C.4, I2C SDA

"PICAXE Manual 1 - Getting Started" also contains PICAXE pinout diagrams.

The DS1307 OUT/SWQ signal can go to any digital input pin or can be left unconnected if not used. Note it is open collector so will need a pull-up to be used.
 
Last edited:

jopooze

Member
Didn't work. I've been using the input/output table and it states that C.4 is SDA and C.3 is SCL however using these doesn't seem to work.
 

jopooze

Member
To note I have all the required resistors and my layout worked with the 18M2 however past the update to the 28X2 I've had no success.
 

techElder

Well-known member
My I/O table for the 28X2 in PE 6.0.8.0:

Leg 14, C.3, I2C SCL
Leg 15, C.4, I2C SDA

And I know that works just fine.
 

hippy

Ex-Staff (retired)
Didn't work. I've been using the input/output table and it states that C.4 is SDA and C.3 is SCL however using these doesn't seem to work.
Sorry that was my typo earlier; I have now corrected that.

Perhaps it's how you are wiring things up ?

If the "experimentation board" is an AXE091 then you need to use the shorter set of pin contacts on the left, between the two sets of 40-pin contacts, to get at SCL. It's also worth checking you haven't got the I2C bus wires crossed over.

If it's not that then perhaps post a photo showing how you have things connected. It might also be worth posting your 28X2 code and describing exactly how it is not working manifests itself.
 

jopooze

Member
No luck still. I did have the wires connected to the wrong set of pins as explained by Hippy but nothing nevertheless. I've added some pictures. No lying here, it's a tad messy.

http://imgur.com/a/9iRCb

Also here's the code I'm working with: http://hastebin.com/sasovecafa.vbs

I've purposely not revealed the jungle that the rest of my wiring is because I know it works; I used it with the 18M2 and it was perfect.
 

techElder

Well-known member
I know that you said above that you had "... all the required resistors ...", but this does sound like you've left off the resistors that connect SCL and SDA to VCC. They are usually 4700 ohms.
 

srnet

Senior Member
Have you checked with a continuity tester between the actual component legs on the PICAXE and Clock chip, that what you think is connected actually is ?
 

jopooze

Member
It says that the photo's I'm trying to upload to show you are too large so I'm unable to let you see in any other way than externally.
 

hippy

Ex-Staff (retired)
The AXE091 board has the 4K7 I2C pull-up resistors built in when using the on-board I2C sockets, so the only connections you need are two wires from legs 14 and 15 to SCL and SDA. I would suggest stripping the wiring back to just those to get the DS1307 working.
 

inglewoodpete

Senior Member
It says that the photo's I'm trying to upload to show you are too large so I'm unable to let you see in any other way than externally.
If you're using windows, then open your pictures in Paint and scale them down (Home Tab>Resize) eg 70% and save them to a new file. It's too easy - you don't need paintshop.

I have to agree with other comments: it's really hard to tell if you have the scl and sda wires in the right sockets with the angle you had your camera at. Also, try to improve the lighting with another photo.
 

hippy

Ex-Staff (retired)
I haven't got an AXE091 to check, but your green wire at the left of the picture in post 7 looks to be in the 13th hole.
Agreed, and the connection is to the 40-pin socket adjacent to the chip. It should, as described earlier, be to the shorter pin socket to its left. It isn't clear if the right wire is in the leg 15 (27) hole either.
 

Attachments

jopooze

Member
Upon changing the DS1307 the same problem appears. I believe change from i2c to hi2c with the 28X2 is causing my problems. Does anyone know any changes I need to make because of the change in pin values?
 

hippy

Ex-Staff (retired)
I2C and HI2C are the same commands with different names and syntax so it is unlikely that is the cause of any problems.

It is still likely to be wiring issue so it would be best if you post a photo of your circuit with unnecessary wiring removed then members can check that it is wired correctly.
 

hippy

Ex-Staff (retired)
The following program worked for me on an AXE091 board, 28X2 and DS1307. Just two wires -

Leg 14, C.3, SCL
Leg 15, C.4, SDA

Code:
#Picaxe 28X2
#No_Data
#Terminal 9600

Pause 2000

SerTxd( "DS1307 Test", CR, LF )

Pause 1000
SerTxd("READY ")

HI2cSetup I2cMaster, $D0, I2cSlow, I2cByte
SerTxd("SETUP ")

HI2Cout $0,(0,0,0,0,0,0,0,$10)
SerTxd("WRITE")

SerTxd(CR,LF)
b8 = -1
do
  Pause 100
  HI2cIn $0,(b0,b1,b2,b3,b4,b5,b6,b7 )
  If b0 <> b8 Then
    b8 = b0 : Gosub ShowHex
    b8 = b1 : Gosub ShowHex
    b8 = b2 : Gosub ShowHex
    b8 = b3 : Gosub ShowHex
    b8 = b4 : Gosub ShowHex
    b8 = b5 : Gosub ShowHex
    b8 = b6 : Gosub ShowHex
    b8 = b7 : Gosub ShowHex
    SerTxd( CR,LF)
    b8 = b0
  End If
loop

ShowHex:
  b9 = b8 / $10 + "0"
  If b9 > "9" Then : b9 = b9+7 : End If
  SerTxd( b9 )
  b9 = b8 & $0F + "0"
  If b9 > "9" Then : b9 = b9+7 : End If
  SerTxd( b9, " " )
  Return
After a short delay, after download or power-cycling, you should see an incrementing display as follows -

Code:
DS1307 Test
READY SETUP WRITE
00 00 00 00 00 00 00 10 
01 00 00 00 00 00 00 10 
02 00 00 00 00 00 00 10 
03 00 00 00 00 00 00 10
[i]etc[/i]
If not, check the two wires go to the correct legs and correct connection points, that you have a 5V supply to the PICAXE and DS1307, check the backup battery or the DS1307 Vbat is connected to 0V.
 

hippy

Ex-Staff (retired)
The wiring seems to be correct though it would have helped to remove all unnecessary wires and use different colour wires for SDA and SCL.

That suggests there is possibly some issue with the unnecessary pull-up resistor, with your power supply, DS1307 battery supply, your code, or perhaps a faulty DS1307 or 28X2. What results do you get if you run the earlier test program ?
 

jopooze

Member
I checked with a different DS1307, battery pack + a cable connector from a plug socket and removed the pull-up resistor so that leaves either my program or my Pic. I noticed that when using my code (the same code that worked with the other pic) the variables of the DS1307 didn't budge. They froze.
 

hippy

Ex-Staff (retired)
When you say "battery pack"; what voltage is that supplying ?

Also, whilst the code you had worked for other chips, have you actually tried that code on other chips in recent days with the current setup you have, or was that from 'way back when' ?

What happens when you run the code I included in post #11 ?
 

jopooze

Member
The battery pack provides 5v. I have no other Picaxe. This update to the 28X2 was the initial change for the code. Also your code opened the terminal and wrote the first stage but none of the rest.

"DS1307 Test
READY SETUP WRITE
00 00 00 00 00 00 00 10"
 

Technical

Technical Support
Staff member
1) The 'out' connection from the 4 pin i2c connector could be wrong, appears to go via 1K to +5V ? Remove it completely.
2) Remove the WP connection as well
3) What chip is in the 24LCxx socket next to the DS1307? Remove it as well.
 

hippy

Ex-Staff (retired)
"DS1307 Test
READY SETUP WRITE
00 00 00 00 00 00 00 10"
That shows that the DS1307 is notionally working, I2C writes and reads do work. If the " If b0 <> b8 Then" command and associated "End If" are removed, the "Pause 100" increased to "Pause 1000", I would predict it to then repeatedly show "00 00 00 00 00 00 00 10" data. It would be worth testing that.

If that is the case it would seem that the DS1307 oscillator isn't working, is not incrementing its internal time. If other DS1307 chips exhibit the exact same behaviour that may point to a failed watch crystal.

That could also be double-checked by running the same test code on PICAXE chips where the RTC code used to work; it probably no longer works with those either.
 

jopooze

Member
Sorry I'm REALLY late to reply to this, been busy. Removing the strings you stated and increasing the pause did what you expected; not sure what that means however. You say it could be the watch crystal? How exactly could I be certain, where can I buy a new one and how can I replace it on the board?
 

hippy

Ex-Staff (retired)
If it is the crystal being problematic, the first thing to do is to check there are no dry joints on its legs and check its legs haven't been pushed together and are shorting. Giving the crystal body a sharp tap my kick it back into life. That's not recommended, can damage a crystal, but it doesn't seem you have a lot to lose.

You may be able to use a scope to see if there is any oscillation on the DS1307 crystal drive pins. Otherwise there is no easy way to check if the crystal is working or not. You could perhaps configure a PICAXE to use an on-chip LPOSC driven timer and see if that increments but if the DS1307 doesn't it's unlikely anything else would. It's probably easier just to replace it; simply unsolder the old one and solder in the new.

Suitable watch crystals are available from our online store ...

http://www.picaxestore.com/RES038
 

jopooze

Member
Can't believe it's so difficult to get a flippin clock module working. I swapped AXE boards with a friend to see if the watch crystal on his worked on mine. It did not. Something is still messing with me. Hippy or someone is it possible to write a tutorial with the main tips to look out for when building a circuit with the 18M2 and the DS1307 with OLED screen. I know I've done something wrong but I don't think I'll find it fiddling for forever.
 

hippy

Ex-Staff (retired)
Can't believe it's so difficult to get a flippin clock module working.
I don't think anyone else can either.

I swapped AXE boards with a friend to see if the watch crystal on his worked on mine. It did not. Something is still messing with me.
That does seem extremely odd.

Hippy or someone is it possible to write a tutorial with the main tips to look out for when building a circuit with the 18M2 and the DS1307 with OLED screen.
There really is nothing to it. Forget any OLED display to start with. On an AXE091 board all that needs to be done is to connect two wires from the PICAXE socket to the I2C header socket and run the code in post #21.
 

MartinM57

Moderator
Note that Hippy's code in post #21 sets the SQWE output on leg 7 of the DS1307 to a 1Hz frequency (but your hastebin code doesn't - you don't write to Control Register at 07H at all)
...so with Hippy's code running and with a multimeter set on volts connected to leg 7 do you see a varying voltage (0.5 sec high, 0.5 second low) on the display?

However you have to connect Leg 7 to Vcc (5 volts) with say a 10K resistor first.

If the leg 7 voltage is measured as completely stable, after writing the SQWE bit as 1 in the control register (and leaving RS0 and RS1 as zero) then it would suggest the DS1307 is not working properly.
 

hippy

Ex-Staff (retired)
I think we perhaps need a reboot or refresh; need to know which PICAXE is being used, what program is being run, what board is being used, and how everything is wired, as it is no longer clear exactly what we are dealing with at this time.

The best starting point is a photo of the hardware with all unnecessary components and wiring removed.
 
Top