【问题标题】:RTL SDR IQ AM DemodulationRTL SDR IQ AM 解调
【发布时间】:2020-07-21 05:15:17
【问题描述】:

我现在正在工作的项目正在调整 PMR 频率并将音频保存到 WAV 文件,但是当 我从 SDR 设备接收 IQ 样本,然后解调为 AM - 我只听到噪音。

编辑,这是写入 WAV 文件的 RAW IQ: https://voca.ro/iSRELps4JBg

对于解调,我使用了这种方法:

https://github.com/simonyiszk/minidemod/blob/master/minidemod-wfm-atan.c

但是声音似乎是噪音......

  while(get_samples(buffer, buffer_size) == 1)
    {


        // Demodulate to AM
        uint8_t uiAMBuff[buffer_size];

        double i1=0, i2, q1=0, q2;
        short s; // 2 bytes
        double sum=0;
        double dbAmp=0;
        for (int i = 0; i < buffer_size; i+=2)
        {
            // I / Q

            i2=((unsigned char)buffer[i]-127);
            q2=((unsigned char)buffer[i+1]-127);


            double phi1=get_phase(i1,q1);
            double phi2=get_phase(i2,q2);

            double dphi=phi2-phi1;
            if(dphi<-PI) dphi+=2*PI; //dphi below -180°? Let's interpret it in the other direction!
            if(dphi>PI) dphi-=2*PI;  //dphi above 180°? Let's interpret it in the other direction!

            // Now let's use signed 16 bit output rather than 8 bit unsigned.
            s=((SHRT_MAX-1)/PI)*dphi; //Okay so let's get the actual sample. dphi should be between -PI and +PI.

            // Store AM in the buffer that gets written to a WAV file
            uiAMBuff[i]=s;
            uiAMBuff[i+1]=s>>8;

            i1=i2;
            q1=q2;
            // This is to calculate DB
            double y = s/32768.0;
            sum += y * y; 

        }

请问如何正确解调IQ到AM?

【问题讨论】:

    标签: c signal-processing rtl-sdr


    【解决方案1】:

    您的代码用于 FM 解调器(频率作为相位的导数,或离散情况下的相位增量)。对于 AM 解调,您只需要获取 IQ 分量的幅度 (abs()) 和低通滤波器。

    【讨论】:

    • 谢谢 hotpaw2,我想念什么......我仍然保持这个线程打开,因为问题是如何在 C/C++ 中解调为 AM
    【解决方案2】:

    我想自己发布一个答案。

    这是我如何将 IQ (RTLSDR) 解调为 AM,从 SDR 中采样。

    uint8_t uiAMBuff[buffer_size];

    float sum=0;
    
    for (int i = 0; i < buffer_size; i+=2)
    {
    
        // Get 0 - 255
        int _i=buffer[i];
        int _q=buffer[i+1];
    
        // This will range : 0 - 32768 (short) 2 bytes
        short amplitude = sqrt((_i*_i)+(_q*_q));
        if(amplitude > 32768) amplitude = 32768;
    
        // Store in separate buffer (serialize) 2 bytes
        uiAMBuff[i]=amplitude>>0;
        uiAMBuff[i+1]=amplitude>>8;
    
        // Calculate AM Amplitude which is always 0..1 thats why division by 32768.0
        sum += amplitude / 32768.0;
    
    }
    

    【讨论】:

      猜你喜欢
      • 2021-04-19
      • 2018-10-23
      • 2019-07-31
      • 1970-01-01
      • 2021-01-18
      • 2019-07-06
      • 2016-02-11
      • 1970-01-01
      • 2021-05-31
      相关资源
      最近更新 更多