Pages

Thursday, March 31, 2022

A DIY Timer/Scheduler and temperature controller using PIC16F876A

Introduction

A timer is useful in any task that requires a specific time or a duration that the target device will turn on and off. It is easily found at low price. For electronic hobbyists, a timer can easily be created using a typical timer IC NE555 with other dozen of components.

Here I design a timer using a small microcontroller - PIC16F876A. It's suitable to handle timing setting, displaying, controlling, and scheduling. 

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Main menu of this timer

This timer can handle the following tasks:

  1. Main menu - displaying date/time, and temperature
  2. Date/Time setting
  3. Short 16 hours timer
  4. Temperature setting for an output relay
  5. Scheduling daily on time of timer relay

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Day of Week Adjust

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Time Adjust

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Date Adjust

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Short timer up to 16 hours



A DIY Timer/Scheduler and temperature controller using PIC16F876A
Temperature Adjusting for output relay

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Daily On Time Adjusting

Design

Firmware

I use MicroC Pro PIC to program this device. The operation of this device become abnormal whenever I try to add more function in C source code. So I tried to optimize, reduce, and test this project as much as I can to make the operation more stable.

Listing below is the source code for v1.2 of this project.

  1.  
  2. #include "board.h"
  3.  
  4. void main() {
  5. LCD_Set();
  6. DS1307_Init();
  7. T_Init();
  8. TMR0_SETUP();
  9. SCH_READ();
  10. while(1){
  11. Menu_Scan();
  12. Selector();
  13. SCH_RUN();
  14. }
  15. }

We can only see a dozen lines of code, as they are separated in different files. Click here to download firmware and design file.

Hardware

I designed this project using Proteus 8. This program also allow us to simulate.

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Schematic

Circuit board is very simple. It can be made using toner transfer method.

A DIY Timer/Scheduler and temperature controller using PIC16F876A
PCB design view
A DIY Timer/Scheduler and temperature controller using PIC16F876A
Copper track

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Top silk


A DIY Timer/Scheduler and temperature controller using PIC16F876A
Design view in 3D

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Idle

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Top Side

A DIY Timer/Scheduler and temperature controller using PIC16F876A
Bottom Side