Commit 2b40675b authored by Roberto Louro Magueta's avatar Roberto Louro Magueta

Apply Doppler Effect

parent 52381833
......@@ -29,6 +29,7 @@
#include "sim.h"
//#define DEBUG_CH
//#define DOPPLER_DEBUG
uint8_t multipath_channel_nosigconv(channel_desc_t *desc)
{
......@@ -201,6 +202,11 @@ void __attribute__ ((no_sanitize_address)) multipath_channel(channel_desc_t *des
}
#endif
struct complexd cexp_doppler[length];
if (desc->max_Doppler != 0.0) {
get_cexp_doppler(cexp_doppler, desc, length);
}
for (int i=0; i<((int)length-dd); i++) {
for (int ii=0; ii<desc->nb_rx; ii++) {
struct complexd rx_tmp={0};
......@@ -216,13 +222,22 @@ void __attribute__ ((no_sanitize_address)) multipath_channel(channel_desc_t *des
}
if (i==0 && log_channel == 1) {
printf("channel[%d][%d][%d] = %f dB \t(%e, %e)\n",
ii, j, l, 10*log10(pow(chan[l].r,2.0)+pow(chan[l].i,2.0)),
chan[l].r,
chan[l].i);
ii, j, l, 10 * log10(pow(chan[l].r, 2.0) + pow(chan[l].i, 2.0)), chan[l].r, chan[l].i);
}
} //l
} // j
if (desc->max_Doppler != 0.0)
rx_tmp = cdMul(rx_tmp, cexp_doppler[i]);
#ifdef DOPPLER_DEBUG
printf("[k %2i] cexp_doppler = (%7.4f, %7.4f), abs(cexp_doppler) = %.4f\n",
i,
cexp_doppler[i].r,
cexp_doppler[i].i,
sqrt(cexp_doppler[i].r * cexp_doppler[i].r + cexp_doppler[i].i * cexp_doppler[i].i));
#endif
rx_sig_re[ii][i+dd] = rx_tmp.r*path_loss;
rx_sig_im[ii][i+dd] = rx_tmp.i*path_loss;
#ifdef DEBUG_CH
......
......@@ -453,7 +453,7 @@ void tdlModel(int tdl_paths, double *tdl_delays, double *tdl_amps_dB, double DS
}
}
void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc)
void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length)
{
// TS 38.104 - Table G.3-1
uint16_t Dmin = 2;
......@@ -466,9 +466,10 @@ void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc)
#endif
double phase0 = 2 * M_PI * uniformrandom();
double cos_theta[chan_desc->channel_length];
double fs[chan_desc->channel_length];
for (int t_idx = 0; t_idx < chan_desc->channel_length; t_idx++) {
double cos_theta[length];
double fs[length];
for (uint32_t t_idx = 0; t_idx < length; t_idx++) {
double t = t_idx / (chan_desc->sampling_rate * 1e6);
if (t >= 0 && t <= Ds / v) {
cos_theta[t_idx] = (Ds / 2 - v * t) / sqrt(Dmin * Dmin + (Ds / 2 - v * t) * (Ds / 2 - v * t));
......@@ -1898,6 +1899,7 @@ int random_channel(channel_desc_t *desc, uint8_t abstraction_flag) {
#ifdef DEBUG_CH
printf("(%d,%d,%d)->(%e,%e)\n",k,aarx,aatx,desc->ch[aarx+(aatx*desc->nb_rx)][k].r,desc->ch[aarx+(aatx*desc->nb_rx)][k].i);
#endif
} //channel_length
#ifdef DEBUG_CH_POWER
ch_power_count++;
......
......@@ -348,6 +348,15 @@ void set_channeldesc_owner(channel_desc_t *cdesc, channelmod_moduleid_t module_i
\param module_name is the C string to use as model name for the channel pointed by cdesc
*/
void set_channeldesc_name(channel_desc_t *cdesc,char *modelname);
/** \fn void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length)
\brief This routine generates the complex exponential to apply the Doppler shift
\param cexp_doppler Output with the complex exponential of Doppler shift
\param desc Pointer to the channel descriptor
\param length Size of complex exponential of Doppler shift
*/
void get_cexp_doppler(struct complexd *cexp_doppler, channel_desc_t *chan_desc, const uint32_t length);
/** \fn void random_channel(channel_desc_t *desc)
\brief This routine generates a random channel response (time domain) according to a tapped delay line model.
\param desc Pointer to the channel descriptor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment