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?
PIC 16f628 Storing time in EEPROM
Started by ●December 24, 2005
Reply by ●December 24, 20052005-12-24
Hello, jagrolet@yahoo.com wrote: Create a timer with 1/8s period and handle the interrupt to count 1/8s pulses.> 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.> User then holds down button 1 again for 2.4 seconds.Count again.> 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.> 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