淘宝官方店     推荐课程     在线工具     联系方式     关于我们  
 
 

微波射频仿真设计   Ansoft Designer 中文培训教程   |   HFSS视频培训教程套装

 

Agilent ADS 视频培训教程   |   CST微波工作室视频教程   |   AWR Microwave Office

          首页 >> Ansoft Designer >> Ansoft Designer在线帮助文档


Ansoft Designer / Ansys Designer 在线帮助文档:


Nexxim Simulator >
Nexsys Discrete Time Domain Analysis >
   Nexsys MATLAB User Defined Models >
       Example MATLAB Model Files >
           Digital Clock Model               


Digital Clock Model

Here is a model for a digital clock source. This SOURCE type model has no inputs and one output. Here is a listing of the model file, dclock.m, with explanations.

The initial comment line (identified by %NEXSYS) is the model definition line. Nexsys reads the model definition into a structure that contains various information the simulator needs.

% NEXSYS FUNCTIONAL_MODEL ("dclock", "0","", "", "1","r", "1","NO_DATA_REQ", "NOT_APPLICABLE", "PERIOD,DELAY=0,DUTY=0,NSAMP,SAMPLE_RATE")

Here are explanations for the entries in the dclock model definition


“dclock”

Model name. The model name, dclock, is also the Matlab function name.

“0”

No inputs

“”

No input data types

“”

No input number of samples

“1”

One output

“r”

The single output is real

“1”

One (1) sample is to be generated per invocation

“NO_DATA_REQ”

No extra data reference is required

“NOT_APPLICABLE”

No probe domain applies

"PERIOD,DELAY=0,DUTY=0,NSAMP,SAMPLE_RATE"

Parameters for the model


Here is the Matlab function declaration for the digital clock. The function name, dclock in this example, is the same as model name.

function [ y, SV ] = dclock (p, SV, status_in)

The input and output variables for the function are:


p

Parameter values of the model

SV

State variable (in)

status_in

Input status

y

Output signal

SV

State variable (out)


The first step is to read the values from the parameters passed to the function.

% Get parameters from function argument p

period = p(1)
delay = p(2)
duty = p(3)
sample_rate = p(5)
time_step = 1.0/p(5)

During the initialization call, the dclock model sets up its state variables structure SV. During later calls, the model retrieves the data.

total_num_out = 0;

% (status_in == 0) => Analysis initialization stage

if status_in == 0

delay_mode = 0;

if (delay > 0)

delay_mode = 1;

end

time_pos = 0.0;

total_out_num = 0;

SV = [delay_mode time_pos total_num_out]

else

delay_mode = SV(1);

time_pos = SV(2);

total_num_out = SV(3);

end

Here is how dclock calculates the output (digital clock) values:

out_value = 0.0;

if delay_mode == 1

time_elapsed = (total_num_out + 1) / sample_rate;

if (delay > time_elapsed)

out_value = 0.0;

else

delay_mode = 0;

end

else

if ((time_pos>=0) && (time_pos < (duty * period)))

out_value = 1.0;

else

out_value = 0.0;

end

%re-calculate the time position

time_pos = time_pos + 1.0 / sample_rate;

if (time_pos >= period)

time_pos = time_pos - period;

elseif (time_pos == period)

time_pos = 0.0;

end

end

y(1) = out_value;

total_num_out = total_num_out + 1;

Finally, dclock saves its state variables SV and returns.

SV = [delay_mode time_pos total_num_out];

return




HFSS视频教学培训教程 ADS2011视频培训教程 CST微波工作室教程 Ansoft Designer 教程

                HFSS视频教程                                      ADS视频教程                               CST视频教程                           Ansoft Designer 中文教程


 

      Copyright © 2006 - 2013   微波EDA网, All Rights Reserved    业务联系:mweda@163.com