Tool/software: Code Composer Studio
Dear All,
My objective is to take square root of the input signal and then multiply it with carrier signal to generate the amplitude modulated wave.
The algorithm I am using is:
1) Read the input signal
2) Divide the input by 2 and then add offset to it. This is to ensure that the input is always positive. For example, if input signal swing is -1 V to 1V, I am converting it to 0 to 1V inside DSP.
3) Take square root of input.
4) Multiply it with carrier.
The problem is that, the modulation index of amplitude modulated wave is very low. Does anyone know how to increase the modulation index. Below is the code I am using.
// 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 "stereo.h"
Int16 left_input;
Int16 right_input;
Int16 left_output;
Int16 right_output;
Int16 mono_input;
#define SAMPLES_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;
signed short carrier =0;
/* Initialize BSL */
USBSTK5505_init( );
/* Initialize PLL */
pll_frequency_setup(100);
/* Initialise hardware interface and I2C for code */
aic3204_hardware_init();
/* Initialise the AIC3204 codec */
aic3204_init();
asm(" bclr XF");
for ( i = 0 ; i < SAMPLES_PER_SECOND * 6000 ;i++ )
{
aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
mono_input = stereo_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);
}
/* Disable I2S and put codec into reset */
aic3204_disable();
SW_BREAKPOINT;
}
// squareroot.c
#include "tms320.h"
#include "dsplib.h" //TI math library
#include "stdio.h"
signed short int generate_squareroot(signed short int input)
{
signed short int SquareRoot = 0;
signed short int SquareRoot2 = 0;
input = input >> 1;
input = input + 0x3FFF;
SquareRoot = input;
sqrt_16(&SquareRoot, &SquareRoot2, 1); // take square root of sinusoid and store the squared root into SquareRoot
return SquareRoot2;
}