electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

8051 - calculating the value of frequency by using counter


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> 8051 - calculating the value of frequency by using counter
Author Message
ecestar



Joined: 01 May 2009
Posts: 10


Post01 May 2009 23:53   

8051


hello
can any one helpe me about who can i calculate the value of frequency by using counter
if i want to input frequency to the microcontro then i want to now what is the value of it .
please i need code to do that and any information about it .
Back to top
nandhu015



Joined: 11 Feb 2006
Posts: 641
Helped: 46
Location: Tamilnadu, India


Post02 May 2009 4:15   

Re: 8051


Hai

Use interrupt to on the timer and off timer

then u can easily calculate the frequency with the formula 1/time

Regards
Nandhu
Back to top
ctownsend



Joined: 27 Nov 2004
Posts: 301
Helped: 21
Location: Canada


Post02 May 2009 12:03   

Re: 8051


ecestar wrote:
hello
can any one helpe me about who can i calculate the value of frequency by using counter
if i want to input frequency to the microcontro then i want to now what is the value of it .
please i need code to do that and any information about it .


There is source code and an example in the Kenneth Ayala 8051 book. Google it.
Back to top
ecestar



Joined: 01 May 2009
Posts: 10


Post02 May 2009 12:15   

Re: 8051


How can i Use interrupt to on the timer and off timer

to calculate the frequency with the formula 1/time
please i need example to explan that with code
Crying or Very sad
Back to top
herlambang



Joined: 20 Apr 2009
Posts: 66
Helped: 1


Post18 May 2009 18:00   

8051


did you mean a frequency counter?
you want use C or assembly?
Back to top
ecestar



Joined: 01 May 2009
Posts: 10


Post18 May 2009 20:48   

Re: 8051


herlambang wrote:
did you mean a frequency counter?
you want use C or assembly?


yes with c language please if you can
Back to top
herlambang



Joined: 20 Apr 2009
Posts: 66
Helped: 1


Post19 May 2009 16:04   

Re: 8051


ecestar wrote:
herlambang wrote:
did you mean a frequency counter?
you want use C or assembly?


yes with c language please if you can


Okay my friend that's no problem but..
because I'am busy now, please wait for a couple days..
I'll prepare it for you.
Back to top
ecestar



Joined: 01 May 2009
Posts: 10


Post19 May 2009 23:59   

Re: 8051


herlambang wrote:
ecestar wrote:
herlambang wrote:
did you mean a frequency counter?
you want use C or assembly?


yes with c language please if you can


Okay my friend that's no problem but..
because I'am busy now, please wait for a couple days..
I'll prepare it for you.



ok i am waiting
Back to top
herlambang



Joined: 20 Apr 2009
Posts: 66
Helped: 1


Post20 May 2009 14:35   

Re: 8051


Hi..
This is the basic one..
You can learn about basic freq. counter on 8051 microcontroller.
This is not the perfect one but it's good for learning purpose. In attachment file included Proteus ISIS simulation for easy debugging. If you want to build on the real hardware, you must modify the schematics on ISIS to meet your requirements such as display and another hardware.

I hope it's can help you..

Regards,

Herlambang.



Sorry, but you need login in to view this attachment

Back to top
ecestar



Joined: 01 May 2009
Posts: 10


Post20 May 2009 23:57   

Re: 8051


thank you very much

and now i have idea about frequency counter

and now if i want to display 25 on the lcd when the frequency value is 500HZ
and 40 when the frequency value is 5kHZ.

SO how can i change the program to do that .

and now i work with my code but i have problem to get the resulte

so i need your helpe


thanks,

Added after 1 hours 11 minutes:

and this is my code

but i want to define the range in it and display more than one number in the lcd because now i have problem to display more than one like 1 (49 in ascii code) so what can i do if i want to display 11 or 12 or any two number and this is my code

/*---------------------------------------------------------
---------------------------------------------------------*/
#include <reg66x.h>
#include <reg52.h>
#include <stdio.h>
#define NewLine 0xc0
#define ClrDisp 0x01
#define TwoLine10dots 0x38
#define ScrOnCurOffBlinkOff 0x0F
#define IncCurDntMovDis 0x06
#define OUT P1


