Internet Research
Protocols
After a day or so of researching the Internet it seems as if there are two protocols I should look at:
- Bell 103A: 300 baud full duplex using 1070/1270 Hz and 2070/2270 Hz
- Bell 202: 1200 baud half duplex or 1200/150 baud full duplex using 1200/2200 Hz and 387/487 Hz
Regardless of the protocol the possible encoding/decoding technologies are:
- Separate frequency filters and envelop detectors and NRZ using a comparator
- PLL and/or tone decoders (lock time likely too slow for most protocols)
- Zero crossing and period/frequency measurement
- DFT
- Goertzel
- Cross-correlation
- and more.
If your familiar with radio receiver technology much of the above is rather similar.
Cross-correlations seems to be the go!
This article by Denis Sequine simplifies the process down to basics:
https://dx.eng.uiowa.edu/eedesign/fskcorr.pdf
Another requirement is digital filter construction and I found this site to be useful;
http://unicorn.us.com/alex/allpolefilters.html
My First Software Encode and Decode for the Bell 202 Protocol
I often prototype software using Excel Macros. Its quick and easy to debug.
So the first task was to encode a binary sequence.
The first issue was how to join the two frequencies up as 2200 Hz does not match the the 1200 baud rate? The answer is to keep track of the phase.
Here is an example of the encoded output:
Note that the output has been smoothed by excel. The article by Denis Sequine suggests using a 13.2 kHz sample clock, so I went with that. There are only 11 sample points per bit.
Next is to read back the data and calculate the cross-correlation for different delay steps to find the best case. The best case was a delay of 6. Refer to Denis Sequine article as to what this all means.Finally a low pass filter (green) and a schmitt trigger was used to recover the data (bright red). I found a four pole low pass with a corner frequency of 900 Hz worked well.
Here is an example of the decoded output (note the decoded output is shifted to the right approximately one bit:
Of more interest is the effect of phase, amplitude and general noise on the signal recovery:
Here is the code (it still needs work for all the parameters to be effective):
Option Explicit
Sub AFSKDem()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Const Pi As Double = 3.14159265358979
Dim Fspace As Double
Dim Fmark As Double
Dim Fsample As Double
Dim Baud As Double
Dim Delay As Long
Dim I As Long
Dim Time As Long
Dim Code As Long
Dim Data As Long
Dim Phase As Double
Dim Magn As Double
Dim MagnN As Double
Dim TestX2 As Double
Dim TestX1 As Double
Dim TestX0 As Double
Dim TestY2 As Double
Dim TestY1 As Double
Dim TestY0 As Double
Dim TestZ2 As Double
Dim TestZ1 As Double
Dim TestZ0 As Double
' Get FSK parameters
Fspace = ActiveSheet.Cells(1, 2).Value
Fmark = ActiveSheet.Cells(2, 2).Value
Fsample = ActiveSheet.Cells(3, 2).Value
Baud = ActiveSheet.Cells(4, 2).Value
Delay = ActiveSheet.Cells(5, 2).Value
' Generate some data to encode
Time = 0
Magn = 0#
Phase = 0#
ActiveSheet.Cells(7, 1).Value = "Time"
ActiveSheet.Cells(7, 2).Value = "Code"
ActiveSheet.Cells(7, 3).Value = "Data"
For Code = 0 To 7
'Data = Int(Rnd + 0.5)
Data = Code Mod 2
' Encode
For I = 1 To Int(Fsample / Baud)
ActiveSheet.Cells(8 + Time, 1).Value = Time
ActiveSheet.Cells(8 + Time, 2).Value = Data
ActiveSheet.Cells(8 + Time, 3).Value = Magn
If (Data = 0) Then
' Fspace
Magn = Sin(2 * Pi * (Phase + (Rnd - 0.5) * 0.2)) * (0.5 + Rnd) + Rnd * Rnd * (Rnd - 0.5)
Phase = Phase + Fspace / Fsample
Else
' Fmark
Magn = Sin(2 * Pi * (Phase + (Rnd - 0.5) * 0.2)) * (0.5 + Rnd) + Rnd * Rnd * (Rnd - 0.5)
Phase = Phase + Fmark / Fsample
End If
Time = Time + 1
Next I
Next Code
' Decode the data
ActiveSheet.Cells(7, 4).Value = "Test"
Time = 0
Magn = 0#
MagnN = 0#
TestX0 = 0#
TestX1 = 0#
TestX2 = 0#
TestY0 = 0#
TestY1 = 0#
TestY2 = 0#
TestZ0 = 0#
TestZ1 = 0#
TestZ2 = 0#
For Code = 0 To 7
For I = 1 To Int(Fsample / Baud)
Magn = ActiveSheet.Cells(8 + Time, 3).Value
If (Time >= Delay) Then
MagnN = ActiveSheet.Cells(8 + Time - Delay, 3).Value
End If
TestZ2 = TestZ1
TestZ1 = TestZ0
TestY2 = TestY1
TestY1 = TestY0
TestX2 = TestX1
TestX1 = TestX0
TestX0 = Magn * MagnN
' 900 Hz Four Pole Low Pass Filter using approximate fractions
TestY0 = TestX0 * 110 / 1667 + TestX1 * 123 / 932 + TestX2 * 110 / 1667 + TestY1 * 106 / 109 - TestY2 * 61 / 258
TestZ0 = TestY0 * 110 / 1667 + TestY1 * 123 / 932 + TestY2 * 110 / 1667 + TestZ1 * 106 / 109 - TestZ2 * 61 / 258
ActiveSheet.Cells(8 + Time, 4).Value = TestZ0
Time = Time + 1
Next I
Next Code
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub
AlanX
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.