frequency counter using optoisolator,arduino uno

here i am trying to make frequency counter using arduino uno.
i want to replace PIC16F168(as shown in attached image) with atmega 328p.
please help me with programming for atmega 328p.
here i attatched program and hex file of (PIC16F168) too.Well there are some bugs in program though.
thanking you.

Optoisolator-Schematic.jpg

Frequency-Counter-HEX.HEX (3.79 KB)

Frequency-Counter-C.C (1.59 KB)

Hi

I don't know how many people here will be able to help you translate this across, I certainly can't. But if the original one is buggy anyway why not start over from the ground up for Arduino? If this is just working out the frequency of a square wave and outputting the digits to a 7 segment LED display those are the two bits you need to get functional on the Arduino - is my summary correct?

If so, there are lots of resources for helping you get to those two goals. Since there's no other hardware in your circuit, you'll likely get to do all this without running out of Arduino pins, therefore you won't need any additional supporting hardware to drive the display which means you can use a software library (like this one in the playground, link here to run your display.

For the frequency counter, googling Arduino Frequency Counter comes up with a lot of suggestions, and several pre-written libraries you'd be able to choose from. One example, here measures up to 20kHz from an Arduino.

Hope this helps get you started on your way, Geoff

well yes sir,i got your point! PIC16F628 is capable of measuring frequency only in 16Hz to 100Hz range.What about atmega 328p? Is there any way to increase this range sir? thank you for your valuable suggestion.

rosh: PIC16F628 is capable of measuring frequency only in 16Hz to 100Hz range.What about atmega 328p? Is there any way to increase this range sir?

Hi,

The first paragraph in the 2nd link above says it can give accurate measurements below 20kHz (20,000Hz) so is that sufficient for what you need?

Geoff

OP, your identical post on this subject has been deleted to prevent anyone wasting their time. Do NOT cross-post.

If you think you have posted something in the wrong section, ask a moderator to move it for you.

Well i wanted the range more than that!! Anyways thank you for your support!

Well i wanted the range more than that!!

Well, how about helping us out with a firm spec?

AWOL:

Well i wanted the range more than that!!

Well, how about helping us out with a firm spec?

I am sorry ,I am new here! What is firm spec ?

What is firm spec ?

A specification, with some performance criteria, with solid numbers. Not just "wider than 20kHz"

yea till 100 Mhz max.

On a 16MHz processor, you're going to need a prescaler.

rosh: yea till 100 Mhz max.

Earlier you said 100Hz (100 cycles per second) and now you're asking for 100MHz (100 Million cycles per second) so that M makes a significant difference. There is nothing in that circuit you posted that indicates it could get up to megahertz ranges either so did it work at all?

What is it you're measuring? If you can provide a link to the datasheet for it that would be useful also. Geoff

It likely runs on port-change interrupts or CCP. So it is designed to measure low frequencies (thus the use of an optocoupler).

If it were direct coupled to T1CKI, it could have easily gone to multi Mhz, with minimum parts.

Here is a frequency counter library for Arduino. Works well. I'm currently working on a GPS-based frequency counter for improved accuracy.