SCL Indirect DB

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi I am trying to read data from various DB's

So "DB_HMI".Data1 := DB[PARAM].Data1

etc

where PARAM = 1 to 99
 
I think you cannot do it symbolically like you have it in your own example.
To access a DB indirectly you loose the symbolic connection.

Something like this should work for a WORD-sized address (INT, or WORD):
"DB_HMI".Data1 := WORD_TO_BLOCK_DB(PARAM_DBNR).DW[PARAM_WORDNR] ;

Something like this should work for a DWORD-sized address (DINT, DWORD or REAL):
"DB_HMI".Data1 := WORD_TO_BLOCK_DB(PARAM_DBNR).DD[PARAM_DWORDNR] ;

edit: In my example also the element is indirectly specified. This may not be necessary for your application.
In that case you can write for example:
"DB_HMI".Data1 := WORD_TO_BLOCK_DB(PARAM_DBNR).DW10 ;

edit again: Maybe PARAM_DBNR is an INT because you want to loop through 1..99.
In that case you can do:
"DB_HMI".Data1 := WORD_TO_BLOCK_DB(INT_TO_WORD(PARAM_DBNR)).DW10 ;
 
Last edited:
Hi thanks

I think I will cheat and just write 99 fc's with awl cut & paste

Pity it was not made easier

Cheers
 
If .data1 is a struct, can you not use DB_HMI".Data1 as destination pointer for SFC20?

Then just create a temp struct for an anypointer, which you feed manually with values. Then you have symbolic dbno.

Measure .data1 length for repetition factor.
 
Hi All

Basically we supplied a machine with a fixed set of parameters for 99 different possible vessels (it is a washer, and yes, we told the customer it was a bad idea)

Now, it has been identified that we need a crude recipe system. I already have a global DB which is the existing setpoints. However the DB also has lots of other items scattered in it such as timer elapsed values, status messages etc.

I was asked TODAY to write some code to fix it for testing onsite TOMORROW..... typical bs etc.

Anyway I exported the global DB and stripped out the parameters (approx. 80) , then copied this to 99 DB's, 1 for each vessel. I know I could have used a UDT but time was limited

The data is a mix of INTs and REALs.

I have written a set of 5 FC's which are basically IF Product1 THEN load parameters for Product1 to the original working DB through to 99 and used a offset in the HMI tag to point to the new Product DB for the data read/write

If I was doing this from the ground up I would probably have used SFC20 and kept the parameters separate.

Would have been so simple if I could have kept the DB[number] style

Will check back here later when at home
Cheers
 
Hi Having been tagging up the HMI indirect addresses I think this task would have been easiest as a HMI script due to not having symbolic programming available due to indirect requirment.

Having said that I prefer to keep as much as possible of any logic etc in the PLC.
 
Hi Jesper
I have more time on this so I am going to investigate post#2 in more depth.

Cheers
 

Similar Topics

Hi, I am facing invalid data type when i compile SCL and no luck in finding any old threads? could point me out to right direction? Thanks...
Replies
3
Views
2,179
Hello, I am currently forced to use s7-1200 (6ES7214-1AG40-0XB0) PLC for one small project. I do have some experience with S7-300/400 mostly in...
Replies
6
Views
5,097
Hi all In a step7 SCL FB (NOT TIA portal) , I have declared many variables as IEC timers (SFB4). Now I need to iterate this variables (hundreds...
Replies
15
Views
7,903
Hi all, Trying to figure out how to convert a block I created in STL to SCL and I run into problems from line one, lol. Is there a way to input...
Replies
10
Views
3,246
Hello, I have a couple of problems I am trying to solve. 1. how to use indirect addressing with variables of type T (timer) similarly to all...
Replies
10
Views
6,800
Back
Top Bottom