Digital Clock. Perry Andrews. A Project By. Based on the PIC16F84A Micro controller. Revision C

Similar documents
Digital (5hz to 500 Khz) Frequency-Meter

Nixie Clock Type Quattro'

Reaction Game Kit MitchElectronics 2019

Nixie Clock Type Frank 2 Z570M

Nixie Clock Type Frank 3

Nixie Clock Kit IN-12B color LED backlit Operation Manual Nixie Clock Kit IN-12B V6.0 ( All Right Reserved 2015 )

ECE 372 Microcontroller Design

7 SEGMENT LED DISPLAY KIT

Assembly Instructions And User Guide. Nixie FunKlock. FunKlock Issue 4 (1 February 2017)

Christmas LED Snowflake Project

PHYS 3322 Modern Laboratory Methods I Digital Devices

ECB DIGITAL ELECTRONICS PROJECT BASED LEARNING PROJECT REPORT ON 7 SEGMENT DIGITAL STOP WATCH USING DECODER

8 PIN PIC PROGRAMMABLE BOARD (DEVELOPMENT BOARD & PROJECT BOARD)

16 Stage Bi-Directional LED Sequencer

35058-TE. PLJ-6LED-A LED Frequency Display Module Manual

Introduction 1. Digital inputs D6 and D7. Battery connects here (red wire to +V, black wire to 0V )

Introduction 1. Green status LED, controlled by output signal ST. Sounder, controlled by output signal Q6. Push switch on input D6

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

Nixie Clock Kit V1.08 Assembly and Operation

DIY KIT MHZ 8-DIGIT FREQUENCY METER

DDS VFO CONSTRUCTION MANUAL. DDS VFO Construction Manual Issue 1.1 Page 1

LED Array Board.

Combo Board.

Keyboard Controlled Scoreboard

Introduction 1. Green status LED, controlled by output signal ST

Total solder points: 117 Difficulty level: beginner advanced. RGB Controller K8088 ILLUSTRATED ASSEMBLY MANUAL

E M E - Antenna Controller System - OE5JFL. Block diagram

Bill of Materials: Super Simple Water Level Control PART NO

ELCT706 MicroLab Session #3 7-segment LEDs and Analog to Digital Conversion. Eng. Salma Hesham

Nixie Tube Clock Type Marsden

Monday 28 January 2013 Morning

N3ZI Digital Dial Manual For kit with Serial LCD Rev 3.04 Aug 2012

ECE 2274 Pre-Lab for Experiment Timer Chip

N3ZI Digital Dial Manual For kit with Backlit LCD Rev 4.00 Jan 2013 PCB

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

uresearch GRAVITECH.US GRAVITECH GROUP Copyright 2007 MicroResearch GRAVITECH GROUP

Laboratory 11. Required Components: Objectives. Introduction. Digital Displays and Logic (modified from lab text by Alciatore)

Light Emitting Diodes (LEDs)

Serial Remote Control of the RX2 SERIAL REMOTE CONTROL FOR THE RX2

Australian Technical Production Services

An Enhanced MM MHz Generator

Data Sheet. Electronic displays

The Micropython Microcontroller

SN-Class Nixie Clock Kits

Embedded Systems. Interfacing PIC with external devices 7-Segment display. Eng. Anis Nazer Second Semester

This Unit may form part of a National Qualification Group Award or may be offered on a free standing basis.

Vorne Industries. 87/719 Analog Input Module User's Manual Industrial Drive Itasca, IL (630) Telefax (630)

Build A Video Switcher

Documentation VFD clock 8 a clock

Alice EduPad Board. User s Guide Version /11/2017

EXPERIMENT #6 DIGITAL BASICS

MONO AMPLIFIER KIT ESSENTIAL INFORMATION. Version 2.2 CREATE YOUR OWN SPEAKER DOCK WITH THIS

WS2815 Intelligent control LED integrated light source

Published in A R DIGITECH

E M E - Antenna Controller System - OE5JFL. Block diagram

Simple PICTIC Commands

Revision 1.2d

Embedded System Training Module ABLab Solutions

ME 515 Mechatronics. Introduction to Digital Electronics

Minimising the tuning drift effects due to external temperature variations in the Titanium Satellite C1W-PLL Wideband LNBF

EPROM pattern generator with "Genlock"

TV Synchronism Generation with PIC Microcontroller

