给出LSB / V的正弦波

时间:2017-12-02 23:19:57

标签: c signals frequency wave sine

我创建一个电压信号的正弦波。 如何在128 LSB / V的比例因子中表示? 幅度为180伏。 Obs:我猜LSB是“低位意义”。

我的代码:

int main(int argc, char **argv) {
    int i = 0;
    short value;
    double amp = 180, freq = 60, freq_samp;

    freq_samp = atof(argv[2]);
    printf("\n** Sample frequency: %f **",freq_samp);
    while(1) {
        value = amp*sin(2*i*PI*freq/freq_samp);
        printf("\nValue = %d",value);
        i = i + 1;
        sleep(1);
    }

    return 0;
}

1 个答案:

答案 0 :(得分:0)

我只是创建一个LSB​​变量e然后做幅度* LSB:

int main(int argc, char **argv) {
    int i = 0;
    short value, LSB;
    double amp = 180, freq = 60, freq_samp;

    freq_samp = atof(argv[2]);
    printf("\n** Sample frequency: %f **",freq_samp);
    while(1) {
        value = LSB*amp*sin(2*i*PI*freq/freq_samp);
        printf("\nValue = %d",value);
        i = i + 1;
        sleep(1);
    }

    return 0;
}