G: Function Generator.
This block mimics the idealized form of a 'diode function generator' as found, in days gone by, on analogue computers,
giving a continuous piecewise linear function of a monotonically increasing argument.
It is a convenient way of creating an arbitrary function, when an analytical form is not available.
The function is created by defining the corner points at a series of values of the input argument.
The function can have any number of points defined, but the default form has 11 points defined to give ten segments.
In McSimAPN, the same function can be used many times in a model because the execution invokes the shape data
from a block which need not be the active block itself.
To create a function, edit the values for the corner points,
making sure the sequence of values for the argument is always increasing.
The corresponding values can be anything.
You won't be able to edit the corner point values for a different block from the one you have selected
in the creation process (menu) or from the block diagram (rt-click).
If you do select a different block's data for function generation,
then the data in the active block becomes irrelevant
and the block serves as a link to the shape data but can use its own scaling.
The variables as used are arranged so that the input can be shifted and scaled, as can the output.
The intention is that it may be convenient to use the range 0 to 1 of the default case
and adjust the input to fall in that range.
Memory as Function
The M-memory and G-function Generator blocks store their data in the same way.
So a function Generator, which can use its ability to read another function to provide replication,
can just as well read a Memory block. This allows different delays (or offsets) to be used
from the same remembered values.
Operation - the variables used.
The input argument is created as:
x = ((Av+aa) - (Bv+bb))*(Cv+cc), where Av is the output value from the block An, etc.
The actual function data to be used is identifed by Pn as the ID number of a block.
In the default case it is the same as the block's own ID number.
Don't point the Pn value to a block that isn't itself a function Generator or a Memory block.
The execution code compares 'x' in turn with the argument values till it locates the relevant segment.
It then does an interpolation.
Finally the output, as found from the interpolation, is scaled by the pp value.
Note that if the input value, x, is outside the range of the argument list,
then the corresponding nearer end value is used for the output.
FunctionGenerator Code
If you are trying to make sense of the code,
you need to know that the data is stored in a one dimensional, dynamic array.
The values are in the locations 1 to N and the arguments are in the range N+1 to 2N.
Procedure ActivateG(ii:integer); //function GENERATOR
var X1,Y1,X2,Y2, Xmin, Xmax, X :real ; //temporary values
Fn, iHigh, jj :integer; //where function is drawn from
rem, N :word; // N = length of data list
begin with B[ii] do begin
if OnOff=0 then EXIT;
Fn:=max(BlocksTiming+1, min(BlocksMaxUsed, Pn) ); //might be using any store as source of a function
iHigh:=High(B[Fn].Store); if iHigh<0 then begin Vn:=0; EXIT end; //there's no function there.
DivMod(iHigh,2,N,rem); if (N<2) OR (rem<>0) then begin Vn:=0; EXIT end;
X:=(B[An].Vn+aa -B[Bn].Vn-bb)*(B[Cn].Vn+cc);
Xmin:=B[Fn].Store[N+1]; if X<=Xmin then begin Vn:=pp*B[Fn].Store[1];EXIT end;
Xmax:=B[Fn].Store[N+N]; if X>=Xmax then begin Vn:=pp*B[Fn].Store[N];EXIT end;
jj:=1; while X > B[Fn].Store[jj+N] do inc(jj); //find where X lies in the list of arguments
X1:=B[Fn].Store[N+jj-1]; X2:=B[Fn].Store[N+jj];
Y1:=B[Fn].Store[jj-1]; Y2:=B[Fn].Store[jj];
Vn:=pp*Interpolate(X1,Y1,X2,Y2,X);
end{with}
end;
|
MJMcCann-Consulting
Help Index:
Index/Search
Background
Simulation Concepts
Continuous Systems
Discrete Systems
McSimAPN Structure
McSimAPN Operation
Using McSimAPN
Start McSimAPN
Save Model,data
Create Blocks
Run-Hold-Reset
Link Excel+VBA
PetriNet Block Types
A activity/action
B belt conveyor
C container/constant
D diverter(random)
Analogue Block Types
E exponents
F flux/flow
G function Generator
H hysteresis
I integrator
J inductor
K logic element
L logarithms
M memory
N note/label
O oscilloscope/graph
p not assigned
Q quantizer/rounding
R relay on/off
S sin/asin/atan
T timer/clock
U user link Excel
V visual voltmeter
W sWitch selector/MUX
X multiply
y not assigned
Z random (fuZZ)
& signed summation
% division/difference
@ access/move values
|
Invitation. McCann can help if you have a
design or operational problem that needs some technical support that is outside your
team's experience, some quantitative assessment of what is really the cause of the
difficulties, some design alternatives or just a fresh look by an intelligent
interrogator.
If you have a problem with the behaviour of a market sector, plant, process or item of
equipment and would like to get a quantitative handle on it to improve yield or optimise
performance, then contact us. We are always ready to give a little time
to discuss a new puzzle, in confidence,
of course. We'll only worry about fees
when we have some defined work. We can be flexible
about how we work with you. Top
|
MJMcCann-Consulting,
POB 902,
Chadds Ford PA
19317 USA.
T: 1 302 654-2953
F: 1 302 429 9458
E: mjmccann@iee.org
|