## ## ************************************************* ## *** Same as ex06.nap *** ## *** *** ## *** But we choose to expand "tool.hdr" *** ## *** *** ## *** Compare the C files of both examples *** ## *** *** ## ************************************************* ## header // ******* HERE ************* fs 1.0e+6 dvar freq 1000.0 dvar ampl 0.5 #* ******** Parameters used by tool (Goertzel) ********* #* Very often tool are controlled by directive. Have a look on tool #* documentation, or the tool itself to have an overview of the various #* possibilities. Here 'NGFT' controls the number of FT's is used to #* obtain a mean value. All these directives are optional as they have #* a default value (1 for 'NGFT'). directive NGFT 4 #* ivar npts 102000 dvar norm 1.0 #* We are using a function defined into header directory #* producing a sweep of frequencies coherent with the analysis #* The sweep is controlled by 'TOOL_INDEX' which is directly #* under the control of the analysis tool. As soon as the tool has #* finished one analysis, the simulator increases 'TOOL_INDEX' #* Sweep here is linearly dependant on the value of tool index. #* If for some reasons, you want to have a logarithmic plot, #* you should consider to use 'coherent_logsweep' instead. #* Please note that an 'update' of 'fz' is necessary to trigger #* a new evaluation of fz at each loop of the simulation. dvar fz coherent_linsweep(TOOL_INDEX, 1000.0, 10000.0, 10, npts) &update &export #* 'fz' is playing an important role in the simulation. Exporting #* this variable with 'export' instruction. It will produce a #* kind of message to the analysis tool. This tool will consider #* to output the value of 'fz' together with its regular output. #* ****************** Simulation ******************** node aref dc 1.0 node i1 sine 0.0 ampl freq 0.0 node in adc 1024 i1 aref node out cell modulator "ds2.net" in 512 #* ****************** Analyse ******************** #* output frequency of interest #* file name | #* Tool name | Signal is | number of points #* | | ** / norm | for goertzel #* _|_ _______|___ ___|_____ _|_ __|_ tool gft "gft1.out" out norm fz npts terminate fz >= 10000.0 #* It is very important to cross-check the termination condition. If 'fz' #* is not updated, the simulation will never end.