<< Click to Display Table of Contents >> Navigation: MODELS > Models Multi-phase |
INPUT, OUTPUT and VAR of a Model can be declared as an array [1..n], and ATPDraw requires the first index to be unity.
Using this can simplify multi-phase handling significantly. The example below shows a 3-phase conversion of data in Cartesian coordinates to Polar. Declaring the INPUT, OUTPUT and VAR as arrays and interacting over them in a for loop simplifies the code considerably.
MODEL CAR2POL
COMMENT
Vonverts the 3-phase input in cartesian notation into polar
ENDCOMMENT
INPUT
Xre[1..3],Xim[1..3] -- The input signal in cartesian coordinates
OUTPUT
Xabs[1..3] -- Magnitude of output
Xang[1..3] -- Angle of output
VAR
i, Xabs[1..3],Xang[1..3]
EXEC
for i:=1 to 3 do
Xabs[i]:=sqrt(Xre[i]**2+Xim[i]**2)
if (Xre[i]=0) and (Xim[i]=0) --seems necessary to protect agains undefined
then
Xang[i]:=0
else
Xang[i]:=atan2(Xim[i],Xre[i])
endif
endfor
ENDEXEC
ENDMODEL
Data can also be declared as arrays, still with unity as the lower index but without restriction on the upper index.