Source Code
Infrared Signal Coding Schemes
home top contents previous up next

%Test case for PAM with ISI, shot noise, and ambient light.

		%=============================
		% Sub Model Usage
		%-----------------------------
        global shotNoisePresented
        shotNoisePresented=1
        global amInteferenceSummationPoints;
        %global ambientLightPresented
        %ambientLightPresented=0
           %Set this parameter to 1 to disable ambient light:
           %To enable ambient light, set this parameter to number of points over which 
           %averaging via interference interval is desired:
           %Accracy is proportional to this number:
        amInteferenceSummationPoints=2;
		%=============================
		
		%=============================
		% Default parameters
		%-----------------------------
		global ceilingHeight
		global Amax
	    global L
		global Rb
		global SNR
        global amSAR
        global amInterferencePeriodTi
		ceilingHeight=3.5 %Height of the room.
		Amax=3 %Number of non-zero  amplitude levels.
	    L=2 %Maximum number of chips in symbol
		Rb=100000000
		SNR=7 %Signal To Noise Ratio, db
        amInterferencePeriodTi=25.0e-6 %In seconds.
        amSAR=1.0 %Signal to Ambient light Ratio.  = amSAR = 1/K where K is parameter from [Wong at all].

   	    global OOK_threshold; %In units of minumum non-zero chip.
        OOK_threshold=0.5
		%=============================

		%=============================
		%Derivative parameters:
		global a %ISI length parameter in chips. Parameter of h-function.
	    global SN %SNR not in dB form:	    
		global T %Chip length, seconds.
	    global avLength %Average number of chips in symbol.
		global aphabetCount %Number of symbols in alphabet
		global M %Bits per symbol
		global bitsPerChip
		global scaled_chip_length %T/a
	    global tapsNumber %"Memory" of multipath channel.
	    global beta  %Discretized h., Array
        global bh %Convolution b*h, Array
	    global lambda %(min non-zero Intensity)/average Intensity:
		%=============================

        
   	    %=============================
		% Spawn parameters
	    %----------------------------
        a=2.0*ceilingHeight/300000000.0
		
        avLength=L
        aphabetCount=1;
        for i=1:L
            aphabetCount=aphabetCount*(Amax+1);
        end
        aphabetCount

        M=log(aphabetCount)/log(2.0)
        lambda=2.0/Amax
        
        %Part II:
        bitsPerChip=M/avLength
		T=bitsPerChip/Rb

		scaled_chip_length=T/a

        %-------------------------------------------------------
        %estimation of size of sequence beta:
        %- - - - - - - - - - - - - - - - - - - - - - - - - - - -
        accuracyEps=1.0e-3
        hThresholdTs= (1.0/accuracyEps)^(1.0/6.0) - 1;
        if hThresholdTs<1.0 
           hThresholdTs=1.0
        end   
        hThresholdTs
        %mark temporary variable with "w":
        wtapsNumber = hThresholdTs/scaled_chip_length
        tapsNumber  = int32(floor(wtapsNumber)) + 1 %1 is taken for safety.
        wTruncationParameterForCuriosity=wtapsNumber / (a/T)
        %tapsNumber= int32(floor((a/T*1.25)))+1
        %-------------------------------------------------------
			
		%Convert SN from dB to numbers:
		SN=exp( SNR/10.0*log(10.0) )
        
        %Adjust x-scale adopted in MatLab for erfc:
        SN=SN/sqrt(2.0);
   	    %=============================

		beta=[1:tapsNumber];
        bh=[1:tapsNumber+L]; %Reserve space. Perhaps we will need only last element.
        %Create beta:
		for k=1:tapsNumber
			beta(k)=betaPortion(k-1, scaled_chip_length);
	    end
        beta %This simply prints arrya beta (to console?)
        q=[1:tapsNumber];
        %plot(q,beta,'r');
        %legend("beta");
        %hold on
    
        am_prepare();
        simulateThresholding();
        
        

Copyright (C) 2009 Konstantin Kirillov