Forum - MCS Electronics
View previous topic :: View next topic
Author
Message
benoit Joined: 24 Jul 2007 Posts: 177
Posted: Thu Jan 29, 2009 5:33 pm Post subject: UP TO 32MHZ TTL FREQUENCY COUNTER WITH ATMEGA8
WHAT YOU NEED
1 ATTINY45
1 QUARTZ 16mhz
1 ATMEGA 8 -16 OR BETTER
1 LCD DISPLAY
DESCRIPTION:
VOLTAGE ON THE ATMEGA8 MUST BE 5 VOLT FOR A GOOD LINEARITY
IN MESUREMENT
RESOLUTION IS ABOUT 50hz
THE ATTINY45 AND THE QUARTZ ARE USED FOR GENERATE 1 SECOND TEMPO SIGNAL
DO NO USE INTERNAL OSCILLATOR BECAUSE IT IS NOT STABLE ENOUGH
HERE IS THE PROGRAM
'--------------------------
'tempo 1 seconde
'micro-controleur attiny45
'par Noël BENOIT
'--------------------------
$prog &HFF , &HC0 , &HDF , &HFF ' generated. Take care that the chip supports all fuse bytes.
$regfile = "atTiny45.dat"
$crystal = 16000000
$hwstack = 32
$swstack = 10
$framesize = 40
Config Portb = Output
Do
Wait 1
Reset Portb.0
Wait 1
Set Portb.0
Loop
End
THE ATMEGA 8 IS USED AS COUNTER AND DISPLAY THE VALUE ON THE LCD
HERE IS THE PROGRAM
' frequencemetre 32 mhz a atmega8
' par Noël BENOIT
Dim Compteur As Long
Dim Frequence2 As Long
Dim Frequence3 As Single
$regfile = "m8def.dat" ' specify the used micro
$crystal = 1000000 ' used crystal frequency
$hwstack = 60 ' default use 32 for the hardware stack
$swstack = 60 ' default use 10 for the SW stack
$framesize = 60
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0
Config Portb = Output
Cls
Lcd "FREQUENCEMETRE"
Do
LOCATE 1,1
Compteur = 0
Frequence2 = 0
Frequence3 = 0
Config Pinc.5 = Input
Do
Loop Until Pinc.5 = 0 'attente passage pinc.5 a 0
Do ' debut du comptage
Compteur = Compteur + 1 'incrementation compteur
Loop Until Pinc.5 = 1 'quand pinc.5=1 fin du comptage
Frequence3 = 32000000 * Compteur
Frequence2 = Frequence3 / 666881
'Lcd Compteur
Lcd Frequence2
Wait 1
Loop
FUSE OF THE ATMEGA8 MUST BE SET AS EXTERNAL CLOCK
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum