CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to store data on eeprom 24c04 like data base with date

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Madhu_k_r



Joined: 12 Jan 2016
Posts: 26
Location: Bengaluru

View user's profile Send private message

How to store data on eeprom 24c04 like data base with date
PostPosted: Thu Nov 10, 2016 7:05 am     Reply with quote

Hi guys ...
For one of my project i need to store data on external eeprom 24c04 like data base that is i need to store at least last 5 days data and retrieve the same got any idea Question please help me with this Thank you
_________________
KaalaayaTasmaiNamah:
guy



Joined: 21 Oct 2005
Posts: 297

View user's profile Send private message Visit poster's website

PostPosted: Sat Nov 12, 2016 2:57 pm     Reply with quote

Hi Madhu,
I have a data logger project with a 24LC1025 (256KB EEPROM). If you can be specific with your question/problem I'd be glad to help.

Guy
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Nov 12, 2016 4:00 pm     Reply with quote

How much 'data' do you need to store ? What IS the 'data'? What format is the 'data'. The EEPROM you listed only has 512 bytes of storage, so is that enogh for 5 days worth of 'data'?

We need a LOT more details about this 'data'....

Also need to know how much you can afford for the external storage device !

And what PIC are you using ? Do you have the required I/O pins available for the interface ? 5 V or 3 V ? Speed ??

Your solution will be found in the 'details' that you haven't provided us with....

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Nov 13, 2016 3:50 am     Reply with quote

As a comment, to store a date, obviously you need some form of RTC on the PIC. There is a 'standard' way of encoding dates/times, which stores them in a machine readable form, as 'seconds since epoch', where the 'epoch' as standard on most systems is either 1970, or 2010 (as an in32 count). CCS provides the standard C library for this, converting a date and time, into such a count, or turning a count back into a date and time (supporting both epoch's, #define TIME_T_USES_2010, switches operation). This is in time.h/time.c. This also includes functions to perform some maths with these, giving you the 'difference' between two times (for example). Now since this includes seconds rather than just date, it may well be bulkier than you need, but (for insance), if your EEPROM data, for each record, simply started with the int32 'timestamp' from this, then if you wanted to find all records in the last day, a simple search, testing if the stored time in each record is less than 86400 seconds from the current time would do this.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Nov 13, 2016 6:02 am     Reply with quote

hmm..since the original post has a very small EEPROM I'm thinking that there are only a few data to store per day. If he doesn't need precise seconds and can live with 15 minute resolution( 6:00,6:15,6:30,etc.) you can store 24hrs in less than a byte! I did that 30 years ago and it still works today. You've actually got one bit leftover, that can be used as a 'flag'. So if you wanted to turn a light on /off, within one byte you have the time and control command.
A similar method can be used for actual temperture, storing the difference and not the real reading.
We still need to hear back from the OP about how much 'data' needs to be stored though.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sun Nov 13, 2016 9:15 am     Reply with quote

Absolutely.
As I said:
"Now since this includes seconds rather than just date, it may well be bulkier than you need".
Indeed since he just says 'date', he may not need time of day at all.

The key thing as you have already said is 'more data needed'.
elektroman



Joined: 07 Feb 2018
Posts: 2

View user's profile Send private message

mylogger
PostPosted: Wed Feb 07, 2018 8:20 am     Reply with quote

https://www.youtube.com/watch?v=HNIHc5i6Ukc
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group