PIC 16f628 Storing time in EEPROM
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
PIC 16f628 Storing time in EEPROM

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Guest






Posted: Sat Dec 24, 2005 9:15 am    Post subject: PIC 16f628 Storing time in EEPROM Reply with quote

Im trying to figure out how to have the user specify a time delay
and the PIC remember that time for use later.
As of now I have a circuit built that has 8 LEDs that represent 8
seperate time modes.
Pressing button 1 cycles through the 8 time modes (LEDS) and
selecting button 2 activates a relay
for that particular time mode selected. I would like to add the
capability for the user to
calibrate and store each time mode to their liking. I have seen in
examples how to read and write the EEPROM
but the timing thing has got me stumped. How do you keep track of
seconds and parts of a second?

PIC16f628
4MHz
2 buttons Port A,2-3
1 relay Port A,0
8 LEDS PORT B

Example:

User enters calibration mode by pushing 2 buttons at same time.
While in calibration mode user holds down button 1, for 2 seconds.
user releases button.
User then holds down button 1 again for 2.4 seconds.
This is added to 1st time and now have accumlated 4.4 seconds. And so
on.
Now user pushes button 2 which exits calibration mode and stores the
4.4 seconds in EEPROM.
When they press button 1 the relay activates for the time stored in
the EEPROM.
Id like to have at least 1/8 second resolution.
Ive looked allover PIClist and the net and can only find simple
countdown timers.

Has anyone done this before and could share, or can point me to an
example of some code that is similar to this?
Back to top
Kurt Harders
Guest





Posted: Sat Dec 24, 2005 4:21 pm    Post subject: Re: PIC 16f628 Storing time in EEPROM Reply with quote

Hello,

jagrolet@yahoo.com wrote:

Create a timer with 1/8s period and handle the interrupt to count 1/8s
pulses.

Quote:
User enters calibration mode by pushing 2 buttons at same time.
While in calibration mode user holds down button 1, for 2 seconds.
user releases button.

Count the 1/8s pulses during key press.

Quote:
User then holds down button 1 again for 2.4 seconds.

Count again.

Quote:
This is added to 1st time and now have accumlated 4.4 seconds. And so
on.
Now user pushes button 2 which exits calibration mode and stores the
4.4 seconds in EEPROM.

Store the counting result in EEPROM. This allows up to 32s if you use 1
byte for counting. Adding a second byte gives you 8192s, thats more
than 2 hours.

Quote:
Id like to have at least 1/8 second resolution.

Thats the interrupt timeing mentioned above. Timer 0 can give you up to
65ms (256*256), timer 1 can give you 1/8s directly if properly
initialized. See chapter 6 and 7 of the PIC16F627A manual.

Regards, Kurt
--
Kurt Harders
PiN -Präsenz im Netz GITmbH
mailto:news@kurt-harders.de
http://www.pin-gmbh.com
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
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




VoIP Electronics Powered by phpBB