5/18/2013 6:59 AM | |
Joined: 1/28/2009 Last visit: 9/2/2024 Posts: 6846 Rating:
|
Since now thanks! Best regards, Edsan Hello, I suspect that your problem is related to EN/ENO mechanism for ensuring error free execution of first function as a per-requisite for execution of 2nd function in LAD.This is implemented by "BR" as a bit in status word of CPU.Check the following link for more information. What is the meaning of the BR bit in the status word in STEP 7? and also the following clustered threads: Cases on BR-EN/ENO Mechanism But for calling several scaling functions in STL inside one network,there should not be any problem.Please upload part of your project for further checks. Best regards Hamid Hosseini |
Last edited by: hdhosseini at: 5/18/2013 3:10 PM |
|
6/26/2013 10:41 AM | |
Joined: 6/24/2013 Last visit: 9/3/2024 Posts: 1618 Rating:
|
Hi If You daisy-chain 2 blocks in one network and one returns 0 in its ENO then second will not be executed. If You wish to scale both analog values put them in separate networks and eno bits in local variable of the FB/FC for scaling - see FC2 in FC1FC2.pdf In case of 4..20mA inputs Siemens scaling block will give ENO=False and Error even if input is a very little bit below 4mA [this is allowed by the standard] so You will need Your own error detection which allows let's say PIW>=-200. This is FC1 printed to pdf in attached FC1_FC2.pdf and source posted below. // Source for function which scales 4..20mA input FUNCTION FC 1 : WORD TITLE =Scale 4..20mA Input VERSION : 0.1 VAR_INPUT I_RAW : INT ; //Raw Value I_ENG_LO : REAL ; //Engineering Value for Minimum i.e. 4mA I_ENG_HI : REAL ; //Engineering Value for Maximum i.e. 20mA END_VAR VAR_OUTPUT Q_SCALED_VALUE : REAL ; //Value Scaled to Engineering Units END_VAR VAR_TEMP Corrected_Raw : INT ; //Raw Value clamped to 0..32767 AlwaysOff : BOOL ; //Always Off for Scaling Block END_VAR BEGIN NETWORK TITLE =Check Raw Value Above 0 A( ; L #I_RAW; L 0; >I ; ) ; JNB _001; L #I_RAW; T #Corrected_Raw; SET ; SAVE ; CLR ; _001: A BR; JC CNVR; NETWORK TITLE =Check Value Greater Equal -200. //When value is between -200 and 0 return minimum value, no error and exit. A( ; A( ; L #I_RAW; L -200; >=I ; ) ; JNB _002; L #I_ENG_LO; T #Q_SCALED_VALUE; SET ; SAVE ; CLR ; _002: A BR; ) ; JNB _003; L 0; T #RET_VAL; SET ; SAVE ; CLR ; _003: A BR; SAVE ; BEC ; NETWORK TITLE =Raw Value Below -200 - return minimum and Error #8 L #I_ENG_LO; // Return T #Q_SCALED_VALUE; // Low Eng Value L W#16#8; // Return Error Code = 8 T #RET_VAL; CLR ; // Set ENO=False SAVE ; BE ; // Terminate here NETWORK TITLE =Set Always OFF to FALSE CNVR: A #AlwaysOff; R #AlwaysOff; NETWORK TITLE =Scale Value to Eng Units and return Siemens Scaling ENO A #AlwaysOff; = L 3.0; BLD 103; CALL FC 105 ( IN := #Corrected_Raw, HI_LIM := #I_ENG_HI, LO_LIM := #I_ENG_LO, BIPOLAR := L 3.0, RET_VAL := #RET_VAL, OUT := #Q_SCALED_VALUE); A BR; SAVE ; END_FUNCTION AttachmentFC1_FC2.pdf (378 Downloads) |
6/26/2013 11:20 AM | |
Joined: 1/28/2009 Last visit: 9/2/2024 Posts: 6846 Rating:
|
Dear friends, Thanks for all your elaboration Calling blocks in separate networks in LAD is wise if you don't want to provide a safe substitute value for illegal converted value.Calling blocks in STL is also possible, of course you can use jump instruction related to "BR" status bit to evaluate error free execution of block. I think the situation is really clear now. Best regards Hamid Hosseini |
Last edited by: hdhosseini at: 6/26/2013 11:21 AM |
|
This contribution was helpful to
1 thankful Users |
Follow us on