Controlled Square Wave Oscillator

This function is a controlled square wave oscillator with parameterizable values of low and high peak output, duty cycle, rise time, and fall time. It takes an input voltage or current value. This value is used as the independent variable in the piecewise linear curve described by the coordinate points of the cntl_array and freq_array pairs. From the curve, a frequency value is determined, and the oscillator will output a square wave at that frequency. From the above, it is easy to see that array sizes of 2 for both the cntl_array and the freq_array will yield a linear variation of the frequency with respect to the control input. Any sizes greater than 2 will yield a piecewise linear transfer characteristic. For more detail, refer to the description of the piecewise linear controlled source, which uses a similar method to derive an output value given a control input.

Alternatively to the pair of parameters cntl_array and freq_array it is possible to determine the frequency of the VCO using the pair of parameters FC and KF.

Port Table

Description Direction Default Type Allowed Types Vector Vector Bounds Null Allowed
Input IN v v,vd,i,id,vnam NO   NO
Output OUT v v,vd,i,id NO   NO

Parameter Table

Name Description Data Type Default Value Limits Vector Vector Bounds Null Allowed
cntl_array control in array Real 0.0   YES 2 / - NO
freq_array frequency array Real 1.0e3 0 / - YES 2 / - NO
FC center Frequency Real 1.0e6   NO   YES
KF frequency sensitivity in Hz/Volt Real 1.0e5   NO   YES
out_low output low value Real -1.0   NO   YES
out_high output high value Real 1.0   NO   YES
duty_cycle duty cycle Real 0.5 1e-6 / 0.999999 NO   YES
rise_time rise time Real 1.0e-9   NO   YES
fall_time fall time Real 1.0e-9   NO   YES

Error Messages

SQUARE: Error allocating square block storage

Generic storage allocation error.

SQUARE: Frequency extrapolation limited to le-16

This error occurs whenever the controlling input value is such that the output frequency ordinarily would be set to a negative value. Consequently, the output frequency has been clamped to a near-zero value.

SQUARE: Size of control array different than frequency array

This error message normally occurs whenever the controlling input array and the frequency array are different sizes.


ain 1 2 pulse1
.model pulsel square(cntl_array = [-1 0 5 6]
+                    freq_array = [10 10 1000 1000] 
+                    out_low = 0.0 out_high =4.5 duty_cycle = 0.2
+                    rise_time = le-6 fall_time = 2e-6)

See also

XSPICE Devices
XSPICE Code Models