Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Frequency Measurement using pic16F877A

Frequency meter using pic16f877a
It will count actual frequency of a wave and displays on LCD[]
Schematic is attached for connection diagram


sheematic.png




Compiler CCS Pic C compiler

Code .......................................................................................

#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)
#define LCD_ENABLE_PIN PIN_B3 ////
#define LCD_RS_PIN PIN_B1 ////
#define LCD_RW_PIN PIN_B2 ////
#define LCD_DATA4 PIN_B4 ////
#define LCD_DATA5 PIN_B5 ////
#define LCD_DATA6 PIN_B6 ////
#define LCD_DATA7 PIN_B7
#include <lcd.c>
#BYTE trisb = 0x86

int8 n1=0,frequency;
#int_EXT
void EXT_isr(void)
{

frequency = frequency+1;
}

#int_TIMER1
void TIMER1_isr(void)
{
n1=n1+1;
if(n1==5){
n1=0;
lcd_gotoxy(1 2);
printf(lcd_putc ,"frequency = %d" , frequency);
frequency=0;
}
#asm
bcf 0x0B , 1 ///////// Clear external interrupt flag
#endasm
set_timer1(15536);
}
void main(void) {
lcd_init();
delay_ms(500);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
#asm
bsf 0x03 , 5 //////////Bank 1
bsf trisb ,0
bcf 0x03 , 5 //////////Bank 0
bcf 0x0B , 1 ///////// Clear external interrupt flag
#endasm

enable_interrupts(INT_EXT);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
lcd_gotoxy(1 1);
printf(lcd_putc , "Frequency Meter");
frequency=0;
set_timer1(15536);

while(1){};

}

Comments

Can you please explain your concept,

By External Interrupt you are counting pulses and incrementing Frequency variable.

How you are using Timer.??
 
xpress_embedo;bt2363 said:
Can you please explain your concept,

By External Interrupt you are counting pulses and incrementing Frequency variable.

How you are using Timer.??


It is very simple i am counting time of one second using timer and after each second i am calculating total pulses count that is actual frequency
 

Part and Inventory Search

Blog entry information

Author
M.Imran Ali
Views
1,301
Comments
3
Last update

Downloads

  • DSN.rar
    5.8 KB · Views: 908

More entries in Uncategorized

Share this entry

Back
Top