S5 to S7 anyone translate this bit for me?

Johnny T

Member
Join Date
Jul 2003
Location
Fife, Scotland
Posts
642
Hi

I'm converting some old S5 code into S7. I've got the following code in S5:

C DB 100
DO FW 223
L DW 0
T FW 220

I want to convert this to S7. I understand that its moving a word equivalent to the value of FW 223 into FW 220 but don't know how to do this in S7. I ideally want to do it in ladder if possible.

So, basically I want something along the lines of a MOVE function that 'moves' DB100.DBW[MW223] into MW220.

Obviously this doesn't work so I wondered if anyone knows the correct and most efficient way to replicate this in S7.

Many thanks

JT ;-)
 
I don't know. But if I put a MOVE function in LADDER and enter DB100.DBW[MW223] then I get a syntax error and it comes up in red?

Any ideas?
 
You have to open the DB first and then do the transfer with L DBW[MW223]. You can't do this in ladder.
 
Last edited:
It doesn't work. I think its because its wanting a Doubleword so that it can access it as a pointer.

So... L DBW[MD 223] works but L DBW[MW 223] doesn't...

The problem is that in the software if Flag Bytes 225 and 226 are used then this is going to end up with unexpected results.

Any ideas how I can use DBW[MW223] or any code that would give me the equivalent?

Cheers

JT ;-)
 
Create a temp variable of type dword, say dwAddress
then:
Code:
L MW223
SLD 4  //convert address to s7 pointer format
T dwAddress
L DBW[dwAddress]
 
Right, I've just had a go at this and think I've come up with the best solution. I've created an FC that is the equivalent to the S5 'do' function. You give it the DB number, the 'DO' word and the destination and it does the rest itself. This code isn't tested but I've posted it below just in case anyone is interested.

NB. I say again.. THIS CODE ISN'T TESTED USE AT OWN RISK

  
FUNCTION "'DO' FUNCTION EQUIVALENT" : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
WHAT_DB : BLOCK_DB ;
WHAT_WORD : WORD ;
WHAT_DESTINATION : WORD ;
END_VAR
VAR_TEMP
DOUBLE_VALUE : WORD ;
TEMP_POINTER : DWORD ;
END_VAR
BEGIN
NETWORK
TITLE =PURGE VALUES

A( ;
L 0;
T #DOUBLE_VALUE;
SET ;
SAVE ;
CLR ;
A BR;
) ;
JNB _008;
L L#0;
T #TEMP_POINTER;
_008: NOP 0;
NETWORK
TITLE =OPEN REQUIRED DATABLOCK
OPN #WHAT_DB;
NETWORK
TITLE =MULTIPLY WORD BY TWO TO CONVERT FROM S5 TO S7 ADDRESSING
L #WHAT_WORD;
L 2;
*I ;
T #DOUBLE_VALUE;
NOP 0;
NETWORK
TITLE =CHANGE WORD INTO A POINTER BY SHIFTING BITS LEFT
L #DOUBLE_VALUE;
SLD 4;
T #TEMP_POINTER;

NETWORK
TITLE =TRANSFER INDIRECTLY ADDRESSED VALUE INTO REQUIRED DESTINATION
L DBW [#TEMP_POINTER];
T #WHAT_DESTINATION;




PS. The reason I double the word that is originally given is because in S5 the words are addressed 0,1,2.. etc but in S7 they are addressed 0,2,4.. etc

;-)
 
Notes on your FC:

Purge is not required as the variables are always loaded later on so you can delete network 1.
The SLD 4 is already multiplying by two so you can delete network 2.
Load WHAT_WORD instead of DOUBLE_VALUE in network 3.

(Another warning - I believe the DO instruction performs an 'or' with the operand of the following instruction. I haven't seen it used, but you may come across the following in which case the contents of FW223 are ored with 1 to form the address !

C DB 100
DO FW 223
L DW 1)
 
Last edited:
Right, I've changed that now. Thanks for pointing all that out.

You could be right about the 'ORing' with the DO command. In the software that I'm translating, so far I've only seen L DW0 commands and not a L DW1.

If I find a '1' or other number somewhere I'll alter my function to include an 'ORing' number as well.

Many thanks for your help on this. Hope you have a great Christmas mate.

Cheers

JT ;-)
 
Call DB100

DO fw223 (process the value in fw223 say 200)
LDW0 (load dw 200 in other words load the dw of the value
in fw223)
t FW226 Store it
example
l kf1 pointer to DW
t fw200 pointer stored in temp fw
c db 100 call db
do fw200
l dw0 (loads dw1)
 

Similar Topics

this a program to send data to barcode printer I want to integrate a new printer in a new machine and i wanted to adapt the old prgram on it but I...
Replies
4
Views
157
I received an email from a student with the following code attached. This is supposed to control a floodgate system, and supposed to be written...
Replies
23
Views
793
does anyone have an install or know if/where i can download it for the following "ABB PS501 Control Builder Plus V2.3 " the software was a free...
Replies
2
Views
92
They are installed in a control panel that was made in France and are intended for the termination of analog inputs. Each of the red capped...
Replies
4
Views
421
Hello everyone, I am currently working on a project that uses a Rockwell L33ER controller and the FTV Studio V13 as Supervisory computer...
Replies
0
Views
134
Back
Top Bottom