Assembling the BS1/LCD Serial Backpack Kit

Master Time Clock MTC Users Manual

DOGM GRAPHIC SERIES 132x32 DOTS

Digital IC Tester by Using PIC18F4550

Laboratory 8. Digital Circuits - Counter and LED Display

Embedded Systems. Interfacing PIC with external devices 7-Segment display. Eng. Anis Nazer Second Semester

VikiLABS. a g. c dp. Working with 7-segment displays. 1 Single digit displays. July 14, 2017

IOCard Displays II Manual. Date:08/03/17 Rev.:2.3

DEM B SBH-PW-N (A-TOUCH)

Total solder points: 123 Difficulty level: beginner 1. advanced AUDIO ANALYZER K8098. audio gea Give your. . high-tech ILLUSTRATED ASSEMBLY MANUAL

This document is intended to provide information to allow the researcher to build their own device.

21 Channel Light Show PWM LED Controller with Remote Control

SDA 3302 Family. GHz PLL with I 2 C Bus and Four Chip Addresses

Radio Clock with DCF77

Today 3/8/11 Lecture 8 Sequential Logic, Clocks, and Displays

USER'S MANUAL. Getting started with ALEXAN ATMEL AT89C2051/AT89C4051 Training Module - 1

Chapter 3: Sequential Logic Systems

DIY Guide - Building Franky v1.1, the SEGA Audio and Videocard for MSX

Be a part of the circuit. Brick'R'knowledge. Set overview.

FSM User Guide Page 1 of 28

LCD Triplex Drive with COP820CJ

Data Conversion and Lab (17.368) Fall Lecture Outline

Device for a inserting text into a video-signal

International Journal of Innovative Scientific &Engineering Technologies Research 1(2):29-41, December, 2013

COLOUR CHANGING USB LAMP KIT

Operating Manual Ver.1.1

Chapter 11 Sections 1 3 Dr. Iyad Jafar

NORTHWESTERN UNIVERSITY TECHNOLOGICAL INSTITUTE

Review : 2 Release Date : 2019 Last Amendment : 2013 Course Code : SKEE 2742 Procedure Number : PK-UTM-FKE-(0)-10

Integrated Circuit for Musical Instrument Tuners

L, LTC, LTM, LT are registered trademarks of Linear Technology Corporation. Other product

Digital Stopwatch Timer Circuit Using 555timer and CD4033

GEKCO SUBCARRIER REFERENCE OSCILLATOR MODEL SRO10 OPERATION/SERVICE MANUAL

EECS 140 Laboratory Exercise 7 PLD Programming

VU Meter Buffer DIY Kit

Kramer Electronics, Ltd. USER MANUAL. Model: VS x 1 Sequential Video Audio Switcher

ELECTRONIC GAME KIT ESSENTIAL INFORMATION. Version 2.0 BUILD YOUR OWN MEMORY & REACTIONS

Triple RTD. On-board Digital Signal Processor. Linearization RTDs 20 Hz averaged outputs 16-bit precision comparator function.

Transcription:

Digital Clock A Project By Perry Andrews Based on the PIC16F84A Micro controller. Revision C 23 rd January 2011

Contents Contents... 2 Introduction... 2 Design and Development... 3 Construction... 7 Conclusion... 9 References... 9 Figure 1 - Main Flow Diagram... 4 Figure 2 Interrupt Flow Diagram... 5 Figure 3 - Configuration Bit (Fuse) Settings... 6 Figure 4 - Circuit Diagram... 6 Figure 5 - The Completed Project... 9 Table 1 - Parts List... 7 Introduction I wanted to make a desk clock for my desk at work that would show both the time and date. I have a preference for LED displays as they are bright and give a large display. The requirements are: Use LED 7 segment displays. Display both the time and date at the same time. Buttons to set the time and date. Take care of leap years. Fit in a small red translucent box. Clock 84 C Perry Andrews Page 2

Design and Development This project creates a clock for a desk which displays the time and date on ten seven segment displays. The project fits in a small red see-through box. The circuit uses eight outputs for the segments and decimal points, and a 4 line to 10 line decoder (4028B) to select the digit via a transistor. To allow the setting of the time two buttons are provided. The first selects the digit and the second increments the digits. The order is hours, minutes, day, month, year. When the setting mode is active only the digits being set are displayed, all the others are shown as '--'. Before creating the program I listed the steps the program requires: 1. Initialise the PIC and set all digits to zero. 2. Start the timer interrupts to count the seconds elapsed. 3. When seconds reach 60 increment minutes and reset seconds. 4. When minutes reach 60 increment hours and reset minutes. 5. When hours reach 24 increment days and reset hours. 6. When days reach 28 or more increment months and reset days to 1. This is dependant on the current month. 7. When months reach 13 increment years and reset months to 1. 8. When the first button is pressed stop updating the clock, reset all digits to apart from the hours. If the button is pressed again set hours to and display the minutes. Each press moves through the digits. The next press after year displays all digits and restarts the clock. 9. After the first button has been pressed the second button increments the number on the digits. When the digit reaches its intended maximum it returns back to its lowest value. For example, hours rang from 00 to 23. When the digit increments to 24 it returns to 00. It is possible to set an invalid date e.g. 30 th February but this will be corrected when the clock starts the next day. A future revision could fix this issue as it is a matter of setting the years, then month and then day. Knowing the year and month allows you to check the range of days available. Revision A differs from the first version only in the program and this is reflected in the flow charts below. Revision B is a modification to the circuit diagram only, adding the switches and a decoupling capacitor. In Revision C I corrected errors on the drawing and I changed the program to allow it to be compiled by the mikroc compiler. Based on these steps I created a flow diagram to help create the program. Clock 84 C Perry Andrews Page 3

Start Initialise Outputs & timer interrupt Button 1 Pressed? state State = 6? Reset seconds State = 0 Button 2 Pressed? State=1? Hours Hours = 24? Hours=0 State=5? Years Correction = 5400 Decrement seconds scr = 0 Minutes Seconds=0 Hours Minutes=0 Days Hours=0 Seconds=60? Minutes=60? Hours=24? Month=2? Year Month=0 Month=13? Month Days=0 Day>30 or >31? Leap Year? Day>28? Month Days=0 Day>29? Month Days=0 Figure 1 - Main Flow Diagram Clock 84 C Perry Andrews Page 4

Interrupt 400th Inturrupt? Seconds scr = 0 End Interrupt Figure 2 Interrupt Flow Diagram The Main Flow Diagram constitutes the main sub program. After setting up the ports and starting the interrupt the main sub program polls the buttons. With Revision A the counters are incremented and the date calculated. The difficult part to this program is how to deal with months having a different number of days, including February which can have 28 or 29 depending on if it is a leap year or not. The interrupt flow diagram now shows only the seconds being updated. t shown in the flow charts, code is also required to display the digits and to read the inputs. I found in use that the clock gained time as the day went on. After a few days the time difference was noticeable. I calculated that every day 16 seconds were being gained. I decided to setup a new counter that was incremented each second and it would be used to lose a second at the correct moment. I needed to loose 1 second every 24 / 16 = 1.5 hours. This was 5400 seconds (1.5x60x60). When the counter reached 5400 seconds the seconds counter was decreased by 1 and the counter was reset. The clock now keeps very good time. In this project I used MikroC to compile the program. There were two reasons for this. The first was to have a new compiler that supports many different PIC microcontrollers (the C2C version I had only supported 16F84). The second reason was to include the fuse configuration bits in the hex file. When you use a PIC device for the first time (or in a new project) you need to change the configuration bits to make sure it is suitable for the way you are using it. There are only a few on the 16F84/A so this is very simple. In the MikroC IDE you set the configuration bits in the edit project window. This is shown in figure 3 on the next page. If your programmer does not see the configuration bit settings in the hex file you need to manually set them using the window on the following page as a guide. Clock 84 C Perry Andrews Page 5

