首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RTL SDR IQ AM解调

RTL SDR IQ AM解调
EN

Stack Overflow用户
提问于 2020-04-09 01:38:32
回答 2查看 866关注 0票数 0

我现在工作的项目目前正在调谐PMR频率和保存音频到WAV文件,但是,当我从SDR设备接收IQ样本,并解调到am -我只听到噪声。

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

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

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

然而,声音似乎是噪音...

代码语言:javascript
复制
  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?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-04-11 07:23:34

我想自己发布一个答案。

下面是我如何将IQ (RTLSDR)解调到AM,从SDR中获取样本。

uint8_t uiAMBuffbuffer_size;

代码语言:javascript
复制
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;

}
票数 1
EN

Stack Overflow用户

发布于 2020-04-09 07:11:36

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61106688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档