Using instance bits inside of FB (Simatic S7)

Nepiter

Member
Join Date
Apr 2010
Location
At job
Posts
79
Hi!

Maybe stupid question, but new thing to me.

I have created FB1 and so far it has one instance db, db1.

But I would need to move one dbw value, which is in INT format (instancedb.dbw0 to Output interface instancedb.dbx4.6 - 5.3.

FB is supposed to move linear servo, according step numbers.
Step number 0-63 is in this dbw which I should move to output interface.
But Servo is reading 6 bits. That's why I need to move INT value to output bits.

But how can I do it inside of FB?
I thought I could use fb's instance db bits without pointing certain db.

Example like this:
L dw0
T dw2
And just mask part of bits to get only those 6 bits in use.

But no.
For some reason, CPU thinks I am using db0 for those instructions, not instance db1.

Sorry for My bad English, hope someone can get the point.. =)
 
Generally inside an FB you must use the declared name of the static variable, not by absolute addressing.
There are ways to access the instance data by absolute addressing, but avoid to do so.

What version of STEP7 are you using, and what PLC exactly ?

With STEP7 TIA and S7-1500 you can access the individual bits via "slice" access.
For example if you have a static INT called #MyInt, then you can access the bits with #MyInt.X0, #MyInt.X1, #MyInt.X2 etc.

Another way is to use AT views. In STEP7 classic this is only possible with SCL. In STEP7 TIA is also possible in the other programming languages.

In STEP7 Classic and STL/LAD/FBD, a quick and easy way is to transfer the INT to a dummy merkerword, and the access the individual bits in the merkerword.

Yet another way is to use pointer access to the bits.
 
I think you are looking for Local addresses when doing things like this.
if the variable inside the FB is called "ServoState" and the output variable is called "ServoOutput", doing:

L #ServoState
T #ServoOutput

will do the trick.
Remember that these variables are only accessible inside the FB and whenever you call any DB block as instance, these two variables will be inside to be used by the software.
Not sure why you'd want to use addresses, but if you are dead set on it, Local addresses would be the way to go.
 
Be careful... in the case of DBW 4... bit 4.7 is the most significant bit and bit 5.0 is the least significant in the word. Which is the bit order in your dbx4.6 to 5.3? If the most significant is 5.3 and the least 4.6, you need a byte-swap as well.
 

Similar Topics

Exposing shades of “newbie”…. I haven’t used arrays much, and I think using one for multi-zone temperature control is probably the solution I...
Replies
12
Views
771
I'm hooking up a scale to an EWEB card on a 1756 PLC through ethernet/IP sockets, and I've run into an issue that seems to defy ladder logic. See...
Replies
9
Views
2,644
Hey! I couldn't find any answer for my question anywhere, so maybe You can help me. Most of the time I was working with Siemens. I created an AOI...
Replies
4
Views
1,211
Using Rslogix 5000 Data Access manual as a reference I keep getting 'Service Not Supported' response when using symbol instance addressing to...
Replies
2
Views
1,545
Hi I am trying to retrive RSLINX data from c#.net application. I have refenced my .Net application to Interop.RSIOPCAUTO.dll. But when trying to...
Replies
3
Views
2,567
Back
Top Bottom