Figure 3 - Configuration Bit (Fuse) Settings The circuit diagram is more complex because 10 displays are being used. The diagram is shown in figure 4 below: C4 100n 11 3 A3 O0 12 14 A2 O1 13 4028B 2 A1 O2 10 15 A0 O3 9 1 O8 O4 5 6 O9 O5 16 IC2 7 VCC O6 8 4 GND O7 R10/Q2 R11/Q3 R12/Q4 R13/Q5 R14/Q6 R15/Q7 R16/Q8 R9 1K0 Q1 BC337 R17/Q9 R18 1K0 Q10 BC337 R19 100R Set R21 22K +5v R20 100R Inc R22 22K a C3 100n R23 1K0 X1 3.2768MHz C1 10p C2 10p 14 17 6 RA0 VDD RB0 18 7 RA1 RB1 1 16F84A 8 RA2 RB2 2 9 RA3 RB3 3 10 RA4 RB4 4 11 MCLR RB5 16 IC1 12 OSC1 RB6 15 13 OSC2 VSS RB7 5 R1 100R R2 100R R3 100R R4 100R R5 100R R6 100R R7 100R b c d e f g f e a g d b c dp f e a g d b c 0v R8 100R 10 Common Anode Displays Figure 4 - Circuit Diagram The circuit diagram is also supplied as a separate PDF file. Clock 84 C Perry Andrews Page 6

Eight outputs are used to turn the 7 segment and decimal points on and off. The displays are common anode so a port set low turns the segment on and a port set high turns it off. Each of the digits is turned on sequentially. The segments for that digit are only on while that digit is on. This technique is used because 80 outputs would be required to power each individual segment otherwise. We only have five outputs left for the digits but 10 are required. This is where a 4 10 line decoder is used to convert 4 outputs into 10. Each of the digits is powered by a transistor connected to each of these outputs. Construction This project was constructed using Vero strip board, as it is quick to work with. A parts list is shown below: Identifier Description Quantity Maplin Stock Code Vero Strip Board 2 pc 100mm x 60mm JP49D IC1 PIC16F84A 1 VS87U Dual Red LED Displays 5 WL27E IC2 4028 4-10 Decoder 1 QX17T Q1-Q10 BC337 10 QB68Y X1 3.2768MHz Crystal 1 FY86T C1-C2 10pf Capacitors 2 RA33L C3-C4 100nf Capacitor 2 RA49D R9-R18, R23 1K0 Resistor 11 M1K R1-R8, R19-R20 100R Resistor 10 M100R R21-R22 22K Resistor 2 M22K PCB Switch 2 KR88V 18Pin DIL Socket 1 HQ76H 16Pin DIL Socket 1 BL19V Infra-Red Box 112x62x27 1 N70AL Table 1 - Parts List I used a crystal as the timing source because of its accuracy. However I did notice that a certain amount of seconds were gained during the day. This project is constructed on two circuit boards. The top one contains the displays and the two switches. There is not enough room on the boards to link the displays on the top so the displays are linked together on the copper side using stranded insulated wire. This is time consuming and tedious but necessary to fit the project into the box size I wanted. Clock 84 C Perry Andrews Page 7

Once the top board was complete I started on the lower board. This contains all other components including the PIC Micro, 4028 and the transistors. The two sockets were soldered in first followed by the wire links. I then soldered in the transistors before locating the resistors. Usually the resistors are soldered first as they are less prone to damage by excess heat. However, with the transistors in place the resistors were easy to locate. Finally solder in the rest of the components. The copper strips on the two boards are gapped and then connected together. Clock 84 C Perry Andrews Page 8

Figure 5 - The Completed Project Before plugging in the IC s the other components should be tested. This is done using the following procedure. 1. Connect 5v Power supply 2. Measure the voltage and polarity of the pins that supply power to the IC s. 3. Connect the Segment pins to 0v (e.g. link IC1 pins 5 & 6) then connect each digit in turn to 5v (e.g. link IC2 pins 16 & 3 then 16 & 14 etc). The same segment should light on each digit. 4. Repeat step 3 for all other segments. All that was left to do was to plug in the PIC, the 4028 and connect the 5V supply to test. Set the time to an accurate clock and check periodically to see if it gains or looses time. The PIC can then be reprogrammed to make it more accurate. Conclusion There is scope for additional features. Change the program so you cannot set an invalid date. A count up timer could be incorporated using another button. This could use the date display to count up from 0 in hours, minutes and seconds. A world clock can be created. Another additional feature could be to automatically change the clock for daylight saving. At the end of March the clocks go forward 1 hour and at the end of October the clocks go back 1 hour. Countdown until it's time to go home. Countdown timer. Hourly Chime. References MikroElektronika http://www.mikroe.com/eng/home/index/ Development tools and compilers etc. Maplin Electronic Supplies Supplier of all components including the PIC development board. Rapid Online Supplier of components. http://www.pelnet.co.uk/elect/index.html Visit my website for more PIC projects. Clock 84 C Perry Andrews Page 9