1968neil
Senior Member
Hi All,
Need to convert the attached basic code for use with a picaxe.
Not familiar with some of the commands used, however most of the code makes sense. Once i can get it working i can alter it to suit my purpose.
It's a 5 tone selcall decoder for use with ham radio.
Im building a logger and the decoder needs to be my starting point.
Any help or pointers much appreciated
Regards
Neil
Need to convert the attached basic code for use with a picaxe.
Not familiar with some of the commands used, however most of the code makes sense. Once i can get it working i can alter it to suit my purpose.
It's a 5 tone selcall decoder for use with ham radio.
Im building a logger and the decoder needs to be my starting point.
Any help or pointers much appreciated
Regards
Neil
Code:
$regfile = "m8def.dat"
$crystal = 8000000
Ddrd = &B00010000
Portd.2 = 1
Config Timer1 = Timer , Prescale = 1 , Capture Edge = Rising , Noise Cancel = 1
Config Aci = On , Compare = On , Trigger = Rising
On Icp1 Oncapture
Enable Icp1
Cls
On Int0 Buttonpress
Config Int0 = Falling
Enable Int0
Enable Interrupts
Dim Countcycles As Word
Dim Icr_new As Word
Dim Icr_old As Word
Dim Frequlong As Long
Dim Freqcy As Word
Dim A(5) As Word
Dim Freqsum As Word
Dim Timesample As Integer
Dim Freqmeasure As Word
Dim Frequpper As Word
Dim Freqlow As Word
Dim Tone As String * 1
Dim Toneold As String * 1
Dim Sequence As String * 10
Dim Timeout As Word
Lcd "Stand by..."
Main:
Waitms 2
Frequlong = 8000000 / Icr_new
Icr_new = 1
Freqcy = Frequlong
Incr Timeout
If Timeout > 40 Then
Sequence = ""
Toneold = ""
Timeout = 0
End If
A(5) = A(4)
A(4) = A(3)
A(3) = A(2)
A(2) = A(1)
A(1) = Freqcy
Freqsum = 0
For Timesample = 1 To 5
Freqsum = Freqsum + A(timesample)
Next
Freqmeasure = Freqsum / 5
Frequpper = A(1) + 10
Freqlow = A(1) - 10
If Freqmeasure > Freqlow And Freqmeasure < Frequpper Then
Select Case Freqmeasure
Case 1114 To 1134 : Tone = "1"
Case 1187 To 1207 : Tone = "2"
Case 1265 To 1285 : Tone = "3"
Case 1348 To 1368 : Tone = "4"
Case 1436 To 1456 : Tone = "5"
Case 1530 To 1550 : Tone = "6"
Case 1630 To 1650 : Tone = "7"
Case 1737 To 1757 : Tone = "8"
Case 1850 To 1870 : Tone = "9"
Case 1971 To 1991 : Tone = "0"
Case 2390 To 2410 : Tone = "A"
Case 920 To 940 : Tone = "B"
Case 2237 To 2257 : Tone = "C"
Case 981 To 1001 : Tone = "D"
Case 2100 To 2120 : Tone = "E"
Case Else
Locate 1 , 1
Lcd "notone"
Goto Main
End Select
Else : Goto Main
End If
If Tone = Toneold Then Goto Main
Locate 1 , 1
Lcd "1 tone"
Toneold = Tone
Sequence = Sequence + Tone
Timeout = 0
If Len(sequence) >= 5 Then
Locate 1 , 1
Lcd Sequence
Rem Sequence = "" let timeout take care of this
End If
Goto Main
Buttonpress:
Portd.4 = 0
Cls
Return
Oncapture:
Countcycles = Timer1
Icr_new = Countcycles - Icr_old
Icr_old = Countcycles
Return