Make a Frequency Meter with PIC16F73

Published by MKDas on

When you are working with electronics, specially power electronics you must have to measure line frequency. But most of the cases people do not have a frequency meter. If you knew how to make a frequency meter in a very easy way, you would make one for yourself. Here in this article, we’ll learn how to make a frequency meter with PIC16F73 general purpose micro-controller and LCD display. Using a multi-meter is ok to measure frequency but many people do not have a multimeter with frequency meter or sometimes, you need to attach a meter onboard not a multi-meter. Considering these issues, making a frequency meter yourself may become very helpful.

Disclaimer: Electricity is always dangerous. Skill required to work with electricity. Do work with your own risk. Author will not be responsible for any misuse or harmful act. This website contents is also copyright protected. Anything copied and directly posted in your website and claiming it as yours is prohibited and nonsensical. Author published all the articles as opensource to help you making your project and learning purpose only. Learn and make one for yourself. If need any help feel free to ask the author. Author will be helpful to you. Thanks.

What is frequency meter?

A frequency meter is an instrument that displays the frequency of a periodic electrical signal. There are different types of frequency meter available in the market. Here is 3 types of frequency meter.

Making our own frequency meter:

In the market, there are types of frequency meter. Making our own frequency meter is not so complex at all. All we need to use a micro-controller to sense frequency and display on LCD. Micro-controllers have timers built in. Using timer as counter mode, we can easily measure the frequency. Then printing this information on LCD is not a critical job at all. In our circuit, we will use PIC16F73 microcontroller and 16×2 LCD display.

Circuit diagram:

Circuit diagram for Frequncy meter

MikroC Coding

/*******************************************************************************
* Program for, "Frequency Meter"                                               *
* Program Written by_ Engr. Mithun K. Das                                      *
* MCU:PIC16F73; X-Tal: 8Mhz; mikroC pro for PIC v7.6.0                         *
* Date: 15-05-2020                                                             *
*******************************************************************************/

// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections


char *freq = "000";
void Display_Freq(unsigned int freq2write)
{
   freq[0] = (freq2write/100) + 48;    // Extract tens digit
   freq[1] = (freq2write/10)%10 + 48;    // Extract tens digit
   freq[2] =  (freq2write/1)%10 + 48;    // Extract ones digit
   Lcd_Out(2, 11, freq);
   Lcd_Out(2,14,"Hz");
}


void main()
{
 TRISA = 0xFF;//all input
 TRISC = 0x00;
 PORTC = 0x00;
 PORTA = 0x00;
 ADCON1=0x00;
 Delay_ms(1000);

 OPTION_REG = 0b00101000; //Timer settings; T0CKI as input
 // of Timer0

 Lcd_Init();
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Cmd(_LCD_CURSOR_OFF);
 Lcd_Out(1,1,"FREQUENCY METER");
 Lcd_Out(2,1,"WITH PIC16F73  ");
 Delay_ms(2000);
 Lcd_Cmd(_LCD_CLEAR);

  while(1)
  {

      TMR0=0;
      Delay_ms(985);  // Delay 1 Sec // you need to calibrate this delay for accurate result
      Lcd_Out(2,1,"FREQUENCY:");
      Display_Freq(TMR0);


  }// while
}// void main

Here we used Timer0 as counter mode.

Timer0 settings:

Timer0 settings register OPTION_REG

Timer0 have an physical input clock pin (RA4/T0CKI). Using this input we can measure the pulse number for a certain time.

Note that, as the timer is of 8bit. So we can only measure upto 256Hz with this methode. If you need to measure higher frequency, then we have to use INT0 hardware interrupt.

Test result:

Test result

Conclusion:

We have learned to make a frequency meter using the Timer counter mode of micro-controller. This frequency meter can be used in panel meters or similar sectors. As this meter can measure upto 256Hz so we can call it as low frequency meter. Making a higher frequency meter is not complex at all. I hope I’ll cover that in another article.


MKDas

Mithun K. Das; B.Sc. in EEE from KUET. Blog: https://labprojectsbd.com

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *