Siemens S7: ANY-pointers in SCL

inalvor1

Member
Join Date
Apr 2012
Location
Malmö
Posts
27
Greetings!

What I'm trying to do is using INPUTS and OUTPUTS of the ANY format in FC's, or to be correct, I'm looking for a workaround with the same functionality since I want variable byte lengths on my inputs/outputs.

I know this:
ANY is only allowed in VAR or VAR_TEMP when it comes to FC's

If it had been an FB:
Code:
TYPE AnyPointer
    STRUCT //ANY structure
      ANY_ID: BYTE;
      DataType: BYTE;
      Length: INT;
      DBNO: WORD;
      BytePointer: DWORD;
    END_STRUCT;
END_TYPE;
FUNCTION_BLOCK FB607
VAR_INPUT
    IA: AnyPointer;
    SMAX: AnyPointer;
    SMIN: AnyPointer;    
    RAW_VALUE AT IA: ANY;
    SCALE_MAX AT SMAX: ANY;
    SCALE_MIN AT SMIN: ANY;
END_VAR;
//This part is not legal even in FB's, but I want it! :)
VAR_OUTPUT
    OA: AnyPointer;
    OUTPUT_VALUE AT OA: ANY;      
END_VAR;
// No code as of yet.
END_FUNCTION_BLOCK
If anyone knows how to write this properly I'd be most grateful for "any" insights.

If I'm unlucky I have to use a Function Block instead :(
 
Last edited:
You have declared a UDT called AnyPointer that replicates the structure of an ANY POINTER and then declared input variable as a UDT rather than as ANY POINTERS.

I take it that your function needs to write to a destination specified as an ANY POINTER so the ANY POINTER need to be an input parameter that is then interpretted so the function can write to the desired location.

What was it you actually wanted to achieve?

Nick
 
My mind seems to be all over the place, coffee deficiency is blamed.

What my purpose is:
Outside of block an input should look like this:

RAW_VALUE := P##Value BYTE 4

(Alternatively the "BYTE 4" could be "BYTE 2".)

I'm trying to make the block recognize how big the input is, and use INT or REAL conversion depending on input size.
 
My mind seems to be all over the place, coffee deficiency is blamed.

What my purpose is:
Outside of block an input should look like this:

RAW_VALUE := P##Value BYTE 4

(Alternatively the "BYTE 4" could be "BYTE 2".)

I'm trying to make the block recognize how big the input is, and use INT or REAL conversion depending on input size.

Code:
VAR_INPUT
  RAW_VALUE : ANY;
END_VAR

Results in that, so why have you used your udt as type?

If you want later easily use parts of anypointer, then use AT.
 
Alternative to AT is to copy the output any to a temp var and use that.

Code:
FUNCTION fc666:void
VAR_OUTPUT
oa:ANY;
END_VAR
VAR_TEMP
oat:ANY;
END_VAR
BEGIN
oat:=oa;
//use oat as you would oa;
END_FUNCTION
 

Similar Topics

Hi every one. I am trying to verify the following: A DINT can be converted to a POINTER by simply shifting the double word left by 3 bits. i want...
Replies
3
Views
2,072
Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
2
Views
30
Hi need help why this “failure 5 emergency stop “ appears at every startup in the morning ? Have to shut off main switch at least 10 times on...
Replies
19
Views
245
i have two plc 1. s7-1212dc/dc/dc ip; 192.168.0.1 2. s7-1500 1513-1pn ip; 192.168.3.2 i need to get data from plc1 to plc2. any idea how to do...
Replies
5
Views
88
Hi everyone hope you'll well. Is it possible for me to download a Crack version of tia portal v13..sorry to say this but the software is very...
Replies
5
Views
185
Back
Top Bottom