S7 Status Word Buildup

Join Date
Apr 2002
Location
Burlington, Ontario
Posts
186
Ladies & Gentlemen,

I hope someone can maybe lead me in the right direction..

It is my first time dabbering with a Siemens S7-300. I decicded to duplicate some code we use on our automation platform, to play around with because I know how it works. The automation platform is not Siemens. It is from a company called Alstom. In the Alstom platform, you can combine bit and word logic in the same rung. This is what I am trying to achieve in the Siemens.

Alstom Example:

Note : The left hand rail cannot be considered a "power" rung or "1" , it has a value if -1 or Hex FFFF.

  

|----||---<AND>----------------------------------(OUT)------|
| a0.0 @1 | | g10
| | |
|----||---<AND>-|-<OR>---||--<AND>---|
a0.1 @2 @FFFF a0.2 @20





I should explain some things about the code.

The "a" and "g" address are integer values, not different than a "B" address in Allen Bradley. The "@" sysbol denotes a hex value.**This last stentence is key*** The <AND> is no different than what it implies. The <OUT> instruction is like the "Transfer" function in Siemens.

The above code works like this, you are basically creating a bit pattern within "g10" by setting bits withing g10 based on the conditions of the a0 bits. This allows you to buildup the word to represent different conditions or what ever you want. We use this for our HMI's to represnt a status for a device, instead of sending induvidul bits to the HMI.

If no "a0" bits are set, g10 = 0
If a0.0 is set, g10 = 2
If a0.1 is set, g10 = 4
If a0.0 and a0.1 are set, g10 = 6
If a0.2 is set, g10 = 32
If all bits are set, g10 = 38

I can figure out how to do this in Siemens, may take quite a bit of code, just trying to see if they have a "canned" instruction to do this?? I've looked, but cant seem to find anything.

Please ask if my explination is confusing...

Any help would be appriciated..

Thank you,

Andrew
 

+-----------+ +----------------+ ALWAYS
| "AND" | Result1 0 | "MOVE" | OFF
----+ SOURCE"A" +----------|=|----+ "0" to +---| |---+----( DUMMY )
| Mask1(111)| | DESTINATION"G" | |
| Result1 | +----------------+ |
+-----------+ |
|
|
+-----------+ +----------------+ ALWAYS |
| "AND" | Result2 0 | "ADD" | OFF |
----+ SOURCE"A" +----------|>|----+ DESTINATION"G" +---| |---+
| Mask2(001)| | +2 | |
| Result2 | | ------------ | |
+-----------+ | DESTINATION"G" | |
+----------------+ |
|
|
+-----------+ +----------------+ ALWAYS |
| "AND" | Result3 0 | "ADD" | OFF |
----+ SOURCE"A" +----------|>|----+ DESTINATION"G" +---| |---+
| Mask3(010)| | +4 | |
| Result3 | | ------------ | |
+-----------+ | DESTINATION"G" | |
+----------------+ |
|
|
+-----------+ +----------------+ ALWAYS |
| "AND" | Result4 0 | "ADD" | OFF |
----+ SOURCE"A" +----------|>|----+ DESTINATION"G" +---| |---+
| Mask4(100)| | +32 |
| Result4 | | ------------ |
+-----------+ | DESTINATION"G" |
+----------------+



The ALWAYS OFF bit ensures that the next branch is always evaluated before bailing out of the rung.

If the Destination "G" is a Byte, then the Masks are bytes...

Mask1 = VB(X+0) = 0000 0000
Mask2 = VB(X+1) = 0000 0001
Mask3 = VB(X+2) = 0000 0010
Mask4 = VB(X+3) = 0000 0100

I used "VB(X+0)" just to make them line up pretty.

The same scheme can be used for any weird-weighting that you might put on the particular bits.
 
Andrew - where are the status bits going to exist after you have built them up ? If they are in a DB why not create the DB as a set of bits and then control the bits individually with simple logic. This will be a lot clearer and simpler.
 
thank you..

Gentlemen,

Thank-you for your reponses. Simon,that is what is essentially happening in my code. I'm just not too versed in Siemens yet. I was acctually thinking about that ways of doing it after I posted. I was actually trying to do this within a Function Call. I was able to define a word, say called "status", but didnt know how to manipulate the words induvidual bits. Is there a way?? OR does it can it only be done through a DB?? Im basically trying to send a word out of the FC that represents different conditions, so it can be interogated somewhere.All I am doing is playing around and learning how to pass parameters in and out of a FC and came across a stumbling block withing the FC.

Again, thank you both for your effort and time.

Thank you,

Andrew
 
Andrew, the question to be answered is:

Is the word used to code a status 0,1,2 etc. correspond to 65536 different status messages, or,
does each bit of the word correspond to 16 separate status messages.

If the former, use a function to pass out a word, if the latter, output 16 bools which you can then parameterize to bits in a db.

The db bits method (recommended) will allow you to cross-ref and track down the status reporting. Setting bits in a word in the accumulator and then outputing the word into a db will be very difficult to track down later.
 
"G needs to be initialised to 0 before this logic is performed."

Indeed it does... I didn't sleep very well thinking about this... but I was too tired to get up and fix it.

In the first branch of the rung, instead of testing for zero, simply load zero into G. Then proceed to evaluate the bits with the remaining branches.
 

Similar Topics

Hi I am working with sinamics starter software with CU310DP. Being a learner, i am trying to find one of the status bit (Status word 3), What...
Replies
4
Views
1,475
Hello, I hoping someone can provide clarification on PF525 Status word, namely the .AtReference and .Active bits. I cannot find anything from...
Replies
2
Views
2,629
What is the following Image suggesting ? Thanks
Replies
5
Views
1,651
Hi, I'm trying to decipher some Statement List code written for a Siemens S7-300 in the late '90s. I've come across an AN instruction, which I...
Replies
6
Views
3,515
Afternoon Guys / girls Im not sure if this is seiemens specific but today I was going through some code in S7 trying to determine how a beer...
Replies
5
Views
1,804
Back
Top Bottom