int check ;
sbit BusyFlag=P1^7;
sbit RS =P3^5;
sbit RW =P3^6;
sbit E =P3^7;
sbit ref =P2^2;


/*---------------------------------------------------------
Timer 0 Overflow Interrupt
---------------------------------------------------------*/
unsigned long tt ;
unsigned long t;

void T0_ISR (void) interrupt 1
{
TF0 = 0;
// Reset the interrupt request

}


/*---------------------------------------------------------
MAIN C function
---------------------------------------------------------*/

/*---------------------------------------------------------
---------------------------------------------------------*/
int calcul(){
int t;
if((tt<=5678)&&(tt>=4689)){
t=49;
}

if((tt<=4689)&&(tt>=3456)){
t=50;
}
if((tt<=2800)&&(tt>=1200)){
t=51;
}

return t;
}



void freqcheck (void){
{
check=calcul() ;
}
//else {
//check ='A' ;
//}
}
}
void checkBusy(void){


OUT=0XFF ;
do{ ;
E =0;
RS =0;
RW =1;
E =1;
}while(BusyFlag);
E=0;
RW = 0;
}

void sendCmd (unsigned char Cmd){
checkBusy();
RS = 0;
RW = 0;

OUT = Cmd;
E =1;
E =0;
}
void sendData (unsigned char ch){
checkBusy();
RS = 1;
RW = 0;
OUT=ch;
E = 1;
E = 0;
}
void init_LCD (void){
sendCmd(TwoLine10dots);
sendCmd(ScrOnCurOffBlinkOff);
sendCmd(IncCurDntMovDis);

}
void main (void)
{
/*--------------------------------------
Set serial port for 9600 baud at
11.0592 MHz. Note that we use Timer 1
for the baud rate generator.
--------------------------------------*/
SCON = 0x50;
PCON =0x00;
TH1 = 0xFA;
TL1 = 0xFA;
TR1 = 1;
TI = 1 ;







/*--------------------------------------
Enable interrupts for timer 0.
--------------------------------------*/
ET0 = 1;
EA = 1;

/*--------------------------------------
Set Timer0 for 16-bit interval timer
mode.
--------------------------------------*/
TMOD = 0x21;

while (1)
{
/*--------------------------------------
Clear the timer overflow counter and
the timer low and high registers. Then,
start the timer.
--------------------------------------*/
TH0 = 0;
TL0 = 0;

TR0 = 1;


/*--------------------------------------
Wait for the pulse to start.
Then, wait for the pulse to end.
--------------------------------------*/
while (!INT0);
while (INT0);

/*--------------------------------------
Compute the width of the pulse -- one
clock cycle is 1us for a standard 8051
and display it.
--------------------------------------*/
init_LCD();
sendCmd(ClrDisp);
freqcheck();
sendData(check);
sendCmd(NewLine);
printf ("%1d\n",tt=(unsigned long)(TH0*256)+TL0) ;


for(t=0;t<100000;t++);

}



}
Back to top
h_waqasahmed



Joined: 19 May 2009
Posts: 1


Post22 May 2009 6:28   

8051


can anybody give me the 8051 programmer circuit which is tested by anyone and it's software
Back to top
pranam77



Joined: 22 Apr 2008
Posts: 1071
Helped: 94
Location: Mangalore(India)


Post22 May 2009 16:27   

Re: 8051


h_waqasahmed wrote:
can anybody give me the 8051 programmer circuit which is tested by anyone and it's software


Post your request under new post, so that some one can really help you out. Goodluck
Back to top
peliasperro



Joined: 19 Jul 2009
Posts: 2


Post19 Jul 2009 9:29   

8051


¿Alguién puede indicarme como puedo hacer un frecuencímetro en ASM?
La señal la paso por un conversor A/D y necesito conocer la frecuencia y el Ton para poder visualizar en un lcd.
¿Cómo paso del valor de los registros a valor en LCD?
Un saldo y gracias
Back to top
ark5230



Joined: 29 Jun 2009
Posts: 188
Helped: 15
Location: India


Post19 Jul 2009 19:54   

8051


Here is a link for ISP programmer requeste by h_waqasahmed

http://www.kmitl.ac.th/~kswichit/IspPgm30a/ISP-Pgm30a.html

or this one

http://www.geocities.com/ddsaproject/electronics/8031-ah/at89s_min_sys.html
Back to top
osoenbolsa



Joined: 20 Jul 2009
Posts: 4
Location: Spain


Post20 Jul 2009 21:25   

Re: 8051


can any one helpe me about who can i calculate the value of frequency by using counter
if i want to input frequency to the microcontro then i want to now what is the value of it .
please i need code to do that and any information about it.

I need code in asm languaje.

I need pass the values of tl1,th1 y r3 (ej.asm) to Hz.

Thanks

Added after 1 minutes:

This is my example code (ej.asm)

ORIGIN 0000H
JMP INICIO


ORIGIN 8200H



*******************************************************
*********INICIALIZACION DEL LCD************************
*******************************************************

INICIO: CALL TIEMPO
MOV A,#38H
CALL ESCI_1
CALL TIEMPO
CALL ESCI_1
CALL TIEMPO
CALL ESCI

CALL ESCI
MOV A,#08H
CALL ESCI
MOV A,#01H
CALL ESCI
MOV A,#06H
CALL ESCI
MOV A,#0FH
CALL ESCI










*************MUESTRA EL PRIMER MENSAJE*******************
*********************************************************

MOV DPTR,#B000H
MENS1: MOV A,#00H
MOVC A,@A+DPTR
CALL ESCD
INC DPTR
MOV A,DPL
CJNE A,#05H,MENS1



MOV A,#86H
CALL ESCI







************VALORES DE EJEMLPO PARA COMPROBAR FUNCIONAMIENTO****************
************INCPOS PASA DE HEXADECIMAL A BCD********************************

CLR 21H
MOV TL1,#38H
MOV TH1,#42H
MOV R3,#0FH



INCPOS EQU C000H

MOV 60H,TL1

MOV DPH,#D0H
MOV DPL,#00H

MOV 50H,#01H
MOV 51H,#04H

CALL INCPOS

MOV 50H,#02H
MOV 51H,#03H

CALL INCPOS

MOV 50H,#03H
MOV 51H,#01H

CALL INCPOS


MOV 60H,TH1

MOV DPH,#D0H
MOV DPL,#0DH


MOV 50H,#03H
MOV 51H,#02H

CALL INCPOS

MOV 50H,#04H
MOV 51H,#04H

CALL INCPOS

MOV 50H,#05H
MOV 51H,#02H

CALL INCPOS

MOV 60H,R3

MOV DPH,#D0H
MOV DPL,#2DH


MOV 50H,#05H
MOV 51H,#01H

CALL INCPOS

MOV 50H,#06H
MOV 51H,#03H

CALL INCPOS

MOV 50H,#07H
MOV 51H,#04H

CALL INCPOS





**********************ESCRIBE EL VALOR DEL TH1,TL1 Y R3 EN EL LCD***************

MOV A,39H
ADD A,#30H
CALL ESCD

MOV A,38H
JNZ S
JMP S11
S: SETB 21.2H
S11: ADD A,#30H
CALL ESCD

JNB 21.2H,SEG
MOV A,#'.'
CALL ESCD


SEG: MOV A,37H
ADD A,#30H
CALL ESCD

MOV A,36H
ADD A,#30H
CALL ESCD

MOV A,35H
JNZ MS
JMP SMS
MS: SETB 21.1H
SMS ADD A,#30H
CALL ESCD
JB 21.2H,SEG1
JNB 21.1H,SEG1
MOV A,#'.'
CALL ESCD



SEG1: MOV A,34H
ADD A,#30H
CALL ESCD

MOV A,33H
ADD A,#30H
CALL ESCD


MOV A,32H
ADD A,#30H
CALL ESCD



JB 21.2H,SEGUNDO
JB 21.1H,MILISEG
JMP US

US: MOV A,#'U'
CALL ESCD
MOV A,#'s'
CALL ESCD
JMP FINI


MILISEG:MOV A,#'m'
CALL ESCD
MOV A,#'s'
CALL ESCD
JMP FINI

SEGUNDO:MOV A,#'s'
CALL ESCD
JMP FINI


















FINI: JMP FIN
FIN: JMP FIN


