7/8/2013 1:58 PM | |
Joined: 1/28/2009 Last visit: 9/10/2024 Posts: 6849 Rating:
|
Hello Pegaia, What is your idea about checking the followig general solution,Even calculating "-23,5" with output of complex numbers i.e result:= Real Part + j (Imaginary Part).In case of INT numbers just a conversion is needed because this function block supports "Real" numbers: General solution for (X^N) in SCL(Complex Variables)[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] Best regards Hamid Hosseini |
7/8/2013 4:21 PM | |
Joined: 9/23/2005 Last visit: 9/11/2024 Posts: 4347 Rating:
|
Hi, I tried to simulate your behavior (V12 / 1500 / Simulator) WITH Integer expoent and doesn't have problem. AttachmentC:\Users\z0008iwv\Pictures\Untitled_13.zip (291 Downloads) |
Denilson Pegaia |
|
This contribution was helpful to
1 thankful Users |
12/11/2018 12:52 PM | |
Joined: 8/24/2006 Last visit: 5/31/2024 Posts: 148 Rating:
|
Hi, sorry for my replay, this work at 100% with + and - in awl? Thank you in advace
------------------------------------------------------------------------------------------ |
Last edited by: Jen_Moderator at: 12/12/2018 6:40:55 AMNew subject after splitting |
|
Follow us on