Conditional move on Siemens S5

J

Thread Starter

John Purves

Does anyone know how to do a conditional move on an s5? i.e. i want to add 2 words together, then on the closing of a contact, move the result of the add into another word.

Thanks in advance.

John Purves
 
M

Michael Griffin

There have been several recent discussions on this subject. I suggest that you search the archives for details. In summary though, there are two ways:

1) Do a conditional jump around the move (load/transfer) when you want to disable it. This requires using a function block.

2) Create a function block which simply does a load + transfer, and call this block conditionally. The block should take the source word as an input parameter, and transfers the result to an output parameter.

The second method can be re-used in other projects as this is a common requirement in many projects.

--

************************
Michael Griffin
London, Ont. Canada
************************
 
D

Donald Pittendrigh

Program it in CSF using the move block with the condition at the EN input to the block, then convert the code to STL and you will understand what it does.

Regards
Donald P
 
S

Steve Linehan

<p>John

<p>You can jump based on the RLO by using JC to a flag which you define. Check the following code.
<pre>
C DB10 - Call DB10
L DW20 - Load DW20
L DW30 - Load DW30
=F Check if Equal ****Note1
JC M002 If Equal Branch to M002
L DB8
etc
etc
etc
M002:
other
other
</pre>
<p>If you need more info drop me a mail and I will puit you in touch with our Siemens Person.
**** Note1 Other checks available such as equal less than greater than etc.
 
R

Richard Hughes

How you do it will be different depending on when you want to do the addition.

If you want to do the addition at the instant the contact closes, then you could do a conditional jump past the FB containing the sum unless the contact input is on (you may need to generate a rising edge on the input to only do the addition/transfer once)

If you are summing data dynamically, then the same sort of routine will do but just put the transfer inside the jump, the add FB outside it.

It makes sense to me, but I assume you understand S5 math instructions. If I misunderstood your question, then a bit more detail would help.

Regards,

Richard Hughes
 
<pre>
A DB20 Work with DB20
L DW 1 Load Word 1
L DW 2 Load Word 2
+F Add
UN E 0.0 Input Not True
SPB = 0001 Conditional jump
T DW 3 If Input True Result in DW 3
0001:
BE
</pre>
 
Top