PIC 16f628 Storing time in EEPROM

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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?

2 buttons Port A,2-3
1 relay    Port A,0


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
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
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?

Re: PIC 16f628 Storing time in EEPROM

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

Quoted text here. Click to load it

Count the 1/8s pulses during key press.

Quoted text here. Click to load it

Count again.

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.

Quoted text here. Click to load it

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
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline