10.06.2016 Views

eldo_user

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Eldo Control Language<br />

Library of Functions for Tasks<br />

* Parallel RLC circuit.<br />

vin 1 0 ac 10<br />

r2 1 2 50<br />

r3 2 3 50k<br />

r5 3 0 50<br />

l1 2 3 100u<br />

c4 2 3 10n<br />

.ac dec 10 1 1g<br />

.option eps = 1.0e-6<br />

.plot w2=v(2) w1=v(1)<br />

.define_task plot_bandwidth<br />

set w1 = 0<br />

set w2 = 0<br />

set w_db_gain = 0<br />

set w_bandwidth = 0<br />

set fcut[] = 0<br />

/* Run the simulation and calculate gain. */<br />

simulation(w1 = @w1, w2 = @w2)<br />

/* Compute the gain and save the waveform. */<br />

w_db_gain = db(w2 / w1)<br />

wsave(wstdout, w_db_gain, "results")<br />

/* Compute the -3dB bandwidth. */<br />

fcut = xval(w_db_gain, -3)<br />

if (fcut.size != 2)<br />

fprint(stdout, "Failed to compute the -3dB bandwidth.\n")<br />

return -1<br />

else<br />

fprint(stdout, "\n\t-3dB bandwidth = (%.2eHz, %.2eHz)\n",<br />

fcut[fcut.imin], fcut[fcut.imin + 1])<br />

endif<br />

/* Create enum data type: 0: cut, 1: pass. */<br />

wcreate_data_type("cut_pass", "-Enum")<br />

wadd_data_enum_value("cut_pass", "cut", 0)<br />

wadd_data_enum_value("cut_pass", "pass", 1)<br />

/* Create the waveform showing graphically the -3dB bandwidth. */<br />

w_bandwidth = wcreate_wave(wstdout, "bandwidth", "results",<br />

"double_frequency", "cut_pass", "-LOG_X")<br />

/* It is usually more efficient to create 2 vectors for x and y values<br />

and call wset_values only once. But here since there are few values, it is<br />

not a real problem to do this: */<br />

wset_values(w_bandwidth, 1, 0)<br />

wset_values(w_bandwidth, fcut[fcut.imin], 1)<br />

wset_values(w_bandwidth, fcut[fcut.imin + 1], 0)<br />

wset_values(w_bandwidth, 1G, 0)<br />

fprint(stdout, "\n\tPlot of bandwidth succeeded.\n")<br />

.end_define_task<br />

976<br />

Eldo® User's Manual, 15.3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!