Shop OBEX P1 Docs P2 Docs Learn Events
DS1307 Driver/ Unable to set it up! — Parallax Forums

DS1307 Driver/ Unable to set it up!

jmmb392jmmb392 Posts: 22
edited 2016-06-13 22:36 in Propeller 1
Dear group,

I am extremely new in the propeller world, this is my first project, I am trying to count the IR pulses coming out of a power meter to measure the energy consumed and create an energy profile. To do that, I need to time stamp each pulse, that is, I need to be able to measure time. I am trying to setup the ds1307 RTC clock but I do not know how to do it. I am using a Propeller Mini, and I am using:

P0 = RTC SDA
P1= RTC SCL

I downloaded this:

http://obex.parallax.com/object/207

but I can not get it to work, after I enter the time it returns Operation failed!

I also downloaded the files that I am attaching, but after I enter the time, it returns

00/00/00
00:00:00 AM

I really appreciate your help.

Thank you

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2016-06-14 01:14
    Your program and the RTC demo program from the ObEx are configured to use I/O pin 28 for SDA and pin 29 for SCL. If you want to use pin 0 and pin 1, you have to change _clockDataPin and _clockClockPin appropriately.

    Also, pin 28 has the required pullup resistor on it. Pin 29 also "should" have a pullup, but not all boards have this (including the Mini) and they work fine otherwise as long as the I/O driver is written for this case (The boot loader and most I2C drivers in the ObEx account for this). If you're going to put the RTC on pins 0 and 1, use a 4.7K pull up resistor (to +3.3V) on both lines.
  • Mike Green wrote: »
    Your program and the RTC demo program from the ObEx are configured to use I/O pin 28 for SDA and pin 29 for SCL. If you want to use pin 0 and pin 1, you have to change _clockDataPin and _clockClockPin appropriately.

    Also, pin 28 has the required pullup resistor on it. Pin 29 also "should" have a pullup, but not all boards have this (including the Mini) and they work fine otherwise as long as the I/O driver is written for this case (The boot loader and most I2C drivers in the ObEx account for this). If you're going to put the RTC on pins 0 and 1, use a 4.7K pull up resistor (to +3.3V) on both lines.

    Hello Mike,

    Thank you for your response, I understand that I have to use pin 0 and pin 1 as SDA (_clockDataPin) and SCL (_clockClockPin) respectively, I already did that and it does not work. For the pull up resistor issue, I am using the following board kit:

    https://cdn-learn.adafruit.com/downloads/pdf/ds1307-real-time-clock-breakout-board-kit.pdf

    They use 2.2k resistors, is that correct, or should I replace them with the 4.7k resistors that you suggest?

    Thank you for your help!
  • Just checking that you changed the pin numbers in the RTC_Demo program. Your posted program shows 28 and 29.

    P0 is physical pin 41 on the Mini, P1 is physical pin 42.
  • Mike GreenMike Green Posts: 23,101
    edited 2016-06-14 15:09
    2.2K pullup resistors are fine. There's a balance between power consumption and noise suppression. 10K is commonly used when the connections are short (cm) and low power consumption is important.

    Your posted code specifies pins 28 and 29. You really have to post the actual code you're using. Otherwise we're all guessing what's wrong ... not very helpful.
  • Double check that you wired the kit correctly and the connections between the kit and Prop Mini are correct.
  • Mike Green wrote: »
    2.2K pullup resistors are fine. There's a balance between power consumption and noise suppression. 10K is commonly used when the connections are short (cm) and low power consumption is important.

    Your posted code specifies pins 28 and 29. You really have to post the actual code you're using. Otherwise we're all guessing what's wrong ... not very helpful.

    Thank you for your response Mike, I apologize I am now attaching the files that I am actually using.
  • I don't see any obvious reason why the program as posted doesn't basically work. That suggests that there's a hardware problem somewhere. My next step would be to carefully check all wiring and solder joints on the kit. Make sure you have a battery installed on the RTC board. Have someone else check the wiring for you if possible. It's too easy to fool yourself into believing that things are all as they should be. The same is often true in checking code.
  • As an aside, you can archive you whole project in the SPIN Tool. This will make a ZIP file with all supporting files included without having to upload each one.
    719 x 355 - 118K
  • Mike Green wrote: »
    I don't see any obvious reason why the program as posted doesn't basically work. That suggests that there's a hardware problem somewhere. My next step would be to carefully check all wiring and solder joints on the kit. Make sure you have a battery installed on the RTC board. Have someone else check the wiring for you if possible. It's too easy to fool yourself into believing that things are all as they should be. The same is often true in checking code.

    Hi again Mike,

    I purchased 2 ds1307 kits, I put together the second one, and replaced the first one, still no answer!
  • tomcrawfordtomcrawford Posts: 1,126
    edited 2016-06-14 22:03
    I wired up a DS1307 on a PPDB and ran the exact code (downloaded from 5 posts above). I can promise the code works. You have to be very careful in going through the set clock procedure EDIT: including leading zeros endedit but it does make a running clock. As posted, it does want data on I/O 0 and clock on I/O 1. I used 3.3K pull-ups to 3.3V.

    Edit: DS1307 does not drive SDA high, so no inline resistor. In fact, depending on configuration, it may keep it from driving a good low. EndEdit
  • jmmb392 wrote: »
    Mike Green wrote: »
    I don't see any obvious reason why the program as posted doesn't basically work. That suggests that there's a hardware problem somewhere. My next step would be to carefully check all wiring and solder joints on the kit. Make sure you have a battery installed on the RTC board. Have someone else check the wiring for you if possible. It's too easy to fool yourself into believing that things are all as they should be. The same is often true in checking code.

    Hi again Mike,

    I purchased 2 ds1307 kits, I put together the second one, and replaced the first one, still no answer!

    Hi Mike,

    I was never able to make it work. What I did, I replaced the propeller mini, and instead, I used a Propeller demo board, I used P4 for SDA and P5 for SCL, and it worked at the first try. Maybe the propeller mini was defective. Thank you for all your collaboration and patience. Now, I want to be able to count the IR pulses coming out of a power meter to measure the energy consumed and create a daily/monthly energy profile. To do that, I need to time stamp each pulse, that is, I need to be able to detect the pulse and then get the time when the pulse was detected and store it in a variable. I finally got the RTC to work, now, how do I create a variable to store the time and date every time a pulse is detected? I am attaching the code where I got the clock to work.
  • The IR pulse from most electricity meters is emitted for every watt-hour consumed, so you will see a lot of pulses during periods of heavy electricity use. Maybe more than one pulse per second, which is the resolution of the DS1307. Time stamping each pulse is not necessary, and will consume a lot of memory.

    Another way to get the information you want would be to count the number of pulses over a fixed interval of time, say 5 minutes, and store that total. Using 5 minute intervals, you will have 288 intervals per day, each with the number of pulses equal to the energy consumed in during that interval, in watt-hours.
  • @jmmb392, It could be that you have overlooked some i/o pin assignments. The highest i/o on the Prop mini is 18 from what I can see in a photo. The code snippet from the demo that you posted communicates on pins 31 and 30
    OBJ
      rtc           : "DSRTC_driver"
      Debug         : "Extended_FDSerial"  
    
    PUB Main
      useser := false
      if ina[31] == 1                      ' RX (pin 31) is high if USB is connected
        Debug.start(31, 30, 0, 57600)      ' ignore tx echo on rx
        useser := true                     ' Debug serial connection is active 
      waitcnt(clkfreq * 3 + cnt)         ' Pause for FullDuplexSerial.spin to initialize
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    lardom wrote: »
    @jmmb392, It could be that you have overlooked some i/o pin assignments. The highest i/o on the Prop mini is 18 from what I can see in a photo. The code snippet from the demo that you posted communicates on pins 31 and 30

    P30/P31 are the programming pins which would be available at the Prop Plug connection.

  • PublisonPublison Posts: 12,366
    edited 2016-06-22 15:11
    Seems to be a discrepancy on the schematic:

    https://www.parallax.com/sites/default/files/downloads/32150-Propeller-Mini-RevA-Schematic-v1.3.pdf

    P30 goes to P30, but P31 goes to P29

    [img][/img]
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Actually that line says both P29 and P31. I have reported it before.
  • For some reason I couldn't get the JPG to post. Will try later
  • Here is the PDF showing the discrepancy.
    Mini.pdf 127.4K
  • P30/P31 are the programming pins which would be available at the Prop Plug connection.

    Is it possible that the Prop Plug could be turned upside down? When I first assembled the Propeller Kit I thought it odd that the logo side of the Prop Plug was facing down. I use a lot of Schmartboard modules currently and the logo side faces up.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    lardom wrote: »
    Is it possible that the Prop Plug could be turned upside down? When I first assembled the Propeller Kit I thought it odd that the logo side of the Prop Plug was facing down. I use a lot of Schmartboard modules currently and the logo side faces up.

    On the Propeller Mini the GND and RX pins are clearly marked on the top side of the board. The resulting arrangement would have the label side up.

  • Sapphire wrote: »
    The IR pulse from most electricity meters is emitted for every watt-hour consumed, so you will see a lot of pulses during periods of heavy electricity use. Maybe more than one pulse per second, which is the resolution of the DS1307. Time stamping each pulse is not necessary, and will consume a lot of memory.

    Another way to get the information you want would be to count the number of pulses over a fixed interval of time, say 5 minutes, and store that total. Using 5 minute intervals, you will have 288 intervals per day, each with the number of pulses equal to the energy consumed in during that interval, in watt-hours.

    lardom wrote: »
    @jmmb392, It could be that you have overlooked some i/o pin assignments. The highest i/o on the Prop mini is 18 from what I can see in a photo. The code snippet from the demo that you posted communicates on pins 31 and 30
    OBJ
      rtc           : "DSRTC_driver"
      Debug         : "Extended_FDSerial"  
    
    PUB Main
      useser := false
      if ina[31] == 1                      ' RX (pin 31) is high if USB is connected
        Debug.start(31, 30, 0, 57600)      ' ignore tx echo on rx
        useser := true                     ' Debug serial connection is active 
      waitcnt(clkfreq * 3 + cnt)         ' Pause for FullDuplexSerial.spin to initialize
    
    lardom wrote: »
    @jmmb392, It could be that you have overlooked some i/o pin assignments. The highest i/o on the Prop mini is 18 from what I can see in a photo. The code snippet from the demo that you posted communicates on pins 31 and 30

    P30/P31 are the programming pins which would be available at the Prop Plug connection.
    Publison wrote: »
    Seems to be a discrepancy on the schematic:

    https://www.parallax.com/sites/default/files/downloads/32150-Propeller-Mini-RevA-Schematic-v1.3.pdf

    P30 goes to P30, but P31 goes to P29

    [img][/img]

    Thank you all for your responses. I decided to switch to a propeller demo board and everything worked. I have already programmed the propeller to use two cogs to read 2 optical ports coming from the power meters and store the values in variables. Now, I want to be able to save those values in a EEPROM for backup and also send those values wirelessly via Xbee, I have no clue on how to start doing any of the two tasks. I am attaching my latest code for your revisions and suggestions.
Sign In or Register to comment.