Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/03/09 15:14
Read: times


 
#161273 - Frequency (Event) Counter Problem
Hello sir,
I am implementing a frequency counter. I am using the micro-controller ATMEL AT89C51 24PI 0743(11.0592MHz crystal). Timer1 is used for generating a time delay of 1 sec so that I can count the number of pulses/sec. Timer0 is used for counting the number of external pulses connnected to T0 pin. The contents of TH0 and TL0 are displayed on LCD 16*2 display. Frequency is generated using timer IC 555(astable multivibrator) at 806Hz as seen on CR0.Output of 555 is given to T0 pin.
The following code has been implemented.

        MOV TMOD,#15H      ;TIMER 1 MODE 1
                           ;TIMER 0,MODE 1, C/T=1
LOAD:   MOV R5,#20         ;DELAY OF 1 SEC         
AGAIN:  MOV TL1,#0FDH      ;VALUES LOADED FOR A DELAY OF 0.05 SEC
        MOV TH1,#4BH
        MOV TCON,#50H      ;STARTING BOTH THE TIMERS AT THE SAME TIME
BACK:   JNB TF1,BACK       ;CHECKING FOR TIMER FLAG
        CLR TR1
        CLR TF1  
        DJNZ R5,AGAIN
        CLR TR0            ;STOP TIMER 0
        MOV 60H,TH0
        MOV 61H,TL0    
        MOV TL0,#00H       ;CLEARING THE TIMER
        MOV TH0,#00H     
	ACALL DISPLAY      ;GOES TO DISPLAY ROUTINE TO DISPLAY THE COUNT
        LJMP LOAD



Problem 1-
I am not getting a stable count in TL0.The count in TH0 remains constant(03 in decimal in this case of 806Hz)and the count in TL0 starts from 44 decimal and increments by 1 for every run of the loop.

Problem 2-
I have converted the values of TH0 and TL0 separately to decimal to recalculate the frequency.Thus frequency i.e 3*256+44=812Hz does not match with the external frequency of 806Hz.
Even if I stop the timer by the command 'CLR TR0,the count in TL0 goes on increasing.

Please, could someone help me out by pointing out where I could be going wrong and as to why I am not able to get the precise count for the given frequency. (I have checked on CRO that the 1 sec timer works fine.)


List of 13 messages in thread
TopicAuthorDate
Frequency (Event) Counter Problem            01/01/70 00:00      
   less than 1% error            01/01/70 00:00      
      Error % is incremental.            01/01/70 00:00      
   ;STARTING BOTH THE TIMERS AT THE SAME TIME            01/01/70 00:00      
      Less variations in TL0 but still error            01/01/70 00:00      
         I do not know, but            01/01/70 00:00      
            CRO Frequency Measurement            01/01/70 00:00      
         Better But Still An Issue            01/01/70 00:00      
         How stabile is your signal source?            01/01/70 00:00      
            Very Good Point...            01/01/70 00:00      
               Easier if 89c52 is used            01/01/70 00:00      
            How stabile is your signal source?            01/01/70 00:00      
               NE555 is popular but not a precision device            01/01/70 00:00      

Back to Subject List