7/6/2013 9:02 AM | |
Joined: 1/28/2009 Last visit: 2/21/2023 Posts: 6794 Rating:
|
Hello, As a previous discussion on same issue HERE , It sounds intersting to be shared here.People inTIA Portal conference can convert this version to "SCL" version in their platform. note for real numbers: X^N:= EXP (N* LN (X)); For complex also same but: LN(-X):= LN (ABS(X)) +j 3.14 and EXP(a+j b)=EXP(a){cos(b) + j sin(b) } [code]FUNCTION_BLOCK FB100 TITLE = 'General X^N' // // Block Comment... // VERSION: '1.0' AUTHOR: hdhosseini NAME: COMPLEX_CALC FAMILY: FORUM_E // Block Parameters VAR_INPUT // Input Parameters base:REAL:=1.0; Power:REAL:=1.0; END_VAR VAR_OUTPUT // Output Parameters Error:BOOL:=false; complex:BOOL:=false; // true when complex result-false real R_part:REAL:=0.0; I_part:REAL:=0.0; END_VAR VAR // Static Variables END_VAR IF ((base=0) AND (Power=0)) OR (base=0) THEN error:=1; complex:=0; R_part:=0; I_part:=0; else IF (base<0) THEN error:=0; complex:=1; R_part:=EXP (POWER* (LN(ABS(base)))) * COS (POWER*3.14); I_part:=EXP (POWER* (LN(ABS(base)))) * SIN (POWER*3.14);; END_IF; IF (base>0) THEN error:=0; complex:=0; R_part:=EXP (POWER* (LN((base)))) ; I_part:=0.0; END_IF; END_IF; ; END_FUNCTION_BLOCK [/code] Hope that helps Hamid Hosseini |
This contribution was helpful to
4 thankful Users |
10/25/2015 5:14 PM | |
Posts: 14 Rating:
|
Hello Thanks a lot for your help Best regards |
10/26/2015 9:27 PM | |
Joined: 9/3/2014 Last visit: 3/13/2019 Posts: 4825 Rating:
|
New question published by anahita is split to a separate thread with the subject Complex poles in PCS7 v8.1. Best regards |
Follow us on