S7 Pointing into a struct

cjd1965

Lifetime Supporting Member
Join Date
Apr 2007
Location
UK
Posts
1,659
Hi I have a db made up of a list of structs. The structs are the same type and are

Struct 1
A Bool
B Bool
C Time
End Struct
Struct 2
A Bool
B Bool
C Time
End Struct


How would i assign a pointer inside a FB to point to A and B, and also for the 2nd struct

Hope this makes sense

Cheers
 
Hi again
I dont understand the instance db and dataword area at the FC call... is this used to map the struct to a temporary DB/memory area?

This has the potential for what i am looking at, which is basically to turn on A from the FC and check the status of B so i would need to (=A) and (A B) inside the FC... how would I do that from this stuct pointer?

Once LAR1 is used, may I redeclare it and open a different db inside the FC?

L intx
LAR1 intx
OPN DBx

etc
 
There is no instance DB used in this example, if you view FB1 in symbolic mode you will see FC1 is being passed the variables you requested and returning pointers to the variables.

Are you trying to implement some processing that applies to all of the structures in the DB by looping through them instead of creating lots of calls that reference each struct individually ?

strop.JPG
 
I tend to keep things simple and work a lot with arrays of udt...


thatway I can in SCL jus do:

MyDB.MyData[pointer].A_Bit

where pointer is an integer i can easily change..

Maybe this isnt good practice but it is dead-easy with scl..
 
Hi
This for for analog signal conditioning and error checking. At the moment I have an FB with hard coded calls to a seperate multi-instance DB and FB containing run and done bits for mask and debounce timers. At project development I have the laborious task of changing these to suit hence why i was looking into pointers.

I think it will be easier to create 8 seperate FC's , 1 for each error condition, and call them from the FB.

I am working at trying to change a single value in the FB input area and the rest will take care of itself.
 
Hi Thim
I have a DB with a long list of structs inside it.
struct is basically a UDT of timer run and timer done bits (BOOL) plus timer preset (TIME). I have 2 timers per alarm, mask and debounce.

So, for example,Analog 1 alarms Alarm 1-8 would be mask run bits 1 to 8, the debouce run bits would be 129-137 the mask done bits 257-264 and debounce done 265-273

So the idea is if i pass an int of 1

int 1 = 1,129,257,385
int 2 = 2,130,258,386
..
..


The total number of alarms can change but I am working with 128 at present

Additional complication is the alarm accknowledge bit from a seperate DB... but these are just Bools in number order, so in this case a list of 128 bools.

Clear as mud i expect

I will try and post the DB and struct data , but it will probably be tonight because I am tavelling soon

Cheers
 
hehe maybe i understood it wrong i though you had a FB that you want to give a value, and the FB knows what to do.
If so and you have a sertain structure in de numbers needed in the FB you can maybe go Through them by a loop and in the loop change the number and call the FB
 
Hi thanks for all the advice
I have decided to rip the struct apart and use a 'non struct' style DB which is well on the road to success. I will revisit struct pointers when I have more time

cheers
 

Similar Topics

Hello! Is it possible to copy pointer's pointing address to any variable at Siemens step7? I mean I have pointer address to db block with...
Replies
14
Views
15,574
Dear all, I have prepared a logic for moving DBvalues first in first out. There is a problem in execution could you guys help me out. L...
Replies
0
Views
1,398
I looking for an industrial pointing device for an outside application and a Class I, Div. 2 rating. I've found several manufacturers that all...
Replies
6
Views
2,567
Hi, if I want to point indirect to a UDT which is in an array how can I do it? I can do it not indirectly: I have declaration in DB10...
Replies
8
Views
3,251
Hi, I have a problem with addresses of a DB. I have two DBs. In one(DB 10) I keep the address of the element from the second one(DB1000). What I...
Replies
3
Views
4,824
Back
Top Bottom