部品実装したPCBである。PCBサイズは、LCDと同じ位の大きさに収めた。
回路図である。プリスケーラは、MB505Lが大量に見つかったので使ったが、MB506が回路変更することなく使う事が出来る。
基板サイズ 79 × 36
Program
BASCOM AVRで開発の為、周波数のピリオド表示を簡単化する為、メガ表示部分を3桁固定。その為、桁数に満たない場合、頭に0(ゼロ)が付く。(3桁を超えると正しく表示されない。)プリスケーラが1/128の為、ゲートタイム1.28sec固定である。
ヒューズビットもプログラムしてあるので、クロックの設定に悩まなくて良い。
'********************************************************
'ATtiny2313 Frequency Counter
'
' 2016/02/01
' JA2GQP
' BASCOM AVR 2.0.7.5(DEMO version) Compiled
'--------------------------------------------------------
'Function
' 1.1/128 prescaler(resolution 100Hz,Gate time 1.28sec)
' 2.Display style 123.456.789MHz
'********************************************************
$regfile = "attiny2313.dat"
$crystal = 12800000
$prog &HFF , &HFF , &HDF , &HFF ' generated. Take care that the chip supports all fuse bytes.
'---LCD port assign ---
Config Lcdpin = Pin , Db7 = Portb.0 , Db6 = Portb.1
Config Lcdpin = Pin , Db5 = Portb.2 , Db4 = Portb.3
Config Lcdpin = Pin , E = Portb.4 , Rs = Portb.5
Config Lcd = 16 * 2
'--- Timer interrupt assign ---
Config Timer0 = Timer , Prescale = 1
Config Timer1 = Counter , Edge = Rising
'--- define memory ---
Dim Flag As Bit
Dim Over As Byte
Dim Tint As Word
Dim Freq As Long
Dim Str_frq As String * 12
Dim Dsp_frq As String * 12
'--- Initialization ---
Stop Timer0
Stop Timer1
On Timer0 Timer0_int
On Timer1 Timer1_int
Enable Interrupts
Enable Timer0
Enable Timer1
Cls : Cursor Off
Lcd "GQP F.Counter"
Locate 2 , 2
Start Timer0
Start Timer1
'--- Main proc ---
Do
If Flag = 1 Then
Freq = Over * 65536
Freq = Freq + Timer1
Freq = Freq * 100
Lcd " "
Locate 2 , 2
Str_frq = Str(freq)
Str_frq = Format(str_frq , "000.000000")
Dsp_frq = Left(str_frq , 4) + Mid(str_frq , 5 , 3) + "." + Mid(str_frq , 8 , 3)
Lcd Dsp_frq ; "MHz"
Flag = 0
Over = 0
Tint = 0
Timer1 = 0
Start Timer0
Start Timer1
End If
Loop
End
Timer0_int:
Incr Tint
If Tint = 64000 Then 'Gate time 1.28sec
Stop Timer0
Stop Timer1
Flag = 1
End If
Return
Timer1_int:
Incr Over
Return
4 件のコメント:
range frequency from min and max?
can you share hex file to me?
thanks
Since there is no development environment for BASCOM AVR, HEX files cannot be created. The operation check frequency is written in the text.
Hello , a demo version of counter.bas has been released, is there a fully functional counter.bas file? Is it possible to get it? Or maybe hex?
73 of S51AI
Andre
Please download S51AI.zip from the download site.
https://sites.google.com/view/ja2gqp
The zip file contains the source program and the HEX file.
コメントを投稿