Hi Hamid!
Thanks for the question - this is an important issue so I want to give some background on how the FED3 keeps time. FED3 has a real-time clock (RTC) inside keeping time with a quartz crystal, just like a digital watch. And just like a digital watch, this RTC can get out of sync. The RTC we use is the
PCF8523 which can drift up to ~8 seconds per month, so it will need to be reset periodically. There are two ways of doing this:
1. If you just need to set it a few minutes back or forward you can do this on the device itself. Hold both pokes during startup (while mouse is running across the screen) and you will enter a small edit menu where you can set the device # and the RTC. Video demo
here.
2. However, if the clock is several days (or months) out of sync it will be easier to use the "SetClock" example in the FED3 library. This will set the RTC to the local time on your computer. Importantly, as you've discovered, when you then reset the device again with the "SetClock" code on it, it will revert to the time you flashed it, as you're re-running the same "SetClock" code whenever you reset it. So your FED3 is operating as designed, although I understand why this would be confusing.
The solution is to flash "SetClock" and then flash your behavioral code without resetting your device. The behavioral code does not reset the RTC, so it will continue to count up from the time you first flashed "SetClock". So why are your devices ending up out of sync? This depends on how long it takes your computer to flash the FED3, which is not a constant duration (your computer may be busy doing other things so it takes more time for some devices to flash). If it's only a few seconds I wouldn't worry about it, the FED3 is not a precision time-keeping device. But if it's >1 minute you can use the on-board adjustment routine to sync them back up.
Hope this helps!
-Lex