2010-02-18 71 views
0

我試圖模擬IEEE 802.15.4/ZigBee的PHY,...modem.oqpskmod - > modem.oqpskdemod不相同的結果

chip_values = [ 
    1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0; 
    1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0; 
    0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0; 
    0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1; 
    0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1; 
    0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1,1,1,0,0; 
    1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1,1,0,0,1; 
    1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,1,0,1,1,0,1; 
    1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1; 
    1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1; 
    0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1; 
    0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0; 
    0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1,0,1,1,0; 
    0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,0,1; 
    1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0,1,1,0,0; 
    1,1,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,0,0,0]; 

    tx = []; 
    values = randsrc(1,1,[0:15]); 
    for k=1:length(values) 
    sym = values(k); 
    tx = [tx chip_values((sym+1),1:end)]; 
    end; 

    tx = tx.'; 
    h = modem.oqpskmod; 
    y = modulate(h, tx); 
    g = modem.oqpskdemod(h); 
    z = demodulate(g, y); 
    length(z) 
    for k=1:length(tx) 
    if(tx(k)~=z(k)) 
    fprintf('%d %d\n',tx(k),z(k)); 
    end; 
    end; 

我的問題是,在這個簡單的例子,爲什麼我的TX和z不包含相同的值,儘管我沒有引入任何噪音?謝謝! TX的

值來如下:

列14到26

1  1  1  1  0  1  1  1  0  0  0  1  1 

列27至32

0  0  1  0  0  1 

列1至13

0  1  1  0  0  0  0  0  0  1  1  1  0 
z com ES如下:

列1至13

3  0  1  1  0  0  0  0  0  0  1  1  1 

列14到26

0  1  1  1  1  0  1  1  1  0  0  0  1 

列27至32

1  0  0  1  0  0 


    h = 

     Type: 'OQPSK Modulator' 
      M: 4 
    PhaseOffset: 0 
Constellation: [1x4 double] 
    SymbolOrder: 'Binary' 
SymbolMapping: [0 1 2 3] 
    InputType: 'Integer' 

    g = 

     Type: 'OQPSK Demodulator' 
      M: 4 
    PhaseOffset: 0 
Constellation: [1x4 double] 
    SymbolOrder: 'Binary' 
SymbolMapping: [0 1 2 3] 
    OutputType: 'Integer' 
DecisionType: 'Hard decision' 
+0

您的輸入和輸出是邏輯類型嗎?如果他們是浮點數,你可能會遇到比較錯誤。 – gnovice 2010-02-19 03:56:40

+0

我不想通過強制將它們轉換,我想了解它爲什麼會按照它現在的方式執行它:)提前致謝! – 2010-02-24 07:35:46

回答

0

這對我來說很難,因爲我不知道沒有安裝通訊工具箱,但我建議使用示例中給出的更簡單的輸入來嘗試在文檔中的mples。使用

tx = randint(10,1,8) 

例如。然後看看輸出,而不僅僅是比較。機器精度還是差不多?你不告訴我們打印什麼(他們是否匹配?)。嘗試考慮tx和z之間的差異。它接近eps(對我來說是2.2204e-016)?

數據傳入和數據傳出之間是否存在切換?告訴我們這些數據是怎麼回事。

更新

我很高興你張貼實際的輸入和輸出。它看起來像z向右移動(並且由於某種原因在開始處有3),這意味着你失去了最後一位。縱觀Matlab documentation,還有一張紙條,上面寫着

OQPSK解調器有1個符號 延遲。

我認爲這可以解釋這個問題。基本上,在調製器的輸入端添加一個額外的0,從解調器的輸出中取出第一個元素,然後開始工作。

+0

對於遲到的回覆感到遺憾,我已經提供了更多信息......提前致謝! – 2010-02-24 07:24:05