Discussion in "Project Doubts" started by    aa6864    Jan 30, 2010.
Sat Jan 30 2010, 10:24 pm
can anyone explain the idea behind codes?at the begining its easy but further it gets hard i dont get the concept!

Sun Jan 31 2010, 01:45 am
you can quote the part of code you find hard to understand. I will make it easy to understand. I hope you have read the theory of operation in download section.

Theory of Operation
As we all know frequency of a signal is number of cycle per second. I made use of this logic to calculate frequency of the input signal.
8051 has two timers, Timer 0 is configured for 1 second delay to sample the input signal and Timer 1 is used as a counter to calculate number of cycles in that 1 second. If timer1 overflows then the overflow is counter in another register which is considered as the high byte of Frequency. Input signal is provided at P3.5/T1 which is input for Timer 1 in counter mode. LCD is connected to microcontroller port 1 in 4-bit mode. Currently program is using 2 Line LCD but it can be used for 1 line LCD too.

Program initializes the Timer0 in 16-bit mode with 50mS delay value, a tick value of 20 is loaded to have total delay of 1s (50 x 20 = 1000 mS). Timer 1 is configured in 16-bit counter mode. After a sample of 1 sec, we get the number of cycles hence the frequency of input signal from timer1 registers (TH1:TL1) and high byte of Frequency. So total 3 byte value is then converted to a decimal equivalent represented in hex. This decimal value is then updated to LCD. The whole process repeats again.

Sun Jan 31 2010, 01:46 am
[Topic moved to Project Doubts forum]
Sun Jan 31 2010, 03:52 pm
i read this at download section.i understand that .you explained the first part of program(in download section) but from disp_num i dont get how it counts frequencyup to 16.5MHZ?(which part shows that it counts from 1HZ to 16.5MHZ?).can you explain the process?for example the purpose of each subroutine.another thing what is the role of XX,YY,ZZ?
another thing i have 89c51 what changes i have to do in assembley code and shematic?

thank you

[ Edited Mon Feb 01 2010, 12:01 pm ]
Tue Feb 02 2010, 05:53 pm
xx yy zz are used in X2D routine which is 4 byte hex to decimal conversion routine.

XX0,XX1,XX2,XX3 is input 4 byte number, YY0,YY1,YY2,YY3 is temporary number used inside X2D routine, and lastly ZZ0,ZZ1,ZZ2,ZZ3 is the o/p BCD number of X2D routine.

TMR0_ISR is used as interrupt service routine for 1 sec timer.
TMR1_ISR is interrupt routine for counting incoming signal frequency.
disp_num to display a number on LCD.
lcd_reset soft reset for LCD.
lcd_init 4-bit lcd initialization routine.
lcd_wait busy flag wait routine.
lcd_cmd to send command to LCD in 4-bit mode.
lcd_dat to send data to LCD in 4-bit mode.
delayms is routine for delay in miliseconds. uses delay variable which tells how much delay needed.
X2D 4-byte hex to BCD conversion.
Tags Frequency Counter using AT89C2051 and LCDFrequency Counter using 8051
Tue Feb 02 2010, 09:36 pm
thanks
another thing when i send frequency more than 500KHZ(the frequency is right until 500KHZ), the LCD shows 300KHZ or something like that and incorrect but in download section you wrote 16.5MHZ. is something wrong in my circuit?

[ Edited Wed Feb 03 2010, 09:16 am ]
Fri Feb 05 2010, 02:11 am
hmm.. strange, are you sending square wave i/p?

### Recent

Ubrat_qwmr
Wed Sep 11 2024, 04:50 am
Raymondelunk
Tue Sep 10 2024, 09:29 pm
WilliamChisk
Tue Sep 10 2024, 08:45 pm
JessePsync
Tue Sep 10 2024, 04:32 pm
Waltergop
Tue Sep 10 2024, 10:24 am
Donnyrap
Tue Sep 10 2024, 06:23 am
kompleksna_qnMt
Mon Sep 09 2024, 10:40 pm
Alcredasem
Mon Sep 09 2024, 09:40 pm