K: Logic Block.
MJMcCann-Consulting

All inputs can be comparators. Choose OR, NOR, AND, NAND, XOR
MJMcCann-Consulting Logo

Logic Blocks.
This block type provides OR, NOR, AND, NAND and XOR logic components depending on the selected mode, 0, 1, 2, 3 or 4 respectively.
All are 4 input components, but unused connections do not have to be given pull up or pull down connections as might be the case with hardware components. They are simply ignored.
Because each input signal (from An, Bn,Cn,Dn) has a fixed value (aa,bb,cc,dd respectively) added to it, every input is therefore a comparator. The signal is taken as High (On, True) if the total input is greater than zero. Zero or negative values are taken as Low (Off, False).
The Pn connection is used to provide scaling for the output so the devices can be used to deliver signals if needed. The default output is 0 (false) or +1 (true), and they can be linked into logic trees.
They change colour depending on whether they are producing True or False output.
I suggest you give them names appropriate to their chosen mode to make understanding the diagrams easier.

K block Code
Procedure ActivateK(ii:integer); // LOGIC Block. 0:OR, 1:NOR, 2:AND , 3:NAND, 4:XOR
var Temp, Active:integer;
Av,Bv, Cv, Dv, Pv, EntryState: Real;
Ai,Bi,Ci,Di : Integer;
begin with B[ii] do begin
if OnOff=0 then EXIT;
EntryState:=Vn;
Temp:=0;
Av:= B[An].Vn+aa; //use of aa, bb etc makes every input a comparator.
Bv:= B[Bn].Vn+bb; // but only if connected. Link to zero block is ignored.
Cv:= B[Cn].Vn+cc;
Dv:= B[Dn].Vn+dd;
Pv:= B[Pn].Vn+pp; //becomes scaling factor for output
if Av>0 then Ai:=1 else Ai:=0;
if Bv>0 then Bi:=1 else Bi:=0;
if Cv>0 then Ci:=1 else Ci:=0;
if Dv>0 then Di:=1 else Di:=0;

case State of
0,1: begin //OR: if any relevant value comes positive result is ONE
Temp:=0;
if (An>0) then Temp:=Ai ;
if (Bn>0) then Temp:=Bi+Temp ;
if (Cn>0) then Temp:=Ci+Temp ;
if (Dn>0) then Temp:=Di+Temp;
if Temp>0 then Temp:=1;
end;
2,3: begin //AND: if any relevant value is zero or neg then result is ZERO
Temp:=0; Active:=0;
if (An>0) then begin Active:=Active+1; Temp:=Temp+Ai end;
if (Bn>0) then begin Active:=Active+1; Temp:=Temp+Bi end;
if (Cn>0) then begin Active:=Active+1; Temp:=Temp+Ci end;
if (Dn>0) then begin Active:=Active+1; Temp:=Temp+Di end;
if Active=Temp then Temp:=1 else Temp:=0; // all active inputs are high
end;
4: begin //XOR: only one can be positive for result ONE.
Temp:=0;
if (An>0) then Temp:=Temp+Ai ;
if (Bn>0) then Temp:=Temp+Bi ;
if (Cn>0) then Temp:=Temp+Ci ;
if (Dn>0) then Temp:=Temp+Di ;
if Temp>1 then Temp:=0;
end;
end{case};
if (State=1) OR (State=3) then Temp:=1-Temp;
Vn:=Temp*Pv;
if (EntryState<>Vn) and Animation then DisplayK(ii);
end; {withBii}
end; {proc}

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
Request. Please let us know how you found this software and your interests by sending an email to mjmccann@iee.org Thank you Date: 2012.02.26
File: k.htm