Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

frequency counting withAT89C51 using C

Status
Not open for further replies.

anilmudulakar

New Member
this is my final year project and iam facing problem with counting the three different frequency from an rf souce...
my purpose is for each frequency i have to perform different task..
some body pls help me to wirte a code in c for atmel 89c51 microcontroller..
 
RF Frequency Detection

I don't think that the processor can detect RF frequencies directly. I'm guessing that you will need some kind of RF front end to convert the signals to a useable range. This may be easy or hard depending on the RF frequency and how wide a band the three frequencies occupy. Can you supply more details?
 
thank u the helphand..
the frequency range is each 1kz distinct from each other. i.e 1kz, 2kz and 3kz respectively..after reading ur responce i practically checked on the bread board u were right... now iam using a audio amplifier made around TBA810 ic and the controller is giving responce to the rf frequency.. but not accurately... i mean it is detecting the signals but not performing the desired task.. iam connecting the input to the microcontroller to pin.no 14 of AT89C51 through 1 pf capacitor. if capacitor is not used the controlleris getting over heated.
 
anilmudulakar said:
thank u the helphand..
the frequency range is each 1kz distinct from each other. i.e 1kz, 2kz and 3kz respectively..after reading ur responce i practically checked on the bread board u were right... now iam using a audio amplifier made around TBA810 ic and the controller is giving responce to the rf frequency.. but not accurately... i mean it is detecting the signals but not performing the desired task.. iam connecting the input to the microcontroller to pin.no 14 of AT89C51 through 1 pf capacitor. if capacitor is not used the controlleris getting over heated.

Your posts are just too confusing?, you mention 1KHz, 2Khz and 3KHz (which are low audio frequenqcies), you mention a TBA810 (an EXTREMELY old audio amplifier chip), then start mentioning RF frequencies?.

Also, a 1pF capacitor isn't much use for most RF purposes, and is completely useless at audio frequencies.

Try and be more specific!.
 
yess sir...
TBA810 is utterly very old audio amplifier... but iam getting responses from microcontroller.... i have tested soo with the assembly language provided in "the 8051 microcontroller by kenneth j.ayala", but the program is so confusing and can count upto 500kH... but my purpose is to just the low frequencies ranging from 1kH to 5kh.. i just want the program in C to count these frequencies...
thank u sir...
 
anilmudulakar said:
yess sir...
TBA810 is utterly very old audio amplifier... but iam getting responses from microcontroller.... i have tested soo with the assembly language provided in "the 8051 microcontroller by kenneth j.ayala", but the program is so confusing and can count upto 500kH... but my purpose is to just the low frequencies ranging from 1kH to 5kh.. i just want the program in C to count these frequencies...
thank u sir...

I can't help you with C, or an AT89C51, as I use neither of them - but you don't stand a chance if you're using a 1pF coupling capacitor, it must be MUCH, MUCH larger - try 0.1uF or higher.
 
thanks for thr suggestion of 0.1mf capacitor.... iam getting more sensible responce.... thank for that....
i request every one ...if possible pls help me to solve my problem..
iam getting frequency till the controller...only thing i have to do is writing the code for counting the frequency ranging from 1kh to 5 kh or even for from 1kh to 10 kh...thank u.
 
Without an adequate schematic diagram it will be difficult, if not impossible, to help you further. I consider it extremely risky to couple the output of an amplifier to the microcomputer with a capacitor. In 40 years as a design engineer I've never seen or heard of this being done. The makers of microcontrollers are very specific about not letting ANY input go more than 0.3 volts below ground. How does your circuit guarantee this, may I ask?
 
Papabravo said:
Without an adequate schematic diagram it will be difficult, if not impossible, to help you further. I consider it extremely risky to couple the output of an amplifier to the microcomputer with a capacitor. In 40 years as a design engineer I've never seen or heard of this being done. The makers of microcontrollers are very specific about not letting ANY input go more than 0.3 volts below ground. How does your circuit guarantee this, may I ask?

A PIC does so by it's internal clamping diodes, obviously requiring a series resistor to limit current - presumably this is what he's doing?. Personally I would prefer to see the input squared more precisely by a schmitt trigger or comparator so you get a really nice square wave.

I don't know if his processor has clamping diodes or not?.
 
sir if u dont feel so.....
anil is asking for program not the schematic and the circuit
.....only program
the thing is that using tba810 i have interfaced the fm signal to at89c51 pin 14 i.e t0 through 0.1uf, even i was getting response from mc, the other thing is that i did project on three different frequencies more r less like anil is doing now. using multivibrator and connecting it to fm transmitter and receiving back through fm radio module and then amplified by tba810 through which it is fed to microcontroller through 0.1uf. the thing is that i got the result but not accurrately on all frequencies
 
