Make a Frequency Meter with a PIC16F73

Published by MKDas on

When you are working with electronics, especially power electronics you must have to measure line frequency. But in most 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 Frequency Meter with a PIC16F73 general-purpose microcontroller and LCD display. Using a multi-meter is ok to measure frequency but many people do not have a multimeter with a 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. Proper skill is required to work with electricity. Do work at your own risk. The author will not be responsible for any misuse or harmful act or any mistake you make. The contents of this website are unique and copyright protected. Kindly don’t do any nonsensical act copying and claiming it as yours. Most of the articles published here are kept as open-source to help you. Take the knowledge for free and use it, but if you are interested you can buy the ready resources offered here. If you need any help or guide feel free to comment below, the author will try to help 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 meters available in the market. Here are 3 types of frequency meters.

Making our own frequency meter:

In the market, there are types of frequency meters. 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 the 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 the PIC16F73 microcontroller and 16×2 LCD display.

Circuit diagram:

Circuit diagram for Frequency 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 has a 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 8bit. So we can only measure up to 256Hz with this method. If you need to measure a higher frequency, then we have to use the INT0 hardware interrupt.

Test result:

Test result

Conclusion:

We have learned to make a frequency meter using the Timer counter mode of the 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 a low-frequency meter. Making a higher frequency meter is not complex at all. I hope I’ll cover that in another article.

Don’t forget to subscribe for the next update.

Loading

JLCPCB – Only $2 for PCB Prototype (Any Color)

24 Hours fast turnaround, Excellent quality & Unbeatable prices

$18 Welcome Bonus for new registrations Now!!! https://jlcpcb.com


Check this out: 5 coolest multimeters you can buy


MKDas

I'm Mithun K. Das; B.Sc. in EEE from KUET, Bangladesh. Blog: https://labprojectsbd.com. "First, electronics was my passion, then it was my education, and finally, electronics is now my profession." I run my own electronics lab, M's Lab (https://mlabsbd.com). Where I work with the creation of new products from ideas to something in real life. Besides this is my personal blog where I write for hobbyists and newcomers in the electronics arena. I also have a YouTube channel where I publish other helpful videos, you can find the link inside the articles. I always try to keep it simple so that it becomes easy to understand. I hope these will help them to learn electronics and apply the knowledge in their real life.

0 Comments

Leave a Reply

Avatar placeholder

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