********************SUBRUTINAS DEL LCD***********************
*************************************************************


ORIGIN 9450H
ESCI_1: MOV DPTR,#4000H
MOVX @DPTR,A
RET



ORIGIN 9500H
ESCI: MOV DPTR,#4000H
MOVX @DPTR,A
CALL CHEQUE
RET


ORIGIN 9550H
CHEQUE: MOV DPTR,#4002H
OCUPA: MOVX A,@DPTR
JB A.7,OCUPA
RET



ORIGIN 9600H
ESCD: PUSH DPL
PUSH DPH
MOV DPTR,#4001H
MOVX @DPTR,A
CALL CHEQUE
POP DPH
POP DPL
RET


ORIGIN 9650H
TIEMPO: MOV R7,#50
S1: MOV R6,#17
S2: DJNZ R6,S2
DJNZ R7,S1
RET

***********MENSAJE*************

ORIGIN B000H

BYTE 'TON: '


*****************************************************
******RUTINA INCPOS: pASA DE HEXADECIMAL A BCD******
*****************************************************

ORIGIN C000H

CLR 20H.0
SIGBIT: MOV C,20.0H
MOV A,60H
RRC A
MOV 60H,A
MOV 20.0H,C
MOV R1,50H
JC A_UNO
PUSH A
MOV A,DPL
ADD A,50H
MOV DPL,A
POP A

OTROBIT:DJNZ 51H,SIGBIT
RET

A_UNO: MOV R0,#32H
OTRAVEZ:CLR A
MOVC A,@A+DPTR

INCDIGIT:CJNE A,#00H,INCMAS2
JMP FINDIGIT

INCMAS2:DEC A
CJNE @R0,#09H,INCR0
MOV 61H,R0

INCMAS: MOV @R0,#00H
INC R0
CJNE @R0,#09H,INCR02

INCR02: INC @R0
MOV R0,61H
JMP INCDIGIT

INCR0: INC @R0
JMP INCDIGIT

FINDIGIT:INC DPL

DJNZ R1,OTRAV
JMP OTROBIT

OTRAV: INC R0
JMP OTRAVEZ


************************************************************
*************TABLA CON LOS PESOS DE CADA POSICION***********
************************************************************

ORIGIN D000H
BYTE 1,2,4,8,6,1,2,3,4,6,8,2,1,6,5,2,2,1,5,4,2,0,1
BYTE 8,4,0,2,6,9,0,4,2,9,1,8,4,8,3,6,1,8,6,7,2,3,6
BYTE 3,5,5,6,2,7,0,1,3,1,4,4,1,2,6,2,8,8,2,4,2,5,6
BYTE 7,5,8,4,0,1,2,5,1,7,9,0,2,4,0,3,4,9,1,4,8,0,6
BYTE 8,8,3,8

END
Back to top
bobsanjose



Joined: 13 Jan 2006
Posts: 265
Helped: 25
Location: SF-Bay


Post24 Jul 2009 5:21   

8051


@osoenbolsa,
I disagree with your needs. You don't need code, you need to improve your understanding of what you are doing and it would also help if you improve your English skills. This group has lots of very nice people and I am not an English native speaker either, however I try to do my homework first and then ask for help if I can't get it done.
Your problem is so basic, it does sound like homework of some school and you are the one that is supposed to get it done!
No offense, Bob
Back to top
Google
AdSense
Google Adsense




Post24 Jul 2009 5:21   

Ads




Back to top
madicalphy



Joined: 22 Jul 2007
Posts: 68
Helped: 3


Post30 Oct 2009 9:25   

Re: 8051 - calculating the value of frequency by using count


frequency counter and led display of counts , for further information
http://microcontroller51.blogspot.com/2009/09/programmable-frequency-meter.html
Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> 8051 - calculating the value of frequency by using counter
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
frequency counter using 8051? (3)
counter value detection using edges (6)
the way of calculating the value of resistor (4)
Calculating the (real) peak value of a set of points (3)
Freq counter using 8051... (10)
Up down counter on using 8051 Microcintroller (9)
frequency counter using at89s51 (5)
Frequency Counter using PIC16F872 (10)
frequency counter using atmega8 (8)
Frequency counter using ICM7216 needed (13)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS