Getting DBLG in SCL

inalvor1

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

What I am trying to do is: Getting the total length of contents in a db. (not di)

Code:
FUNCTION_BLOCK FB102
VAR_INPUT
    dbObjData:ANY;   
END_VAR
VAR_OUTPUT
    udtlen:INT;
    dblen:INT;
END_VAR    
VAR_TEMP
    taD : ANY;              
    tstD AT taD : STRUCT  
        S7Code : BYTE;          // Code for S7  
        DataType : BYTE;        // Code for data type  
        Length : WORD;           // Repetition factor = Send/receive length  
        DBNumber : WORD;         // Data block Number  
        Bit_Pointer: DWORD;     // Byte address     
    END_STRUCT;
    tUDT:UDT101;
    tUDTlength:INT;
    tDbLength:INT;
END_VAR
VAR

END_VAR

//Getting UDT lenght
taD:=tUDT;
tUDTLength:=WORD_TO_INT(tstD.Length);
//Getting DB length
taD:=dbObjData;
tDbLength:=WORD_TO_INT(tstD.Length);
 
 udtlen:=tudtlength;
 dblen:=tDbLength;
END_FUNCTION_BLOCK
I thought linking a db to the ANY input would work. Alas it didn't.

Don't mind the udt code, that works.


If anyone has got any ideas, please tell me. :)

Thanks in advance!
 
Yes, but that would mean another input on the block. ANY or BLOCK_DB is ok, but with just the DB number I cannot transfer data later on.
 

Similar Topics

The application was working in Twincat 4022.16 Used VM for offline. recently changed the laptop and the getting the error with Message as below...
Replies
0
Views
52
We are using wincc scada WinCC system software V7.5 SP2 , connected to few plc . Past 3 weeks we getting this alarm continously when we checked...
Replies
0
Views
78
I am very, very new to PLCs. I only have experience with Picos, but I knew enough to save this from the dumpster. Apparently, everything on it is...
Replies
13
Views
600
Hi, I tried today to get RD3A and WR3A instructions to work on the PLC and it didn't work, but it worked in simulation. I followed the clone...
Replies
18
Views
1,384
Good morning guys; Im new at AB plc, and i just need help about a table or a list called something like "exchange data table" in French it is...
Replies
4
Views
763
Back
Top Bottom