Summary of Clock ControllerV1.1 using AT89C2051
This article describes the Clock Controller V1.1, an 8051-based digital clock project that controls AC loads via a relay using preset times. It features a 7-segment display for time and a keypad for settings, utilizing Timer0 interrupts and sink current driving for hardware control. The software is available in C for various compilers, including SDCC.
Parts used in the Clock Controller V1.1:
- AT89C2051 microcontroller
- 7-segment common anode LED displays
- 4-PNP transistors (2n2907)
- Electromechanical relay (5V)
- Momentary switches
- Keypad interface components
- SDCC compiler
- Micro-C Compiler
Builda digital clock that turns AC load on/off with preset time. sourcecode with sdcc for 8051.
The Clock Controller V1.1was designed to be an exemplary of using ‘C’ language to control timer0interrupt, 7-segment LED and keypad scanning. It provides 1-bit sink currentdriving output, for driving a relay, opto-triac, say. Many projects requiring7-segment display and keypad interfacing may get the idea from the Clockcircuit and software.
Hardware
Figure 1 shows a circuitdiagram of the Clock Controller V1.1. P10-P1.7 drives 7-segment commonanode LED with sink current. P3.0-P3.3 also drives a base pin of 4-PNPtransistor, 2n2907 with sink current. As shown in the figure, the 2nd 2-digitLED that connected to P3.2 and P3.3 is rotated 180 degrees to the 1st 2-digitallowing the pt. segment to be used for 1 second blinking. P3.0-P3.3 alsoconnects four momentary switches while the other legs are tied to inputport P3.4. During display and key switch scanning, a logic ‘0’ is shiftedfrom P3.0 to P3.3, if there was a key pressed, P3.4 then became low.P3.7 is a 1-bit sink current driving, an example in the circuit uses a2n2907 to drive a small electromechanical relay 5V, say.\
Software
The program clock.cwas written in ‘C’ language and was complied by Micro-C Compiler from DunfiledDevelopment Systems. The memory model is TINY. The hex file of clock.csuitable for downloading by Easy-Downloaderis clock.hex.
The Clock1.cwas modified for C51 compiler. The function that updates real-time clockwas moved into timer0 interrupt service routine. The HEX file is Clock1.hexsmaller than compiled by Micro-C.
I got many requests askingmodification of the source code. Now you can modify the source code byyourself with the free compiler sdcc for 8051. Here is the source codeof new firmware, clock2.c and the hex file, clock2.hex.Please test it and let me know the result. I haven’t tested my hardwareyet, because I cannot find it now. This project is quite long time ago.You may add your code or modify whatever you like to have using sdcc! Youmay download the sdcc here, sdcc.zip.
For more detail: Clock ControllerV1.1 using AT89C2051
- What language is used to write the program?
The program clock.c was written in C language. - How does the circuit drive the relay?
P3.7 acts as a 1-bit sink current driving output connected to a 2n2907 transistor which drives the relay. - Can I modify the source code with SDCC?
Yes, you can modify the source code yourself with the free compiler sdcc for 8051. - Which interrupt service routine updates the real-time clock?
The function that updates the real-time clock was moved into the timer0 interrupt service routine. - How are the key switches scanned?
A logic 0 is shifted from P3.0 to P3.3 during scanning; if a key is pressed, P3.4 becomes low. - What is the purpose of the second 2-digit LED?
The second 2-digit LED is rotated 180 degrees so its pt segment can be used for one-second blinking. - Where can I download the SDCC compiler?
You may download the sdcc from sdcc.zip. - Does the author confirm testing the hardware?
No, the author has not tested the hardware yet because they cannot find it now.