ldpc working, performance not that great, about to try simplified model
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 16 Feb 2014 06:41:48 +0000 (06:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 16 Feb 2014 06:41:48 +0000 (06:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1404 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/test_qpsk.m

index a7dc6a6ace629f82413a638cc1879e922394bc7f..987841cf3746c69138edc9eebbe84d8ce654827b 100644 (file)
@@ -58,7 +58,7 @@ function sim_out = ber_test(sim_in, modulation)
 \r
         ldpc;\r
 \r
-        rate = 1/2\r
+        rate = 3/4\r
         mod_order = 4; \r
         modulation = 'QPSK';\r
         mapping = 'gray';\r
@@ -157,11 +157,12 @@ function sim_out = ber_test(sim_in, modulation)
         tx_phase = rx_phase = 0;\r
         tx_data_buffer = zeros(1,2*framesize);\r
         s_data_buffer = zeros(1,2*Nsymb);\r
+        C_log = [];\r
 \r
         for nn = 1: Ntrials\r
                   \r
-            %tx_bits = round( rand( 1, framesize*rate ) );\r
-            tx_bits = [1 0 zeros(1,framesize*rate-2)];\r
+            tx_bits = round( rand( 1, framesize*rate ) );\r
+            %tx_bits = [1 0 zeros(1,framesize*rate-2)];\r
 \r
             % modulate\r
 \r
@@ -215,8 +216,8 @@ function sim_out = ber_test(sim_in, modulation)
                    %if ((sc+M) > length(spread)) || ((sc+M) > length(spread_2ms))\r
                    %    sc =1 ;\r
                    %end\r
+                   comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))';\r
                    if hf_phase_only\r
-                        comb = conj(spread(sc:sc+M-1))' + conj(spread_2ms(sc:sc+M-1))';\r
                         tx_filt = tx_filt.*exp(j*angle(comb));\r
                         hf_angle_log = [hf_angle_log angle(comb)];\r
                    else\r
@@ -235,6 +236,7 @@ function sim_out = ber_test(sim_in, modulation)
                    if hf_phase_only == 0   % C already 1 if we are just tweaking phase\r
                        tx_filt *= hf_gain;\r
                    end\r
+                   C_log = [C_log abs(comb)*hf_gain];\r
                end\r
                tx_filt_log = [tx_filt_log tx_filt];\r
 \r
@@ -323,7 +325,10 @@ function sim_out = ber_test(sim_in, modulation)
             if nn == 1\r
                 tx_bits_tmp = tx_bits(skip:length(tx_bits));\r
                 rx_bits_tmp = rx_bits(skip:length(rx_bits));\r
-            end\r
+            else\r
+                tx_bits_tmp = tx_bits;\r
+                rx_bits_tmp = rx_bits;\r
+           end\r
 \r
             error_positions = xor( rx_bits_tmp, tx_bits_tmp );\r
             Nerrs = sum(error_positions);\r
@@ -340,8 +345,12 @@ function sim_out = ber_test(sim_in, modulation)
                 tx_data_buffer(framesize+1:2*framesize) = tx_bits;\r
                 s_data_buffer(Nsymb+1:2*Nsymb) = s_ch;\r
 \r
-                st_tx = (Nfiltsym-1)*bps+1;\r
-                st_s = (Nfiltsym-1);\r
+                offset = Nfiltsym-1;\r
+                if (phase_est)\r
+                    offset += floor(Nps/2);\r
+                end\r
+                st_tx = offset*bps+1;\r
+                st_s = offset;\r
 \r
                 detected_data = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, ...\r
                                 s_data_buffer(st_s+1:st_s+Nsymb), min(100,EsNo));\r
@@ -373,7 +382,8 @@ function sim_out = ber_test(sim_in, modulation)
             printf("EsNo (dB): %f  Terrs: %d BER %f BER theory %f", Es, Terrs,\r
                    Terrs/Tbits, 0.5*erfc(sqrt(EsNo/2)));\r
             if ldpc_code\r
-                printf(" LDPC: Terrs: %d BER: %f", Terrsldpc, Terrsldpc/Tbitsldpc);\r
+                printf(" LDPC: Terrs: %d BER: %f Ferrs: %d FER: %f", \r
+                       Terrsldpc, Terrsldpc/Tbitsldpc, Ferrsldpc, Ferrsldpc/(Ntrials-1));\r
             end\r
             printf("\n");\r
         end\r
@@ -385,9 +395,9 @@ function sim_out = ber_test(sim_in, modulation)
     end\r
     \r
     Ebvec = Esvec - 10*log10(bps);\r
-    sim_out.BERvec      = BERvec;\r
-    sim_out.Ebvec       = Ebvec;\r
-    sim_out.TERvec      = TERvec;\r
+    sim_out.BERvec          = BERvec;\r
+    sim_out.Ebvec           = Ebvec;\r
+    sim_out.TERvec          = TERvec;\r
     if ldpc_code\r
         sim_out.BERldpcvec  = BERldpcvec;\r
         sim_out.TERldpcvec  = TERldpcvec;\r
@@ -400,20 +410,15 @@ function sim_out = ber_test(sim_in, modulation)
         scat = rx_symb_log(2*Nfiltsym:length(rx_symb_log)) .* exp(j*pi/4);\r
         plot(real(scat), imag(scat),'+');\r
 \r
-        if hf_sim\r
-          figure(3);\r
-\r
-          if hf_phase_only\r
-              plot(hf_angle_log);\r
-              axis([1 10000 min(hf_angle_log) max(hf_angle_log)])\r
-          else\r
-            plot(abs(spread));\r
-            hold on;\r
-            plot(abs(spread_2ms),'g');\r
-            hold off;\r
-            axis([1 10000 0 1.4])\r
-          end\r
-       end\r
+        figure(3);\r
+        clf;\r
+\r
+        if hf_phase_only\r
+            plot(hf_angle_log);\r
+            axis([1 10000 min(hf_angle_log) max(hf_angle_log)])\r
+        else\r
+            plot(C_log);\r
+        end\r
     end\r
 endfunction\r
 \r
@@ -444,23 +449,23 @@ endfunction
 % Start simulations ---------------------------------------\r
 \r
 more off;\r
-sim_in.verbose = 1;\r
+sim_in.verbose = 2;\r
 \r
-sim_in.Esvec            = 1:5; \r
-sim_in.Ntrials          = 3;\r
-sim_in.framesize        = 576;\r
+sim_in.Esvec            = 5; \r
+sim_in.Ntrials          = 100;\r
+sim_in.framesize        = 100;\r
 sim_in.Rs               = 400;\r
 sim_in.phase_offset     = 0;\r
 sim_in.phase_est        = 0;\r
 sim_in.w_offset         = 0;\r
-sim_in.plot_scatter     = 0;\r
+sim_in.plot_scatter     = 1;\r
 sim_in.hf_delay_ms      = 2;\r
-sim_in.hf_sim           = 0;\r
+sim_in.hf_sim           = 1;\r
 sim_in.Np               = 6;\r
 sim_in.Ns               = 5;\r
 sim_in.hf_phase_only    = 0;\r
-sim_in.hf_mag_only      = 0;\r
-sim_in.ldpc_code        = 1;\r
+sim_in.hf_mag_only      = 1;\r
+sim_in.ldpc_code        = 0;\r
 \r
 Ebvec = sim_in.Esvec - 10*log10(2);\r
 BER_theory = 0.5*erfc(sqrt(10.^(Ebvec/10)));\r