Thursday 5 September 2013

Instrumentation timer using AT89C2051.

Instrumentation Timer using AT89C2051.

The Instrumentation timer was designed to be an exemplary of using 'C' language to control timer0 interrupt, 7-segment LED and keypad scanning. It provides 1-bit sink current driving output, for driving a relay, opto-triac, say. Many projects requiring 7-segment display and keypad interfacing may get the idea from the Clock circuit and software.

Hardware
Figure 1 shows a circuit diagram of the Clock Controller V1.1. P10-P1.7 drives 7-segment common anode LED with sink current. P3.0-P3.3 also drives a base pin of 4-PNP transistor, 2n2907 with sink current. As shown in the figure, the 2nd 2-digit LED that connected to P3.2 and P3.3 is rotated 180 degrees to the 1st 2-digit allowing the pt. segment to be used for 1 second blinking. P3.0-P3.3 also connects four momentary switches while the other legs are tied to input port P3.4. During display and key switch scanning, a logic '0' is shifted from 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 a 2n2907 to drive a small electromechanical relay 5V, say.



Figure 1: Schematic Diagram of the Timer

Software

The program clock.c was written in ‘C’ language and was complied by Micro-C Compiler from Dunfiled Development Systems. The memory model is TINY. The hex file of clock.c suitable for downloading by Easy-Downloader is clock.hex.
The Clock1.c was modified for C51 compiler. The function that updates real-time clock was moved into timer0 interrupt service routine. The HEX file is Clock1.hex smaller than compiled by Micro-C.
I got many requests asking modification of the source code. Now you can modify the source code by yourself with the free compiler sdcc for 8051. Here is the source code of new firmware, clock2.c and the hex file, clock2.hex. Please test it and let me know the result. I haven't tested my hardware yet, 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! You may download the sdcc here, sdcc.zip.

Practice

  • The function time( ) in clock.c was not put in the timer0 service routine, there's a bit delay at scanLED( ) function making the clock delay, try write a function that make adjustment of the clock.
  • With C51 compiler, there's a space for more functions to put in, write a function that saves a second time on and off.
  • Heavy Load Driving

    I suggest to use a zero switch solid-state relay for driving heavy loads (>10A). Most solid state relay's input can be driven with 3-30Vdc without any problems. 

    No comments:

    Post a Comment