Tuesday, August 1, 2023

Very Simple Timer with PIC16F18313

Recently I was asked for gerber files for one of my old projects - "Simple Timer with PIC16F628A", but unfortunately the files of that project were lost. I decided to make a new project with more modern and smaller microcontroller - PIC16F18313, which have 8 pin only. To make that possible the display has to be with 2 wire serial communication. I already had such a display - a 4 digit 7 segment module with TM1637, and I already learned how to use it.

Here is the schematic:

The circuit is extremely simple, but it can be simplified even further. If the active buzzer is a piezo type with less than 15 mA consumption, the transistor Q1 can be removed and the buzzer and the LED can be connected directly between the microcontroller pin 3 (RA4) and the ground. Also if the timer is used only for the alarm, the second transistor and the relay can also be scrapped. 

There is a jumper (JP1 that can switch the voltage to the relay circuit between 5V and the input voltage. This is useful if one don't have 5V relay, there can be used 12V or 24V relays instead.
The supply voltage can be between 7 and 30V. When using higher supply voltage the regulator 7805 can get hot so some sort of heatsink may be needed.

Here is the 3D view of the PCB:

I designed the PCB single sided and with only through hole elements so to be easy made at home.

The schematic uses the internal 32 MHz oscillator of the microcontroller - there is no way to connect external crystal - no enough pins for this luxury :) The internal oscillator is good enough in most cases, but there is a way to tune the frequency with the register OSCTUNE to make it more precise. 

As the schematic uses pin4 as input for the Button2, this pin cannot be used as reset pin so when programming the microcontroller the programmer have to use high voltage to initiate the programming.

The operation of the timer is simple: Button1 cycles between four modes: "Idle/Stop", "Edit minutes", "Edit seconds", Timer On. When in "Edit minutes" and "Edit seconds", clicking the Button2 will increase the minutes or the seconds. Long press will trigger repeat function of Button2. Pressing both buttons in "Idle/Stop" will clear the set time, in "Edit minutes" will clear only the minutes and in "Edit seconds" will clear only the seconds. The timer can be set from 1 second up to 99 minutes and 59 seconds. If the set time is 00:00 the timer will count 100 minutes.

The relay contact are connected to the terminal block J1 and can be used to control any external appliance. The relay used in the schematic is something like this: LCSC 
It can switch up to 10A and voltages up to 30VDC or 250VAC. 
Please be careful if using the timer with high voltages and/or high currents!

Here is short video demonstrating how to operate the timer:

Here the archive with all project files: Timer_PIC16F18313

I only test the schematic on a breadboard, so there is always a possibility for errors in the PCB. Check everything for yourself and use the files on your own responsibility.

No comments:

Post a Comment