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:

  • ho -> hour, from 0 to 23
  • nn -> minutes, from 0 to 59 (I could not display m so I used n twice for it)
  • dd -> date day, from 1 to days/month -> calculated based on month and year
  • dn -> date month (JA FE MA AP MY JU JL AU SE oc no dE -or- 01 02 03 04 05 06 07 08 09 10 11 12, depending on dt setting)
  • dy -> date year, from 0 meaning 2000 to 99 meaning 2099 (not displayed in time/date mode but needed to calculate days per month)
  • dt -> date type can be 1 or 2, if date type equals 1 then letters are used for month, else numbers are used
  • tt -> time in seconds for showing time/clock, from 2 to 99, you cannot set 0 or 1 for this setting (default: 8) (option you cannot change in PIC16F84 project)
  • td -> time in seconds for showing date, from 0 to 99, if 0 is used then the date is not shown (default: 2) (option you cannot change in PIC16F84 project)
  • tE -> time in seconds for showing temperature, from 0 to 99, if 0 is used then the temperature is not shown (default: 3) (option you cannot change in PIC16F84 project)
  • tL -> low thermostat value from 0 to th (thermostat high value) (default: 25)
  • th -> high thermostat value from tl (thermostat low value) to 60 (default: 30)
  • tA -> set thermostat active low (01->increase button) or active high (03->decrease button) (default: 01)
  • Sh -> calibrate the clock by adjusting second high (see below)
  • Sl -> calibrate the clock by adjusting second low (see below)

[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.