Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » bele
  • » Profile

Posts

Posts

Apr-17-19 13:51:21
Category: Programming

Yeah! Now I got the basic problem. Now I am trying to rectify in entire code.

one more help: How should I implement hann window in this code?   

Apr-17-19 13:41:16
Category: Programming

Thanks a lot. error eliminated

Apr-17-19 13:28:48
Category: Programming

Integer x1 = 0;
Integer x2 = 1;
Integer n = 512;

V = linspace(x1, x2, n);
d_vec = V.*limits_d_max;

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[1] 15:27:58 Translation Error
[IFphasemodel_3: 129:1-129:22]: Type mismatch in equation V=array(/*Real*/(x1) + (/*Real*/(x2) - /*Real*/(x1)) * /*Real*/(-1 + i) / /*Real*/(-1 + n) for i in 1:n) of type Real=Real[n].

[2] 15:27:58 Translation Error
Error occurred while flattening model IFphasemodel_3

Apr-17-19 12:46:53
Category: Programming

as my value of n=512, I tried with
1) d_vec = linspace(x1, x2, n).*limits_d_max; ..................(with defining input n=512)
2) d_vec = linspace(x1, x2, 512).*limits_d_max;
3) d_vec = linspace(x1, x2, sqrt(22.62)).*limits_d_max;

still the error is same

Apr-16-19 13:50:46
Category: Programming

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I want to impliment linspace but got an error like above:

[1] 15:38:31 Translation Error
[IFphasemodel_3: 130:1-130:80]: Type mismatch for positional argument 3 in linspace(n=n). The argument has type:
  Real
expected type:
  Integer

[2] 15:38:31 Translation Error
Error occurred while flattening model IFphasemodel_3

Please help me to rectify it and let me know if you found any other wrong argument as I am converting a Matlab program into openmodelica. 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
model IFphasemodel_3

input Real c = 3e8                       "speed of light";
parameter Integer[2] param_p = {0,0}     "position of radar";
parameter Integer param_N_ant_rx = 4;
input Integer SNR = 0                    "rx snr [dB]";

Real[2,2] objects_p_0 = {{0,20},{0,10}} "object's initial (cartesian) positions";
input Real[2,2] position_0 = transpose(objects_p_0);
Real[2,2] objects_v = {{0,10}, {0,0}}  "object's initial velocities in x and y directions in [m/s]";
input Real[2,2] velocity_0 = transpose(objects_v);
input Integer[1] objects_rcs = {10}     "object's RCS in dBm^2";
input Integer[2] objects_alpha = {1,1}  "amplitude of object, in this simple model, no radar equation is used";
input Integer objects_M = size(objects_alpha, 1);

input Real sig_B_sw = 1e9              "sweep BW, [Hz]";
input Real sig_f_0 = 77e9              "start frequency [Hz]";
input Real sig_T_sw = 24e-6            "sweep time (of one sweep/ramp) [s]";
input Integer sig_N_sw = 128              "number of sweeps/ramps";
input Real sig_N_samp_per_ramp = 1024.0  "number of fast-time samples (ADC samples per ramp)";
input Real sig_f_s = 25e6              "sampling frequency";
input Real x1 = 0;
input Real x2 = 1;
input Real n = 0.5.*sig_N_samp_per_ramp;

output Integer objects_d_0_true;
output Integer objects_v_true_abs;
output Integer p_diff;
output Integer p_u;
output Integer objects_v_r_true;
output Integer objects_AoA;
output Integer cos_phi;
output Integer sig_T_s;
output Integer sig_k;
output Integer sig_lambda;
output Integer param_ant_rx_spacing;
output Integer sig_t_sw;

output Integer sig_IF;
output Integer delta_d;
output Integer T_sw;
output Integer T_sw_cont;
output Integer sig_temp;
output Integer d_0_i_m;
output Integer tau_0_i_m;
output Integer Tau;
output Integer phi_m;

output Integer sig_power;
output Integer noise_power;
output Integer sig_noise_temp;
output Integer limits_d_max;
output Integer limits_d_res;
output Integer limits_v_max;
output Integer limits_v_res;
output Integer d_vec;
output Integer v_vec;
output Integer win_range;
output Integer sig_IF_win;
output Integer S_range;
output Integer win_doppler;
output Integer S_range_win;
output Integer S_RD;



equation
sig_T_s = 1/sig_f_s "sampling time";
sig_k = sig_B_sw/sig_T_sw  "sweep slope [Hz/s]";
sig_lambda = c/(sig_f_0+sig_B_sw/2);
param_ant_rx_spacing = c/sig_f_0/2     "RX antenna spacing [m]";
sig_t_sw = 0:sig_T_s:(sig_N_samp_per_ramp-1)*sig_T_s;
sig_t_sw = sig_t_sw[:];


objects_d_0_true = zeros(objects_M,1) "convert object parameters to channel parameters - d + v + AoA";
objects_AoA = zeros(objects_M,1);
objects_v_r_true = zeros(objects_M, 1);


