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



Labels

ADC (10) Analog (14) Arduino (12) Atmega16 (19) Audio (2) AVR (20) Charger (1) Cortex-M0 (1) Counter (10) CPLD (25) Digital I/O (22) Display (34) EEPROM (2) Environment Sensor (1) esp8266 (2) Experiment Board (10) I2C (4) Interrupt (7) LCD (1) LDmicro (29) measurement and instrumentation (7) Microchip Studio (3) MikroC (1) One-Shot (3) OpAmp (1) PCB (31) PIC16 Microcontrollers (16) PIC16F877A (2) PIC16F887 MikroC (22) PLC (35) PWM (11) Regulator (1) RTC (2) Sensor (8) Shift Registers (5) SPI (5) Timer (34) UART (2) ultra-sonic sensor (1) USB (1) VHDL (21) xc8 (1) XC95108 (9) XC9536 (15) XC9572 (1) Xilinx (23) Xilinx ISE (22)