Shop OBEX P1 Docs P2 Docs Learn Events
DS1307 with Prop and “RTCEngineDS1307” — Parallax Forums

DS1307 with Prop and “RTCEngineDS1307”

AmaralAmaral Posts: 176
edited 2010-03-12 00:23 in Propeller 1
Hello all !

I’m having an odd behave on my DS1307 (RTC) chip with this object “RTCEngineDS1307”, the clock is really slow, missing time like 8 minutes per hour! The thing is that the same chip running on a BS2Pe, in the same breadboard works perfectly. The object is very clear and well made, at first I could not believe that there was something wrong with that, but now I don’t know anymore what to think, if it’s me that is making some stupid mistake or anything else !

I took some measurements on an oscilloscope on the SWQ/OUT pin of the DS1307 with the same frequency set to be out (8.192 kHz), and this show an even more odd behavior, with the BS2Pe the wave is continuous (as it should be) but on the propeller driven DS1307 the wave is broken from time to time (see images attached )

I’m really missing something here, if anyone can help me would be very appreciable.

I attached the object and the codes of both too, just for clarity .

Thanks in advance.

Amaral.

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 00:43
    Your code is outputting a 100Hz signal on I/O 10 which exactly corresponds with the low frequency modulation in your waveform. Could it be perhaps that you have this signal connected to the timing output of the RTC?

    BTW, I'm guessing that your timing or clock frequency of the Prop is incorrect somewhere.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*

    Post Edited (Peter Jakacki) : 3/8/2010 12:50:13 AM GMT
  • AmaralAmaral Posts: 176
    edited 2010-03-08 00:45
    even if I take that off, the behave is the same ! that was just for me to know when I was refreshing the LCD .
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 00:49
    Ok, have you double checked the hardware, it looks like you have another output trying to drive the RTC pin and that output is running at 100Hz.

    The reason I say this is that you can still see the clock output riding on the high or low of the 100Hz.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • AmaralAmaral Posts: 176
    edited 2010-03-08 00:53
    yeap , just took out everything of the code ( all the flashing lights ), the pin 7 of the RTC is just been pulled up by a 4.7K ohm to 5V. nothing else ! and still the same measurement. is really odd !
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 00:56
    The RTC code only seems to set rs1,rs0 of the RTC but SQWE needs to be set to 1. Where are you setting that? I have never used Kye's 1307 driver myself.

    Ok, I just checked the driver and it seems to be setting that bit automatically.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 01:00
    Oh, your slow clock plus the interference seems to point to 100Hz modulation of the 32.768kHz oscillator. What does that look like?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:01
    I'm not, I am trusting that the Kye's driver does it for me.

    PUB setSQWOUTFrequency(frequency) '' 13 Stack Longs

    '' ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
    '' │ Turns the square wave on. │
    '' │ │
    '' │ Frequency - Selects the frequency of the square wave pin. (0 - 1HZ), (1 - 4.096KHZ), (2 - 8.192KHZ), (3 - 32.768KHZ). │
    '' └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

    setRAM(7, ($10 | ((frequency <# 3) #> 0)))

    this setRAM on the end gives me the SQWE with this $10 right before the freq. At least that was what I deduced ! but I can be wrong, as I told before, the driver is so clean that I don't believe that is the problem !
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:04
    " Oh, your slow clock plus the interference seems to point to 100Hz modulation of the 32.768kHz oscillator. What does that look like?

    *Peter* "

    Sorry peter ... but I did not get what you mean !
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 01:08
    The 32K crystal is a very sensitive oscillator on pins 1&2. It can be be prone to interference and even scope probes can affect it. Pin 2 is the output so try hooking up the x10 scope probe to there and check that it's a clean signal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:17
    Looks very clear, even with a big sample, it does not show any pattern of the 100 Hz cutoff. The oscillator is welded to the top of the pins 1 and 2 of the RTC, I do that to minimize interference. But never knew how to test it. Thanks , but the problem still persists.

    Amaral
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 01:26
    Good, but your test is incomplete, you must compress the scope's timebase down to view 100Hz modulation as you can miss the subtle modulation in such a keyhole type view. Remember, this is a sensitive analog circuit here and you have done the right thing in keeping the leads short and close. Double check the RTC's supply for AC while you are at it, you never know.


    My goodness, I just realized that is slowed down. That's your problem there, that is 50Hz (or 60Hz) coming in.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*

    Post Edited (Peter Jakacki) : 3/8/2010 1:31:57 AM GMT
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:40
    ohh man !


    The problem just disappeared !
    I reload all the flashing lights and even some parts for controlling the push buttons, and now it’s working normally !
    Is there any possibility of the resonator to be with some kind of charge inside, or anything that during the test just discharged or charged, or got rib of ! have you ever heard about anything like that ?
    The sad part is that I’ll never know what was happening ! that makes my project not really trustable .

    Thank you very much, the sequence of tests made it go back ( and I lost a hole Sunday afternoon on that, but now I know how to test a resonator ) .

    If you have any idea of what was happening please share !

    Amaral

    PS: over here is all 60Hz , but my power supply is very clean!
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:44
    the problem is back !

    Desapeared for a moment , and now is back again !
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 01:45
    Faulty crystal, replace it?

    BTW, make sure that you clean the flux off properly from around the RTC. It affects both the oscillator and the standby current.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:49
    Taking the measurement very carfully, it is not 100 Hz , it is 59.93 Hz, wich shows me that is really and inductance from the power grid. !
    ok .. no idea how to get rib of it !
  • AmaralAmaral Posts: 176
    edited 2010-03-08 01:50
    ok .. I'll do it and repport !
  • Tracy AllenTracy Allen Posts: 6,667
    edited 2010-03-08 02:05
    How is your DS1307 powered, and also the battery backup? The SWQ pin is clearly pulled up to 5V, and if you have followed Kye's instructions, both SDA and SCL are pulled up to 3.3V. That should be okay for data communication. The power supply Vcc on pin 8 has to be 5V, or between 4.5 and 5.5. The DS1307 is not supposed to run at Vcc=3.3V. Funny things can happen if the battery input is floating. Also, this chip will do strange things if it is running on parasitic power, for example, if Vcc goes to zero while SDA or SCL are still pulled high, or if the ground connection is not solid.

    Is your 'scope well-grounded to the circuit? If not, it would be picking up power line hum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • AmaralAmaral Posts: 176
    edited 2010-03-08 02:37
    Still the same problem ! even with different combinations of DS1307 and cristals !
    Yeap the pull ups are ok !
    I'm using a battery , I have made the mistake of lefting the pin 3 Batt floating before !
    The communication is solid and good , I can access NVRAM, I can set time , but I get that funny thing on the pin 7 , and Im running the clock slow !
    When I power off the circuit, the occilator stops too, I don't miss data from NVRAM and I don't get the clock (RTC) zeroed, but the seconds does not advance ! Still with the BS2p . everything works perfect , with all the combinations of DS1307 and cristals that I have ( I have two DS1307 and four Cristals, not welded anymore).

    Another interesting thing, when I power up , it takes around 10 seconds to start changing the seconds ! It's becamming clear that is a hardware problem, but I still cannot isolate it !

    Any suggestions are welcome !


    Amaral
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-08 02:51
    As mentioned previously the 1307 needs +5V to run and Vbat must be less than that at less than 4V. Are you saying that your oscillator is now fine? Do you have a photo?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • AmaralAmaral Posts: 176
    edited 2010-03-08 03:08
    the DS1307 is running at 5V , and the batt is a single cell littium , that is supplying 3.3V .

    Tomorow I´ll re assembly everything and see if it makes any difference ..
    ·
  • KyeKye Posts: 2,200
    edited 2010-03-08 15:57
    @Amaral - I'm sorry you are having any problems witht eh DS1307 RTC. The RTC driver I wrote just sends I2C data back and forth to the DS1307. My driver does not control the operation of the RTC. So, it just tells the DS1307 to turn its SWQ pin output on and nothing more.

    So, I would say that you definately have a hardware problem with your setup. Check to make sure you put a by pass capacitor on the 5V rail near it. Ive had many problems before with devices when the bypass cap was left out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
  • RaymanRayman Posts: 14,996
    edited 2010-03-08 17:50
    I'd guess a bad connection or interference at the crystal...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm

    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • AmaralAmaral Posts: 176
    edited 2010-03-10 03:13
    Guys, I'm convinced that I have a hardware problem, Kye , thanks for the excellent driver, as I said before that is very clear and clean !

    I had an emergency at my job and will return just by the end of the week... if I am lucky. but then I'll check everything, including the cap close to the rail. I'll post news as I have it ..

    Thanks all
  • AmaralAmaral Posts: 176
    edited 2010-03-11 21:17
    Ok .. cannot Explain, just disassemble averything, and assemble back on another breadboard ! now is working perfectely !

    Thanks for the help !
  • KyeKye Posts: 2,200
    edited 2010-03-12 00:23
    Breadboard. There's your problem.

    Protoboard. There's your fix.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.