Build a simple real-time controller with PIC16F84 running at low power X-tal 32,768Hz. Daily scheduler for 6-channel resided in 64-byte EEPROM can easily be preprogrammed using Nigel PicProg.
RTC2.C provides user programmable set current time without the need of recompilation.
Fixed bug on minute conversion!
IntroductionThe F84 MRTC was my second design of a miniature real-time controller. This version uses PIC16F84 running with a low power X-tal 32,768Hz. The scheduler for 6-channel output was saved in EEPROM. No terminal for serial downloading of the scheduler. It's suitable for fixed scheduler job. Two AA size battery provides +3V backup for clock operation when main power has failed. Time setting at 19:00 is set only once by pressing S1 button. The 6-channel open collector output provides max. 30mA @30V load.
HardwareA circuit diagram of the F84 MRTC is shown in Figure 1. The controller is PIC16F84, Flash based RISC uController running with a low-power X-tal 32,768Hz. The 6-channel output is RB2 to RB7 connected to a 74LS07 open collector buffer providing approx. 30mA @30V suitable for driving a homemade opto-triac shown in Miniature Real-time Controller 2051 version. D1 and D2 forms a simple switch between main supply and +3V battery. As can be seen, D1 may be silicon signal diode 1N914 or 1N4148. D2, however, can use a Ge diode having lower V forward. S1 is a momentary switch when pressed, it set current time to 19:00. The small LED at RB0, indicates functioning of the controller, after reset the blink rate is 1Hz, after press S1 set time to 19:00, it will blink at 1/3Hz or every 3 second.
Figure 1: Circuit Diagram of the F84 Miniature Real-Time Controller.
SoftwareThe original source program for the F84 MRTC was written using 'C', RTC.C with header file RTC.H. The hex file, RTC.HEX was compiled by PICC PCW V2.666. Daily scheduler is resided in 64-byte EEPROM data space. Editing for your scheduler can be made under PicPro by Nigel Goodwin. As shown in Figure 2, each byte may edit and enter into Nigel's Picpro buffer before write the code and EEPROM data into the F84 chip. See details of setting scheduler in RTC.C.
Figure 2: Editing scheduler in 64-byte EEPROM window (physical address is 2100H to 213FH). Example scheduler above turns output 1 and 2 at 19:00 and 19:01, say.
User programmable set time when press S1I got email from Canada asked for difficulty of changing set hour and min when press S1. Because the control program, RTC.C defined both as a constant value. I thought may we need two bytes in eeprom space, say byte 63th and 64th for saving set hour and set min. So who want the other set time instead of 19:00 may change without the need of recompilation easily. As shown the left figure, the physical address is address 213EH and 213FH. The built-in eeprom read function uses read_eeprom(62) and read_eeprom(63) respectively. The modified source program was RTC2.C and the hex file ready for programming was RTC2.HEX. Thus with RTC2.HEX, before write the code, you need to edit what scheduler and set time are.May 5, 2004 found big error! Below files are new firmware that fixed bug on Minute Conversion! I thanks to a friend from Pakistan, Jawed I Bhatti who mailed me and let me know that bug! However I cannot find my board. It was quite long time ago. So please let me know the test.
July 28, 2004 Updated firmware, set all bits of port B to high to turn off devices when S1 was pressed.
July 31, 2004 Modified firmware, disable program scan on Saturday and Sunday by Rollandi Henry Spoornet, ZA. However you must power up on Monday, since reset will set day to 1 or Monday!
Exemplary Application by Rollandi Henry Spoornet, ZA
This project was done for a friend of mine who lives in a complex consisting of 28 units. The automated gate was giving endless problems due to the enormous work rate. During the peak periods [ 06:30 - 08:00 and 16:00 - 17:30] the gate would be opened at least 60- 70 times [per single peak period] .At times the gate would be half closed when someone would exit, this caused the changeover relay contacts to burn and stick resulting in the gate jamming Besides the relays having to be replaced, mechanical wear and tear was also a problem with the gate Rail and gears , having to be replaced.
Then came RTC, the first version was installed and everything worked fine,[The gate would open at 06:45 and close again at 08:30, open at 16:00 and close at 17:30] However there was one Problem, on a Friday evening, a bypass switch had to be activated so that the gate would not open on the Saturday and Sunday and then on the Sunday evening the bypass switch restored to normal so the RTC could function for the duration of the week.
And so RTC evolved and the code modified so it would not activate on a Saturday and Sunday. I am happy to say that since the installation of the RTC the gate has not malfunctioned ..OH!! My friend is also happy He no longer has the problem of the Bypass switch J . Well Almost, there are the public holidays in between, but who knows, perhaps RTC will evolve even more ??
- F84-Programmer Easy-build programmer for PIC16F84.
CreditCircuit diagram of both versions, 89C2051 and PIC16F84 were drawn by my student, Miss Patra Pienchob.
July 28 ,2004