回路図である。全てのデバイスが含まれているので、必要に応じ、構成すれば良い。
PCB寸法 54 x 55。既に公開の物と同じ。
Program
AD9850 DDS VFO Ver1.1aをベースとしたが、チャンネル切替スイッチのメインメモリー(ch0)保持機能は、BASCOMのメモリー制限により、割愛した。ch1 50.55MHz、ch2 50.60MHzで初期化した。
'********************************************************
'AD9850 DDS VFO program ver.1.0
' 50.500Mhz to 50.700Mhz Limitted!
' Copyright (C)2014.JA2GQP.All rights reserved.
' 2014/6/15
' JA2GQP
' BASCOM AVR 2.0.7.5(DEMO version) Compiled
'--------------------------------------------------------
' Function
' 1.Lower heterodyne
' 2.RIT operation(-10khz to +10khz)
' 3.STEP(1k,10k)
' 4.Memory operation is push RIT
' (Frequency and Step)
' 5. Protection operation at the time of transmission
' 6.Channel memory ch0(main channel),ch1,ch2
'********************************************************
$regfile = "m88adef.dat"
$crystal = 800000 '0.8Mhz clock
'--- config port ---
Config Portb.0 = Input 'TX
Config Portb.1 = Output 'STEP LED 1k
Config Portb.2 = Input 'STEP
Config Portb.3 = Input 'RIT
Config Portb.4 = Input 'ENC A
Config Portb.5 = Input 'ENC B
Config Portc.0 = Output 'DATA
Config Portc.1 = Output 'FU_UD
Config Portc.2 = Output 'W_CLK
Config Portc.3 = Input 'ch1
Config Portc.4 = Input 'ch2
Config Portc.5 = Input 'none
Config Portd.1 = Output 'Frq LED Mid .
Config Portd.3 = Output 'Frq LED Low
Config Portd.4 = Output 'Frq LED Hi
'--- port pullup ---
Portb = &B00111101 'Bit 0,Bit 1-4 pull up
Portc = &B00111000 'Bit 3-5 pull up
'--- debounce set ---
Config Debounce = 1
'---LCD port assign ---
Config Lcdpin = Pin , Db7 = Portd.6 , Db6 = Portd.5
Config Lcdpin = Pin , Db5 = Portb.7 , Db4 = Portb.6
Config Lcdpin = Pin , E = Portd.2 , Rs = Portd.0
Config Lcd = 16 * 2
'---Frequency Parameter(50.500Mhz to 50.700Mhz Limitted!)
Const If_frq = 10700000 'IF frequency
Const Lw_frq = 50500000 'Lower limit operation frequency
Const Hi_frq = 50700000 'Upper limit operation frequency
Const Def_frq =(lw_frq + Hi_frq) / 2 'Operation center frequency
Const Def_frq1 = 50550000 'ch1=50.55MHz
Const Def_frq2 = 50600000 'ch2=50.60MHz
'--- constant data ---
Const Lw_vfo = Lw_frq - If_frq 'VFO lower limit(RX)
Const Hi_vfo = Hi_frq - If_frq 'VFO upper limit(RX)
Const Def_vfo = Def_frq - If_frq 'VFO ch0
Const Def_vfo1 = Def_frq1 - If_frq 'VFO ch1
Const Def_vfo2 = Def_frq2 - If_frq 'VFO ch2
Const Lw_rit = -10000 'RIT lower limit
Const Hi_rit = 10000 'RIT upper limit
Const Scal = 34.35973837 '2^32/125.000Mhz
Const Dds_cmd = &B00000000 'DDS command
'--- define subrutine ---
Declare Sub Enc_sub 'Encorder
Declare Sub Dds_sub 'DDS
Declare Sub Lcd_sub 'LCD
Declare Sub Stp_sub 'STEP
Declare Sub Rit_sub 'RIT
Declare Sub Rx_sub 'RX
Declare Sub Tx_sub 'TX
Declare Sub Chsw_sub 'Channel SW check
Declare Sub Eep_rd_sub 'EEP read
'--- define memory ---
Dim Vfo_dat As Long 'VFO freqency data
Dim Dds_dat As Long 'DDS frequency data
Dim Str_frq As String * 10 'String frequency
Dim Dsp_frq As String * 10 'Display frequency
Dim Sng_wrk As Single 'main channel
Dim Lng_wk1 As Long 'Long work1
Dim Lng_wk2 As Long 'Long work2
Dim Wrd_wk1 As Word 'Word work1
Dim Wrd_wk2 As Word 'Word work2
Dim Wrd_wk3 As Word 'Word work3
Dim Enc_stp As Integer 'Encorder step
Dim Rit_dat As Integer 'RIT data
Dim Rit_datb As Integer 'RIT data old
Dim Int_wrk As Integer 'Integer work
Dim Flg_rit As Byte 'RIT flag
Dim Flg_ritb As Byte 'RIT flag old
Dim Flg_tx As Byte 'TX flag
Dim Frq_eep0 As Eram Long 'EEP frequency ch0
Dim Frq_eep1 As Eram Long ' ch1
Dim Frq_eep2 As Eram Long ' ch2
Dim Stp_eep0 As Eram Integer 'EEP STEP ch0
Dim Stp_eep1 As Eram Integer ' ch1
Dim Stp_eep2 As Eram Integer ' ch2
Dim Flg_enc As Byte 'Encorder dir flag
Dim Byt_cmd As Byte 'DDS command
Dim Byt_wrk As Byte 'Byte work
Dim Byt_chn As Byte 'Channel
'--------------
'Main roution
'--------------
Main:
Flg_tx = 0 'TX flag reset
Flg_rit = 0 'RIT flag reset
Cursor Off
Cls
Call Chsw_sub 'Channel SW check
Byt_wrk = Byt_chn
Call Eep_rd_sub 'EEP initial
Call Lcd_sub
Do
If Flg_tx = 0 Then
Debounce Pinb.4 , 0 , Enc_sub , Sub 'Encorder
Debounce Pinb.2 , 0 , Stp_sub , Sub 'Step
Debounce Pinb.3 , 0 , Rit_sub , Sub 'RIT
Call Chsw_sub 'Channel SW check
If Byt_wrk <> Byt_chn Then
Byt_wrk = Byt_chn
Call Eep_rd_sub 'EEP load
End If
If Vfo_dat =< Lw_vfo Then 'VFO lower limit check
Vfo_dat = Lw_vfo
Portd.3 = 1 'Frq LED Low on
Else
Portd.3 = 0
End If
If Vfo_dat = Def_vfo Then 'VFO Def Frq check
Portd.1 = 1 'Frq LED Mid on
Else
Portd.1 = 0
End If
If Vfo_dat >= Hi_vfo Then 'VFO upper limit check
Vfo_dat = Hi_vfo
Portd.4 = 1 'Frq LED Hi on
Else
Portd.4 = 0
End If
If Enc_stp = 1000 Then 'STEP LED 1k check
Portb.1 = 1 'LED on
Else
Portb.1 = 0
End If
End If
Debounce Pinb.0 , 1 , Rx_sub , Sub 'RX
Debounce Pinb.0 , 0 , Tx_sub , Sub 'TX
If Flg_rit = 1 Then
Dds_dat = Vfo_dat + Rit_dat
Else
Dds_dat = Vfo_dat
End If
If Flg_tx = 1 Then
Dds_dat = Vfo_dat
End If
Call Dds_sub
Loop
End
'-----------------------------
'Encoder check,Create DDS data
'-----------------------------
Sub Enc_sub
If Pinb.5 = 1 Then
Flg_enc = 0 'Up
Else
Flg_enc = 1 'down
End If
If Flg_enc = 0 Then
Lng_wk1 = Vfo_dat + Enc_stp 'Up
Lng_wk2 = Rit_dat + Enc_stp
Else
Lng_wk1 = Vfo_dat - Enc_stp 'down
Lng_wk2 = Rit_dat - Enc_stp
End If
If Flg_rit = 1 Then
Rit_dat = Lng_wk2
Else
Vfo_dat = Lng_wk1
Rit_dat = 0
End If
If Vfo_dat < Lw_vfo Then 'VFO lower limit check
Vfo_dat = Lw_vfo
End If
If Vfo_dat > Hi_vfo Then 'VFO upper limit check
Vfo_dat = Hi_vfo
End If
If Rit_dat < Lw_rit Then 'RIT lower limit check
Rit_dat = Lw_rit
End If
If Rit_dat > Hi_rit Then 'RIT upper limit check
Rit_dat = Hi_rit
End If
Call Lcd_sub
End Sub
'-----------------------------
'AD9850(DDS) Data write
'-----------------------------
Sub Dds_sub
Sng_wrk = Dds_dat
Lng_wk1 = Sng_wrk * Scal
Byt_cmd = Dds_cmd 'DDS command
Reset Portc.1
Shiftout Portc.0 , Portc.2 , Lng_wk1 , 3
Shiftout Portc.0 , Portc.2 , Byt_cmd , 3
Set Portc.1
End Sub
'-----------------------------
'LCD Data write
'-----------------------------
Sub Lcd_sub
Locate 1 , 1
Lng_wk1 = Vfo_dat + If_frq
Str_frq = Str(lng_wk1)
Str_frq = Format(str_frq , "00.000000")
Dsp_frq = Left(str_frq , 3) + Mid(str_frq , 4 , 3) + "." + Mid(str_frq , 7 , 3)
Lcd Byt_chn ; ":" ; Dsp_frq ; "MHz"
Locate 2 , 1
Lcd "S: "
Locate 2 , 3
Int_wrk = Enc_stp / 1000
Lcd Int_wrk ; "k"
If Flg_rit = 1 Then
Locate 2 , 8
Lcd "R: "
Str_frq = Str(rit_dat)
Str_frq = Format(str_frq , "00.000")
Locate 2 , 10
Lcd Str_frq
Else
Locate 2 , 8
Lcd " JA2GQP"
End If
End Sub
'-----------------------------
'Step
'-----------------------------
Sub Stp_sub
Select Case Enc_stp
Case 10000:
Enc_stp = 1000 '1k
Case 1000:
Enc_stp = 10000 '10k
Vfo_dat = Vfo_dat + 5000 'round 10k
Vfo_dat = Vfo_dat \ 10000
Vfo_dat = Vfo_dat * 10000
Case Else:
Enc_stp = 10000 '10k(initial)
End Select
Call Lcd_sub
End Sub
'-----------------------------
'RIT
'-----------------------------
Sub Rit_sub
If Flg_rit = 0 Then
Rit_dat = 0
Flg_rit = 1
Select Case Byt_chn
Case 1:
Frq_eep1 = Vfo_dat 'Save VFO1 data
Stp_eep1 = Enc_stp 'Save STEP1 data
Case 2:
Frq_eep2 = Vfo_dat 'Save VFO2 data
Stp_eep2 = Enc_stp 'Save STEP2 data
Case Else:
Frq_eep0 = Vfo_dat 'Save VFO0 data
Stp_eep0 = Enc_stp 'Save STEP0 data
End Select
Else
Flg_rit = 0
End If
Call Lcd_sub
End Sub
'-----------------------------
'RX
'-----------------------------
Sub Rx_sub
If Flg_tx = 1 Then
Flg_tx = 0 'TX flag rest
Locate 1 , 1
Lcd Byt_chn
End If
End Sub
'-----------------------------
'TX
'-----------------------------
Sub Tx_sub
If Flg_tx = 0 Then
Flg_tx = 1 'TX flag set
Locate 1 , 1
Lcd "T"
End If
End Sub
'-----------------------------
'Channel SW check
'-----------------------------
Sub Chsw_sub
If Pinc.3 = 0 Then
Byt_chn = 1
Elseif Pinc.4 = 0 Then
Byt_chn = 2
Else
Byt_chn = 0
End If
Locate 1 , 1
Lcd Byt_chn
End Sub
'-----------------------------
'EEP set
'-----------------------------
Sub Eep_rd_sub
If Frq_eep0 =< 0 Then 'EEP VFO data check
Vfo_dat = Def_vfo 'Initialize VFO data
Frq_eep0 = Def_vfo
Frq_eep1 = Def_vfo1
Frq_eep2 = Def_vfo2
Else 'Restore VFO data
Select Case Byt_chn
Case 1:
Vfo_dat = Frq_eep1
Case 2:
Vfo_dat = Frq_eep2
Case Else:
Vfo_dat = Frq_eep0
End Select
End If
If Stp_eep0 =< 0 Then 'EEP STEP data check
Enc_stp = 10000
Stp_eep0 = Enc_stp 'Initialize STEP data
Stp_eep1 = Enc_stp
Stp_eep2 = Enc_stp
Else 'Restore STEP data
Select Case Byt_chn
Case 1:
Enc_stp = Stp_eep1
Case 2:
Enc_stp = Stp_eep2
Case Else:
Enc_stp = Stp_eep0
End Select
End If
Call Lcd_sub
End Sub