How it works
When you first power the device the clock is mentained for few seconds.
Then the date and temperature will be displayed. The space code of PIC16F84 limited the clock ability with
the decrease option, and also some of the options can't be changed (see below in red),
therefore I advise you to use PIC16F628 (still the downloads number
is higher on PIC16F84 project...). The clock has three buttons, with one button you enter in
set mode, with another button you increase values. In the case of PIC16F628 the third button
will be used to decrease values and for PIC16F84 project the third button resets the device.
The two middle points are not blinking when date/temperature are shown and also when
set mode is on.
You can change:
[Date]
When setting up the day for month take in consideration the month and year and days/that month in that year. You cannot set 31 day for february for example. If you don't want to display the date set td to 0.
[Temperature]
Temperature is taken in the first second when the clock is displayed. If you set 99 seconds for the clock then you'll see the temperature taken 98 seconds before. The device can measure from -55 to +125 °C. If you don't have DS1631 sensor you can set tE to 0 and the temperature will not be displayed. If both td and tE are set to 0 then the time will be the only one displayed. If you want only the clock or temperature, for example, set td to 0.
[Thermostat]
The thermostat function uses a led that is triggered by Tout pin from DS1631 (see schematic layout). When the temperature meets or exceeds thermostat high (th) the termostat is activated. When the temperature goes below thermostat low (tl), the thermostat is deactivated. If tA (thermostat active->03 : default) is set to active high then the led will be on (lit) if temperature exceeds th. If tA is set to active low (01) then the led will be on (lit) if temperature is below tl, in this case the led will be off if temperature goes above th. This allows you to implement any amount of hysteresis into the output response, where the led is connected.
[Clock calibration 1]
The clock can be calibrated through software. This is usefull if the clock lost or gain seconds during a period of time. This can happen for various reasons. The idea is to make the second last longer or less. One second lasts 1000000 microseconds. This is a big number for my display where I can write only 4 numbers, but.. if we represent this number in hexadecimal will have this value: 0F4240.
Calibrations means adjusting around 1000000 so I dropped 0F, you cannot set that, but you can adjust 42(Sh) and 40(Sl) from 00 to FF. This gives you a large posibility to adjust your second. Adjusting examples:
-> lost 30 seconds / 24 hours => 30/86400=0.000347 1000000-(1000000*0.000347)=999653(decimal)=F40E5(hexadecimal)
=> Set 40 for Sh and E5 for Sl.
-> lost 2 seconds / 1 hour => 2/3600=0.000555 1000000-(1000000*0.000555)=999445(decimal)=F4015(hexadecimal)
=> Set 40 for Sh and 15 for Sl.
-> gain 15 seconds / 60 days => 15/5184000=0.000002
1000000+(1000000*0.000555)=1000002(decimal)=F4242(hexadecimal)
=> Set 42 for Sh and 42 for Sl.
A longer the period of time being tested will have a better acuracy for the clock.
[Clock calibration 2]
Other way to calibrate the clock is adjusting Sh and mostly Sl like below. First you need to know two values: one that makes the clock run faster and one that makes the clock run slower. Let's say our two values are:
999840(clock runs faster=FAST) and 999884(clock runs slower=SLOW). Repeat changing the second length to (FAST+SLOW)/2 until FAST=SLOW(+/-1). This should make your clock very accurate.
Note: Do not place DS1631 near heat providers, best thing is to let it float in the air while
is connected through isolated wires. Project using PIC16F84 does not have tt, td, tE, options because it didn't have enough space for the code. For more information about these options see » How it works page.