element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Pic Microcontrollers Forum using DS1307 to store data
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 2 replies
  • Subscribers 191 subscribers
  • Views 866 views
  • Users 0 members are here
Related

using DS1307 to store data

Chris_Chuter
Chris_Chuter over 2 years ago

Hi All. I am developing a PIC 16F1829 based design which starts, stops and monitors a big diesel generator. An important function is that the module will timestamp an SD card module data output with a 'chunk' which will contain various realtime parameters derived from the acquisition of values using the analogue inputs and ccp counts from the PIC/generator. The SD card is removeable and can be inserted into a PC which will confirm various User uses of power by means of a spreadsheet.

My difficulty is how in C, to get a timestamp value with which I can prepend the 'chunk'. I know that VB has a standard way of presenting Date/Time in, possibly. a Long data value  but I am becoming confused in how to move forward.

Chris

  • Sign in to reply
  • Cancel

Top Replies

  • shabaz
    shabaz over 2 years ago +1
    Hi, You can check the DS1307 datasheet, it contains the format that you can read the clock time in: For instance, if you read addresses 00, 01 and 02, then you'll know the real time seconds and minutes…
  • Chris_Chuter
    Chris_Chuter over 2 years ago +1
    Thanks a lot, Shabaz. This was a very comprehensive answer so I have looked at using the PICO but I need to do a lot of ADC conversions. Also, I am fairly comfortable with Microchip PIC's and although…
  • shabaz
    0 shabaz over 2 years ago

    Hi,

    You can check the DS1307 datasheet, it contains the format that you can read the clock time in:

    image

    For instance, if you read addresses 00, 01 and 02, then you'll know the real time seconds and minutes and hours. There are probably many example C libraries for DS1307 so you likely don't need to write that part of your code entirely from scratch. However DS1307 and PIC combination are used by beginner students, so expect a lot of awful code examples on the Internet  too : ) Anyway, by looking at some examples, you'll soon get the idea how to do it yourself too.

    If you're putting the data in a file, then CSV is as reasonable as any other format, you can check Wikipedia to see what CSV format looks like (it's just commas). You can view CSV files with Excel, and programmatically read them with C, Python, and VB, etc. Google CSV and the language of your choice, and again you'll likely find plenty of code examples so that you can read the data from your SD card.

    The actual time format that you write to the card within the CSV file is up to you. You can see what Excel can natively understand, by typing a value in to a cell and using the Format Cells menu:

    image

    If you really want to go to town, you could pick a standard (ISO 8601 for instance, it is google'able) and write your values in that format. Again, any programming language can be used to parse that, and there will be examples for all languages if you google for it. Or, you could create your own standard (not really a good idea if this is a professional product).

    Finally, I'd suggest using a different microcontroller; you'll fit a proper file system library into a more recent microcontroller (Pi Pico for instance - or something else, depending on your other needs like say ADC requirements).

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Chris_Chuter
    0 Chris_Chuter over 2 years ago

    Thanks a lot, Shabaz. This was a very comprehensive answer so I have looked at using the PICO but I need to do a lot of ADC conversions. Also, I am fairly comfortable with Microchip PIC's and although I've only a few years' experience, this project is very much about extending that knowledge. I have already ordered a PICO, though so I will be experimenting with it soonish.

    many thanks

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube