NAME
wave_gen - create wave form generator
PROTOTYPE
unitptr wave_gen( int T1, int T2, int T3, int mode, unitptr host)
ARGUMENTS
- int T1
- time constant T1
- int T2
- time constant T2. Total period length is T1+T2 exec steps
- int T3
- time shift. Wave form will start with time shift of -T3 after initialization.
- int mode
- determines generated wave form (see below)
- unitptr host
- host unit for newly created instance
RETURN VALUE:
- unitptr u
- pointer to newly created unit
INTERFACE OF CREATED UNIT:
- X_in[1]:
- (input field 0) control variable c
- X_out[1]:
- (output field 0) time t
- Y_out[1]:
- (output field 1) wave amplitude at time t
EXECUTION OF CREATED UNIT:
At each execution step
X_out[0] = t
Y_out[0] = (1-c)*Y_out[0] + c * f(t-DT)
and t = t+1 (X_out[0] remaining fixed)
where f(t) depends on mode and is given for 0=<t=<T1+T2
by
sin(2*pi*t/(T1+T2)) for mode = 0
cos(2*pi*t/(T1+T2)) for mode = 1
(t<=T1) ? - 1 + 2*t/T1 : 1 - 2*(t-T1)/T2 for mode = 2
("triangle wave")
(t<=T1) ? 1 : -1 for mode = 3 ("square wave")
For other values of t, f(t) is defined by periodic continuation.
INITIALIZATION:
A call of ctrl_unit(cmode,u) with cmode=NST_INIT or
NST_I_ZERO resets the internal counter variable t and
X_out[0] to zero. Y_out[0] becomes f(-DT).
FILE:
nst_math
SEE ALSO:
funct_gen
FILE
/local/homes/rhaschke/nst7/man/../o.linx86//../foldersrc/nst_math.c