View previous topic :: View next topic |
Author |
Message |
mns Guest
|
Event driven datalogger |
Posted: Fri Jan 18, 2008 8:11 am |
|
|
Hi,
I'm in the process of designing an event driven datalogger that will have approximately 10 digital inputs. The interfaces to be used are LCD, EEPROM, RTCC, RS232, all of which i have tested and all work okay. The PIC i'm using is the 18F452.
I'm now starting to think about the software for the main program and this is where i'm weak (software!) but learning slowly. As the datalogger will be event driven, i was thinking of scanning each input in turn and if a state change occurs, then log the state, time and date to EEPROM. Sounds simple but i can't think of a way of only capturing the time on a state change (due to lack of programming experience).
Has anyone got some ideas that could point me in the right direction to get started?
Regards
mns |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jan 18, 2008 12:03 pm |
|
|
Add a Real Time Clock (RTC) chip such as the DS1307. Then read the
date and time from it whenever a trigger event occurs. Then write a
record to an external eeprom chip, such as 24LC256. Look in the CCS
code library for drivers for RTC chips, or look in the CCS drivers
directory on your hard disk. |
|
|
mns Guest
|
|
Posted: Sat Jan 19, 2008 2:38 pm |
|
|
Thanks for your reply.
I'm already using the rtc ds1302 and can display the time date etc but i'm having trouble trying to get my head around the fact that i only want to know the time on each state transition of each input.
I think i know how to just capture the time when say the input goes high but not sure how to just read that time and then return to polling the inputs.
Regards
mns |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
|
Posted: Sat Jan 19, 2008 6:18 pm |
|
|
mns wrote: | Thanks for your reply.
I'm already using the rtc ds1302 and can display the time date etc but i'm having trouble trying to get my head around the fact that i only want to know the time on each state transition of each input.
I think i know how to just capture the time when say the input goes high but not sure how to just read that time and then return to polling the inputs.
Regards
mns |
A simple method would be to poll to see if any inputs have changed since the last log entry. If a change has occurred make a log entry. Run this as a function called from your main loop. Run a function for each interface. |
|
|
|