Siemens S5 question

Potter

Member
Join Date
Nov 2004
Location
Nottingham, England
Posts
77
Looking at a problem on a machine controlled by an S5 115 I traced the problem to F 165.0 not being on. When I tried to look into what conditions are required to get F 165.0 I came to this FB:

A F 160.0
JC =M001
JU =M002

M001: C DB 193
AN F 160.1
A F 160.2
JC =M003
JU =M004

M003:
L DW 100
L DW 101
-F
T DW 100
L KF +1
<F
= F 160.3
A F 160.3
JC =M005

M004:
AN F 160.4
JC =M006

M005:
L KH 0000
T DW 100

M006: AN F 160.1
= F 160.2
L DW 100
L KF +1
<F
JC =M007
JU =M002

M007: R F 160.0

M002:
L DW 100
SLW 4
T PW 128
L DW 100
L DW 104
<F
= F 165.0
I'm not very familiar with Siemens, and frankly don't have much idea what this means. Can anyone out there give me a few clues?
 
A F 160.0 // Check if f160.0 is 1
JC =M001 //If f160.0=1 then jump to marker m001 (jump conditional)
JU =M002 //Or if f160.0=0 then jump to m002 (jump unconditional)

M001: C DB 193 //Call Data Block 193
AN F 160.1 //Check if f160.1 is 0....
A F 160.2 //Check if f160.2 is 1....
JC =M003 //and jump if both correct
JU =M004 //else jump here

M003: //jumped here if f160.1=0 and f160.2=1
L DW 100 // load data word 100 (of data block 193)
L DW 101 // load data word 101 (of data block 193)
-F //subtract dw101 from dw100...
T DW 100 //put the answer here
L KF +1 //load fixed decimal value of 1
<F //compare if dw100 is less than fixed value 1
= F 160.3 // if dw100 is less than 1 then enable this flag
A F 160.3 //check if f160.3 is 1
JC =M005 //and jump to this marker if true
//program continues here if doesn't do the jump above
M004:// jumped here when either f160.1=1 or f160.2=0
AN F 160.4 // check if f160.4 is 0
JC =M006 // and jump here if true
//program continues here if doesn't do the jump above
M005:// jumps here if m160.3 is 1
L KH 0000 //load zero into accumulator 1
T DW 100 // and transfer accumulator 1 to dw100

M006: AN F 160.1 //jumps here if f160.4=0 and check if f160.1=0
= F 160.2 // if true then enable f160.2
L DW 100 //load dw100 into accumulator 1
L KF +1 //load fixed value 1
<F //check if dw100 is less than 1...
JC =M007 //if true then jump to m007
JU =M002 // if not true then jump here

M007: R F 160.0 // reset flag f160.0

M002:
L DW 100 // load dw100
SLW 4 // shift left word (dw100) 4 places
T PW 128 // transfer to pheriphal word pw128 (analog output)
L DW 100 // load dw100
L DW 104 // load dw104
<F // if dw100 is less than dw104 then..
= F 165.0 // enable f165.0

Bear in mind that the program is scanned top to bottom, and that the jump statements only serve to 'miss out' bits of code, and does not interrupt program flow (in this instance).

From what I can gather, when f160.0=0, then most of this code is ignored and dw100 is loaded straight into the analog output (pw128). Otherwise, dw101 is taken away from dw100 and then put into pw128. The subtraction of dw101 maybe done every cycle, therefore meaning dw100 will get less and less while flag f160.0=1 (slowing something down?). That really depends on where dw100 gets its value from. If a fixed value is loaded into dw100 every scan, then the subtraction will only get done once.

edit..

Sorry I've just read the post again..the actual problem is f165.0 nor being on, so, check the values of dw100 and dw104.
Where does m160.0 come from?
 
Last edited:
The only other place where F 160.0 appears is this FB:

C DB 193

A F 190.0
JC =M001
JU =M002

M001:
R F 165.0
S F 160.0
L DW 15
T DW 100
L DW 15
SLW 4
T PW 128
JU =M003

M002:
JC FB 3
NAME: BREMSESL

M003:
BE

The conditions for F 190.0 can be found in a PB, which I can understand ok because it's written in ladder.
 
This FB has a reset condition of the f165.0 you need to find - and it has another reference to pw128. So...

Firstly you need to find out how many places your flag f165.0 appears in.
Then you need to find out which bit of code is being processed since having multiple output references to a bit suggests that not all the code is being scanned at the same time). There are probably conditonal jumps to these blocks from another block (possibly OB1).

Are you sure that your flag f165.0 is being turned off in the first FB you posted?
 
Potter

The key to your question is the value in DW104 (DB193), as randomFire has pointed out check the value in this DW. Where is the value written to this DW?

It seems that DW100 is decremented everytime (counter value???) until the value is below that of DW104, then you will get your F160.5 set.

Could you monitor these two datawords in 'status variables'?

Go TEST -> Status Variable.
Type in:-

DB193 (enter)
DW100 (enter)
DW104 (enter)

Change the KH part to KF, then press F6 to activate.

Paul
 
Hi Potter,

just a tought...
Is this the entire FB you posted , or just a
snipset of the code ?
What I saw is, as randomFire stated before
From what I can gather, when f160.0=0, then most of this code is ignored and dw100 is loaded straight into the analog output (pw128).
Yes, but at the marker m002: there is no datablock called!
Maybe Datablock 193 is already opened before but it could be
an issue if it's not. I would call the related Datablock
explizit at marker m002.

Cheers

Rolf
 
One of the maintenance electricians who's worked here for ever told me that when they had a similar problem a couple of years ago they ended up re installing the entire programme.
I've just tried this and it worked, the machines running fine!!
Still no wiser as to what caused it, but I've learned a bit about how it works so I'll have a better idea what I'm looking at in future.
Thanks to all who responded.

Is it just me or is Siemens a hell of a lot more complex than Mitsubisi, AB etc.
 
Potter

Having to re-load the whole program makes it sound like someone has been having a fiddle.... :rolleyes:

Originally posted by Potter

Is it just me or is Siemens a hell of a lot more complex than Mitsubisi, AB etc

Naw, it's just you! :D

Paul

P.S I have never had the pleasure of a Mitsu or AB etc.
 

Similar Topics

OK. You guys helped me out a bunch with my first Siemens question. I found a bunch of issues with integrity checking the PLC programs I was...
Replies
7
Views
309
Does anyone know why my one string is displaying this way? It is causing issues with my HMI displaying it.
Replies
4
Views
261
Hello all. I have an ESA HMI that is connected to a Simatic S7-300 (CPU312). I have uploaded the program from the PLC which is written with Step7...
Replies
6
Views
1,429
Everyone, i am in the process of purchasing the Slc 500 version of software to support what we have and i have a question. Several of our...
Replies
9
Views
751
We've got very fast machine whose position controlled by interrupt OB35 set at 2ms. For position reading we use Temposonic connected to TM...
Replies
19
Views
2,488
Back
Top Bottom