the coding is in asm language even i need the same and accurate code in c
the coding is ....
frqflg equ 0fh
freq:
org 0000h
mov sp,#30h
sjmp over

org 001bh
setb psw.3
inc r0
cjne r0,#00h,checktime
inc r1

checktime:
cjne r1,#03h,goback
cjne r0,#0e8h,goback
clr tr0

clr tr1;
setb frqflg

goback:

clr psw.3
reti

over:
mov tcon,#00h
setb psw.3
mov r0,#00h
mov r1,#00h
clr psw.3
mov tmod,#25h
mov tl1,#9ch
mov th1,#9ch
mov tl0,#00h
mov th0,#00h
clr frqflg
mov tcon,#50h
mov ie,#88h

simulate:
jbc frqflg,getfrq
sjmp simulate

getfrq:
mov r0,#000h
mov p2,r0
mov p1,r0
mov a,th0
jb acc.4,fr
jnb acc.4,next
next:
jb acc.3,fr
jnb acc.3,go0
go0:
jb acc.2,fr
jnb acc.2,forw
forw:
//cjne a,#00h,fr
jb acc.1,sr
jnb acc.1,k
k:

/* new1:
cjne a,#00h,fr*/
sjmp over

/* k:ljmp tr
next0:
mov a,tl0
jb acc.7,k1
k1:
ljmp tr
jnb acc.7,go1
go1:
jb acc.6,sr
jnb acc.6,k2
k2:ljmp tr */

fr:
acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov a,#001h
mov p2,a
acall delayan
mov p2,r0
mov r3,#001h
track0:
acall delayan
mov a,#004h
mov p2,a
acall delayan1
mov p2,r0
djnz r3,track0

acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov r5,#002h
close0: mov a,#001h
mov p2,a
acall delayan
acall delayan
mov p2,r0
acall delayan
acall delayan
djnz r5,close0
ljmp over

sr:
acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov a,#001h
mov p2,a
acall delayan
mov p2,r0
mov r3,#002h
track1:
acall delayan
mov a,#004h
mov p2,a
acall delayan1
mov p2,r0
djnz r3,track1

acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov r5,#002h
close1: mov a,#001h
mov p2,a
acall delayan
acall delayan
mov p2,r0
acall delayan
acall delayan
djnz r5,close1
ljmp over

/*tr:
acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov a,#001h
mov p2,a
acall delayan
mov p2,r0
mov r3,#003h
track2:
acall delayan
mov a,#004h
mov p2,a
acall delayan1
mov p2,r0
djnz r3,track2

acall delayan
mov a,#002h
mov p2,a
acall delayan
mov p2,r0
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
acall delayan
mov r5,#002h
close2: mov a,#001h
mov p2,a
acall delayan
acall delayan
mov p2,r0
acall delayan
acall delayan
djnz r5,close2
ljmp over */


delay:
// mov r4,#0ffh
// mov r3,#0ffh
// d0:djnz r4,d0
// d1:djnz r3,d1
ret

delayan: ;antifast delay
push 00h
push 01h
push 04h
push 0f0h
//mov b,r4
mov r6,#0ffh
loop4: mov r0,#0fh
loop2: mov r1,#0ffh
loop3: djnz r1,loop3
djnz r0,loop2
djnz r6,loop4
pop 0f0h
pop 04h
pop 01h
pop 00h
ret


delayan1: ;antifast delay
push 00h
push 01h
push 04h
push 0f0h
//mov b,r4
mov r6,#0ffh
loop8: mov r0,#01h
loop5: mov r1,#0ffh
loop6: djnz r1,loop6
djnz r0,loop5
djnz r6,loop8
pop 0f0h
pop 04h
pop 01h
pop 00h
ret
end
 
thanku sir....
u people are struggling for me a lot... i will be really thankfull to u if i get my program in c ...
thanku very much...
 
actual problem is i dont understand the assembly coding....
any ways mr. mudassir thanks for the effort....
and i request the senior members of the group help me out of my problem...
thank u....
 
Loading timer0 in order to find the frequency, hmm, and you need C code have you seen "Interfacing with C" by Howard Hutchings. I think you may need to revise the input circuit maybe a serial shift register.
 
Help

Yet another exanple of students not doing their own coarse-work......... What were you doing when everybody else in your class were learning.......

If you pass this exam you will have done so by cheating......... I would not think you will do well in the REAL world when you get a job...........
 
microcontroller

gaurav1985 said:
this is my 6 month training project and i want to run a stepper motor using atmel 89c51 using assembly language programming. i also want to use remote sensor. when ir detecter transmit signals then receiver receive these which is connected to microcontroller. and microcontroller programming is done in such a way wahen receive signals then stepper motor starts work according to programming.
had any one work on this. plz help me and tell how i can implement it. tell program which can work in assembly language.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top