% then switch to a more robust tracking algorithm. If we lose sync we switch
% back to acquire mode for fast-requisition.
-function [track state] = freq_state(sync_bit, state)
+function [track state bad_sync] = freq_state(sync_bit, state, bad_sync)
% acquire state, look for 6 symbol 010101 sequence from sync bit
if state == 5
if sync_bit == 1
next_state = 6;
+ bad_sync = 0;
else
next_state = 0;
end
% states 6 and above are track mode, make sure we keep getting 0101 sync bit sequence
if state == 6
+ next_state = 7;
if sync_bit == 0
- next_state = 7;
- else
- next_state = 0;
+ bad_sync = 0;
+ else
+ printf("inc ");
+ bad_sync++;
+ if bad_sync > 2
+ next_state = 0;
+ end
end
end
+
if state == 7
+ next_state = 6;
if sync_bit == 1
- next_state = 6;
- else
- next_state = 0;
+ bad_sync = 0;
+ else
+ printf("inc ");
+ bad_sync++;
+ if bad_sync > 2
+ next_state = 0;
+ end
end
end
+ %printf("state: %d next_state: %d sync_bit: %d bad_sync: %d\n", state, next_state, sync_bit, bad_sync);
+
state = next_state;
if state >= 6
track = 1;
track_log = [];
track = 0;
fest_state = 0;
+ bad_sync = 0;
% spectrum states
% freq est state machine
- [track fest_state] = freq_state(sync, fest_state);
+ [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync);
track_log = [track_log track];
% count bit errors if we find a test frame
% Simulation Parameters --------------------------------------
-frames = 50*10;
-EbNo_dB = 10.3;
+frames = 100;
+EbNo_dB = 7.3;
Foff_hz = 0;
modulation = 'dqpsk';
hpa_clip = 150;
t = 0;
foff = 0;
fest_state = 0;
+bad_sync = 0;
track = 0;
track_log = [];
% freq est state machine
- [track fest_state] = freq_state(sync, fest_state);
+ [track fest_state bad_sync] = freq_state(sync, fest_state, bad_sync);
track_log = [track_log track];
% Update SNR est