5/22/2012 6:50 PM | |
Joined: 10/7/2005 Last visit: 9/14/2025 Posts: 3049 Rating:
|
Hello Niklas let me start by emphasizing the following: As aStep 7 programmer you must assume that an S7 operates on the so called "pass by value" principle (Step 5 on the other hand always worked on the "pass by reference" principle, see also HERE for more on the general differences between the two). What does this mean for you: Well, you can NOTcount on being able to determinethe address of anassigned parameter (there's typically or really no need to anyhow, as the value of the Parameter is what shouldi nterest you). Example1 (your code will NOT work): You call an FC in LAD or FBD and assignlets sayI1.2to an IN paramter. What you'll find is thata TEMP variable is created and used as the actual IN parameter variable. If you change to STL view you'll even see the code that now firstly copies I1.2 to to a TEMP variable which is then used as the IN parameter for the FC. This also allows you to have a combination of BOOL'S assigned to one IN Parameter in LAD/FBD. An yes, you can argue that theTEMP variable is passed on to the FC on the "pass by reference" principle(which is what your logic inside the FC sees). Example2 (your code will NOT work): You call an FC in STL, LAD, FBD SCL etc andassign lets say DB10.DBX7.6 to an IN parameter. What you'll find is that an "invisible"TEMP variable is created and used to hold the value of DB10.DBX7.6. The "problem" for Step 7 here is that a fully qualified DB address (e.g. DB10.DBX7.6) requires 6 Bytes to hold the address and this simply can NOTbe passed on as an address. Example3 (your code will work): If you call an FC directly in STL or SCL and use I1.2 as the IN parameter, Step 7 will use the "pass by reference" principle. AsI1.2 only uses 4 Bytes to hold the address (which is the limit for "pass by reference" principle in Step 7), Step 7will now happily work on the "pass by reference" principle. Your "Parameter address evalution code" will as such also work with M,L or partial DB variables (e.g. DBX 3.4). I hope this helps and you'll find somemore similar info in THIS thread. Last but not least: Why do you need/want to find outthe address of the Parameter (instead of simply using its value via "normal" programming). |
Cheers |
|
Follow us on