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 counter using atmega8

Status
Not open for further replies.

arnab.bhaumik

Member level 5
Joined
Sep 20, 2006
Messages
81
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,288
Location
Kolkata, India
Activity points
1,835
atmega8 counter

hi guys,

i am considering to design a frequency counter using atmega8, i want to use asynchronous operation of timer/counter2.


frequency counter developed by pic asynchronous timer is ther.... but i want to make it with atmega8.....


need some suggestion..



arnab/vu2bpw
 

atmega frequency counter

i write this code prior . i hope it be helpul for u.its write under bascom avr
Code:
$regfile = "m8def.dat"
$crystal = 8000000
 Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
 Config Lcd = 16 * 2
Config Timer1 = Counter , Edge = Rising
Config Timer0 = Timer , Prescale = 1024
Enable Counter1
Enable Interrupts
Enable Timer0
Enable Timer1
On Ovf1 Int_counter1_1
On Ovf0 Int_timer_0
Dim Int_shomar As Long , A As Long , B As Byte , F As Single
B = 0
Cls
Start Timer0
  Lcd "start..."
'******************************************************************************
Do

Loop
End
'******************************************************************************
Int_timer_0:
Incr Int_shomar
If Int_shomar > 30 Then
Stop Timer0
Cls : Home
A = B * 65536
A = A + Counter1
Lcd "frequency="
Lowerline
Lcd A ; "HZ"
B = 0
Int_shomar = 0 : Counter1 = 0
Start Timer0
End If
Return
'******************************************************************************
Int_counter1_1:
Incr B
Counter1 = 0
Return
 

    V

    Points: 2
    Helpful Answer Positive Rating
atmega8 frequency counter

thanks for the replay,
i will check the code tomorrow........

it will not be a problem for me to get the idea and apply it with winavr into my circuit

arnab/vu2bpw
 

atmega8 timer0

hi

got ur idea, but my problem is to measure at least 30MHz(all HF band of ham radio ) without any costly external prescaler...........

using PIC circuits are ther, at atmega8 we cannot prescale external clock , it seems.......


aranb/vu2bpw
 

bascom frequency counter

using PIC circuits are ther, at atmega8 we cannot prescale external clock
May I have further information about PIC prescale external clock capability? Any links or documentations?
 

atmega counter

i think u can use pic mcu & timer0 with external clock and prescale external clock
 

atmega frequency meter

if i use pic then i will use that microcontroller only and will finish the project with that mcu only..

but surely i am in love with atmega series. beleive me it is very good comparing to size, feature and cost. so i want to do this project with atmega8 only.

i already got the idea.

i will use atmega8(L). so the max uc frequency is 8MHz. so in synchronous mode by using timer0,timer1 or timer2 i can measure max 3 MHz directly. now if i add 74hc390 (ripple decade counter) in the input of the uc timer then i will get 30 Mhz directly.
i am thinking about this and expecting some suggestion. withen 1 or 2 days i will finalize the design. the local hams looking at me for a low cost good frequency counter.



arnab/vu2bpw
 

frequency meter bascom

hi arnab.bhaumik
it's good idea and 74hc390 can operate upward 60mhz and if u use atmega8 16pi ,i think it can measure upward 60mhz frequency.:idea:
 

atmega8 frequency meter

atmega8 16pi is not available in kolkata (india) market. atmega8L (80 inr (1.4$))is available and atmega16(150 inr 3$) is available.

thanks for the suggestion.

arnab/vu2bpw
 

hi, im trying to measure the length a period of square wave signal, and count it in for a minute, its for rpm meter, could u help me writing the bAscom code
thank you
 

is there no asynchronous counter in avr and asynchronous prescaler for avr??? in PIC micro, asynchronous counter is there and thats why we can measure frequency upto around 40MHz.

arnab/vu2bpw
 

Hi arnab,
The Timer2 in AVR can be used for asynchronous counter, study the ASSR register and related Timer2 registers in the datasheet for that.

Hope this helps.
Tahmid.
 

Tahmid said:
Hi arnab,
The Timer2 in AVR can be used for asynchronous counter, study the ASSR register and related Timer2 registers in the datasheet for that.

Hope this helps.
Tahmid.

Ya but freq. range should be between 0hz to 256khz...
I don't think that can be used to to measure high frequency signals :D
(Timer2 is asynchronous becoz it is independent of system clock.)

correct me if any errors in my statement
 

Hi arnab.bhaumik

How did your project turn out? Did you end up using a 74hc390 with atmega8? If so what did you do to prevent from exceeding it's input voltage?

I am very curious about how well it worked, I am currently trying to do the exact same thing for my ham radio friends. Any and all advice/help is welcomed!
 

my problem is to measure at least 30MHz(all HF band of ham radio ) without any costly external prescaler...........

I think your problem is having such an unrealistic goal that you have set yourself up for sure failure.
 

Re: atmega frequency counter

i write this code prior . i hope it be helpul for u.its write under bascom avr
Code:
$regfile = "m8def.dat"
$crystal = 8000000
 Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5 , E = Portc.1 , Rs = Portc.0
 Config Lcd = 16 * 2
Config Timer1 = Counter , Edge = Rising
Config Timer0 = Timer , Prescale = 1024
Enable Counter1
Enable Interrupts
Enable Timer0
Enable Timer1
On Ovf1 Int_counter1_1
On Ovf0 Int_timer_0
Dim Int_shomar As Long , A As Long , B As Byte , F As Single
B = 0
Cls
Start Timer0
  Lcd "start..."
'******************************************************************************
Do

Loop
End
'******************************************************************************
Int_timer_0:
Incr Int_shomar
If Int_shomar > 30 Then
Stop Timer0
Cls : Home
A = B * 65536
A = A + Counter1
Lcd "frequency="
Lowerline
Lcd A ; "HZ"
B = 0
Int_shomar = 0 : Counter1 = 0
Start Timer0
End If
Return
'******************************************************************************
Int_counter1_1:
Incr B
Counter1 = 0
Return

What changes I should make in this code if i write this in 'mikroC' compiler?
 

i already built two frequency counters with pic16f628. and one with prescalar 664 (DIP 8 pin ic) it can measure around 1200MHz. no luck with atmega8. but my 16f628 can measure 40MHz alone.
 

Somebody can give me the full project of this counter? i have an atmega 8 smd +2x 16 LCD, I want to make this. Because the last trying with 89C2051 doesn`t was a disaster.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top