A PIC16F819 DYMOCLOCK

I wanted to build a clock as simple as possible :
  • built around a little 18 pins PIC
  • no 7 segment display, only LEDs
  • no decoder, no buffer, no driver for the LED display
  • a cheap temperature sensor

The solution of direct LED driving comes from aΒ Microchip Application Note AN234, and as I’m using 25 mA LEDs, I simply removed all current limiting resistors.

A PIC16F819 DYMOCLOCK A silicon diode is used asΒ temperature sensor, and the rest of the circuit is very classic aroundΒ a PIC16F819Β :
Upper row : hours
Middle row : minutes or seconds or degrees C
Lower row : add it to middle row
The wiring side of the LEDs is a little bit messy,

some colored wires are helpful !
See the source code for LED numbering.

THE SOURCE CODE
*************************************************************************
Β * fileΒ Β Β Β Β Β Β Β  : dymoclock.c
Β * projectΒ Β Β Β Β  : Simple LED clock with thermometer
Β * authorΒ Β Β Β Β Β  : Bruno Gavand
Β * compilerΒ Β Β Β  : mikroC V6.0.0.0
Β * dateΒ Β Β Β Β Β Β Β  : september 15, 2006
Β *
Β * descriptionΒ  :
Β *Β Β Β Β Β  This is a 12 hours clock with 27 LEDs display, with a 2Β°C resolution thermometer
Β *
Β * target device :
Β *Β Β Β Β Β  PIC16F819 with 16 Mhz crystal
Β *
Β * configuration bits :
Β *Β Β Β Β Β  HS clock
Β *Β Β Β Β Β  no watchdog
Β *Β Β Β Β Β  no power up timer
Β *Β Β Β Β Β  RA5 as MCLR pin
Β *Β Β Β Β Β  brown out detect
Β *Β Β Β Β Β  LVP disabled
Β *Β Β Β Β Β  data EE protect disabled
Β *Β Β Β Β Β  ICD disabled
Β *Β Β Β Β Β  CCP1 pin on RB2
Β *
Β Β *************************************************************************
Β */
/*
Β * display modes
Β */
#define MODE_HOURMNΒ Β Β Β  0Β Β Β Β Β Β  // display hours:minutes
#define MODE_SSΒ Β Β Β Β Β Β Β  1Β Β Β Β Β Β  // display seconds
#define MODE_TEMPΒ Β Β Β Β Β  2Β Β Β Β Β Β  // display temperature
#define MAX_MODEΒ Β Β Β Β Β Β  3Β Β Β Β Β Β  // number off display modes
/*
Β * buttons
Β */
#define BUTTONΒ Β Β Β Β Β Β Β Β  ((PORTA.F1 == 0)Β  || (PORTA.F2 == 0))Β Β  // at least one
#define BUTTON_MODEΒ Β Β Β  (PORTA.F1 == 0)Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // mode / advance
#define BUTTON_TOGGLEΒ Β  (PORTA.F2 == 0)Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // toggle / valid
#define BUTTON_SETΒ Β Β Β Β  ((PORTA.F1 == 0) && (PORTA.F2 == 0))Β Β Β  // both at the same time
#define TEMP_REFΒ Β Β Β Β Β Β  115Β Β Β Β  // silicon junction offset : 600 mV
#define MAX_TEMPΒ Β Β Β Β Β Β  20Β Β Β Β Β  // number of temperature samples
/*
Β * LED multiplexing tables
Β *
Β * LED indexΒ Β  : 1 2 3 4 5Β  6 7 8Β  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Β * LED numberΒ  : 1 2 3 4 9 10 5 6 11 12 25 30Β  7Β  8Β  5 10 35 40 45 50Β  2Β  1 15 20Β  3Β  4 55
Β * LED hoursΒ Β  : 1 2 3 4 5Β  6 7 8Β  9 10 11 12
Β * LED min/deg :Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  5 10 15 20 25 30 35 40 45 50 55
Β * LED 1234Β Β Β  :Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  1Β  2Β  3Β  4
Β */*
Β * upper row : hours from 1 to 12
Β */
constΒ Β  unsigned char hhTable[] = { 0, 1, 2, 3, 4, 7, 8, 13, 14, 5, 6, 9, 10 } ;
/*
Β * middle row : minutes/seconds/Β°C from 5 to 55 step 5
Β */
constΒ Β  unsigned char mnTableH[] =
Β Β  Β  Β  Β {
Β Β  Β  Β  Β 0, 0, 0, 0, 0,
Β Β  Β  Β  Β 15, 15, 15, 15, 15,
Β Β  Β  Β  Β 16, 16, 16, 16, 16,
Β Β  Β  Β  Β 23, 23, 23, 23, 23,
Β Β  Β  Β  Β 24, 24, 24, 24, 24,
Β Β  Β  Β  Β 11, 11, 11, 11, 11,
Β Β  Β  Β  Β 12, 12, 12, 12, 12,
Β Β  Β  Β  Β 17, 17, 17, 17, 17,
Β Β  Β  Β  Β 18, 18, 18, 18, 18,
Β Β  Β  Β  Β 19, 19, 19, 19, 19,
Β Β  Β  Β  Β 20, 20, 20, 20, 20,
Β Β  Β  Β  Β 27, 27, 27, 27, 27Β Β  Β  Β Β  } ;/*
Β * lower row : increment of minutes/seconds/Β°C from 1 to 4
Β */constΒ Β  unsigned char mnTableL[] =
A PIC16F819 DYMOCLOCK SchematicΒ Β  Β  Β Β  {Β Β  Β  Β Β  0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26,
Β Β  Β  Β  Β 0, 22, 21, 25, 26
Β Β  Β  Β  Β } ;
/*
Β * RAM variables
Β */
unsigned charΒ Β  mode ;Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // display mode
unsigned charΒ Β  toggleMode ;Β Β Β Β Β Β Β Β Β Β Β  // toggle mode flag
unsigned intΒ Β Β  scaler = 0 ;Β Β Β Β Β Β Β Β Β Β Β  // timer overflow divider
unsigned charΒ Β  hh = 1 ;Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // hours
unsigned charΒ Β  mn = 1 ;Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // minutes
unsigned charΒ Β  ss = 0 ;Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // seconds
intΒ Β Β Β Β Β Β Β Β Β Β Β  temp ;Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  // temperature in Β°C
unsigned charΒ Β  tdeg[MAX_TEMP] ;Β Β Β Β Β Β Β  // array of temperatures samples

unsigned charΒ Β  tidx = 0 ;Β Β Β Β Β Β Β Β Β Β Β Β Β  // index of the temperature sample

 

For mroe detail: A PIC16F819 DYMOCLOCKΒ 


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.