工具/软件:Code Composer Studio
尊敬的所有人:
我的目标是获取输入信号的平方根、然后将其与载波信号相乘、以生成调幅波形。
我使用的算法为:
1) 1)读取输入信号
2) 2)将输入除以2、然后向其添加偏移。 这是为了确保输入始终为正。 例如、如果输入信号摆幅为-1V 至1V、我将在 DSP 内将其转换为0V 至1V。
3) 3)取输入的平方根。
4) 4)将其乘以载波。
问题是、调幅波的调制指数非常低。 是否有人知道如何提高调制指数。 下面是我使用的代码。
// main.c
#include "stdio.h"
#include "usbstk5505.h"
#include "usbstk5505_led.h"
#include "aic3204.h"
#include "pll.h"
#include "DSPLib.h"
#include "squareroot .h"
#include "sinewaves.h"
#include "立体声.h"
int16 left_input;
int16 right_input;
int16 left_output;
int16 right_output;
int16 mono_input;
#define SAMOESS_PER_second 192000
#define GAIN_IN_dB 30
unsigned long int i = 0;
unsigned int Step = 0;
unsigned int LastStep = 99;
unsigned int key = 0;
void main( void )
{
signed short int left_output2 = 0;
signed short int right_output2 = 0;
signed short int env = 0;
带符号短载波=0;
/*初始化 BSL */
USBSTK5505_init();
/*初始化 PLL */
PLL_FREQUENCY 设置(100);
/*初始化代码的硬件接口和 I2C */
aic3204_hardware_init();
/*初始化 AIC3204编解码器*/
aic3204_init();
asm (" BCLR XF");
对于(i = 0 ;i < samples_per_sond * 6000 ;i++ )
{
aic3204_codec_read (&left_input、&right_input);//配置为每两个通道一个中断。
MONO_INPUT =立体声_TO_MONO (LEFT_INPUT、RIGHT _INPUT);
env=generate_squareroot (mono_input);
carrier= generate_sinewave (40000,31000);
left_output2 = (short)(((long) env *(long) carrier)>>15);
right_output2 = (short)(((long) env *(long) carrier)>>15);
left_output = left_output2;
right_output= right_output2;
aic3204_codec_write (left_output、right_output);
}
/*禁用 I2S 并将编解码器置于复位状态*/
aic3204_disable();
SW_breakpoint;
}
// squarerot.c
#include "tms320.h"
#include "DSPLib.h" //TI 数学库
#include "stdio.h"
signed short int generate_squareroot (signed short int 输入)
{
signed short int SquareRoot = 0;
signed short int SquareRoot2=0;
输入=输入>> 1;
输入=输入+ 0x3FFF;
SquareRoot =输入;
sqrT_16 (&SquareRoot、&SquareRoot2、1);//获取正弦曲线的平方根并将平方根存储到 SquareRoot 中
返回 SquareRoot2;
}