for m in 1:objects_M loop
    objects_d_0_true(m) = norm(param_p-position_0[:,m])    "distance";
    objects_v_true_abs(m) = norm(velocity_0[:, m])           "absolute velocity";
    p_diff = position_0[:,m]-param_p                 "vector from radar to object";
    p_u = -p_diff/norm(p_diff)                        "unit vector from object to radar";
    when(objects_v_true_abs(m) > eps) then
        cos_phi = transpose(velocity_0[:,m])* p_u/ objects_v_true_abs(m); 
        objects_v_r_true(m) = objects_v_true_abs(m)*cos_phi      "radial velocity";
    end when;
    objects_AoA(m) = atan2(p_diff(2), p_diff(1))-pi/2            "angle of arrival";
end for;


equation
T_sw_cont = T_sw + sig_T_sw*repmat(0:(sig_N_sw-1), sig_N_samp_per_ramp, 1) "continued time matrix - continuous also along sweep dimension";
delta_d = (param_ant_rx_spacing .* sin(objects_AoA)) "distance difference of arrival at RX antennas";   
T_sw = sig_t_sw*ones(1,sig_N_sw) "base time matrix - same for all sweeps";
T_sw_cont = T_sw + sig_T_sw*repmat(0:(sig_N_sw-1), sig_N_samp_per_ramp, 1) "continued time matrix - continuous also along sweep dimension";


for i_ant in 1:param_N_ant_rx loop
    sig_temp = zeros([sig_N_samp_per_ramp,sig_N_sw])   "temporary to sum up object signals";
    for m in 1:objects_M  loop             
        d_0_i_m = objects_d_0_true(m)      "current distance of i-th antenna";
        tau_0_i_m = (2*d_0_i_m + delta_d(m).*(i_ant-1))/c "RTDT of i-th antenna - start of first sweep";
        Tau = tau_0_i_m + 2*objects_v_r_true(m)/c .* T_sw_cont "compute phase of m-th IF signal";
        phi_m = 2*pi*sig_k.*Tau.*T_sw + 2*pi.*Tau.*sig_f_0 - pi .*sig_k.*Tau.^2;
           
        sig_temp = sig_temp + objects_alpha(m)*cos(phi_m);
       
    end  for;
   
    sig_power = 10*log10(sum(abs(sig_temp[:].^2))./ (sig_temp[:])) "calculate signal and noise power and generate noise";
    noise_power = sig_power-SNR;
    sig_noise_temp = sqrt(10^(noise_power/10))*randn(size(sig_temp));
    sig_IF[:,:,i_ant] = sig_temp + sig_noise_temp "total IF signal";
   
end  for;

equation

limits_d_max = c*sig_f_s/4/abs(sig_k) "resolution and basis vectors";

limits_d_res = c/2/abs(sig_B_sw);
limits_v_max = c/(4*sig_f_0*sig_T_sw); 
limits_v_res = c/(2*sig_f_0*sig_T_sw*sig_N_sw);


d_vec = linspace(x1, x2, n).*limits_d_max "distance vector for first stage DFT";
v_vec = transpose({-sig_N_sw/2 : sig_N_sw/2-1})/sig_N_sw.* 2*limits_v_max "velocity vector";

win_range = fill(hann(sig_N_samp_per_ramp), 1, sig_N_sw, param_N_ant_rx) "Range/Doppler processing - windowing in fast-time";
sig_IF_win = sig_IF* win_range;

S_range = 1/sqrt(sig_N_samp_per_ramp) * realFFT(sig_IF_win, sig_N_samp_per_ramp)"Range/Doppler processing - FFT over fast-time";
S_range = S_range[1:length(d_vec), :, :] "Range/Doppler processing - cut out positive side of spectrum";

win_doppler = transpose(fill(hann(sig_N_sw)), length(d_vec), 1, param_N_ant_rx) "windowing in slow-time/ramps";
S_range_win = S_range.*win_doppler;
S_RD = 1/sqrt(sig_N_sw) * realFFTsamplePoints(S_range_win, sig_N_sw, 2) "FFT over slow-time/ramps";

end IFphasemodel_3;

Apr-08-19 11:21:35
Having issues with an equation that has a transpose function in it
Category: Programming

Thanks a lot @perost. It worked

Apr-07-19 16:57:12
Having issues with an equation that has a transpose function in it
Category: Programming

input Real objects_p_0 = transpose({0,20},{0,10});

error: Wrong type or wrong number of arguments to transpose({0, 20}, {0, 10}).
(in component <NO COMPONENT>).

how can I solve this one?

Mar-29-19 10:12:42
Conversion of Matlab Code into Openmodelica
Category: Programming

Hello,

I am new to Openmodelica. I want to convert a Matlab code into Openmodelica. is it possible?

many thanks in advance!

  • Index
  • » Users
  • » bele
  • » Profile
You are here: