Hello,
I need some help with some STL programming for siemens simatic 5.4. I am bring in an ascii code from a module and it is being stored into a DB as individual characters. I am trying to convert these select a range of characters to make a string. I want to take the first 10 characters and store them as one string then take characters 12-23 to store as another string.
I am using the code below as a FC and entering the source and target DB as well as the start position. The problem is when I convert the characters to a string my position is off by 2 characters. I am pointing to the character located in db4.dbx0.0 but I get the character located in db4.dbx2.0. So I can never bring in the first 2 characters from my serial number because I am reading the 3rd character with the 0 placement.
EX- serial - 123456789 in db 4 starting at 0.0
target db5
source db4
target position 0
source position 0
serial in db 5 starting at 0.0 is 3456789
L B#16#10 // Load the syntax ID and
T LB 0 // transfer it to the "Source" ANY pointer
L B#16#2 // Load data type Byte and
T LB 1 // transfer it to the "Source" ANY pointer
L #NumberOfBytes // Load number of bytes to transfer
T LW 2 // transfer it to the "Source" ANY pointer
L #SourceDB // Specify source DB
T LW 4 // transfer it to the "Source" ANY pointer
L #StartAdrSource //Start of the source
SLD 3
OD DW#16#84000000
T LD 6 // transfer it to the "Source" ANY pointer
Network 2
L B#16#10 // Load the syntax ID and
T LB 10 // transfer it to the "Target" ANY pointer
L B#16#2 // Load data type Byte and
T LB 11 // transfer it to the "Target" ANY pointer
L #NumberOfBytes // Load 160 bytes
T LW 12 // transfer it to the "Target" ANY pointer
L #TargetDB // Specify target DB
T LW 14 // transfer them to the "Target" ANY pointer
L #StartAdrTarget //Start of the source
SLD 3
OD DW#16#84000000
T LD 16 // transfer it to the "Target" ANY pointer
Network 3
CALL "BLKMOV"
SRCBLK :=#Source
RET_VAL:=#Errorcode
DSTBLK :=#Target
NOP 0
Network 4
A L 20.7
SAVE
BEC
Network 5
CLR
SAVE
I need some help with some STL programming for siemens simatic 5.4. I am bring in an ascii code from a module and it is being stored into a DB as individual characters. I am trying to convert these select a range of characters to make a string. I want to take the first 10 characters and store them as one string then take characters 12-23 to store as another string.
I am using the code below as a FC and entering the source and target DB as well as the start position. The problem is when I convert the characters to a string my position is off by 2 characters. I am pointing to the character located in db4.dbx0.0 but I get the character located in db4.dbx2.0. So I can never bring in the first 2 characters from my serial number because I am reading the 3rd character with the 0 placement.
EX- serial - 123456789 in db 4 starting at 0.0
target db5
source db4
target position 0
source position 0
serial in db 5 starting at 0.0 is 3456789
L B#16#10 // Load the syntax ID and
T LB 0 // transfer it to the "Source" ANY pointer
L B#16#2 // Load data type Byte and
T LB 1 // transfer it to the "Source" ANY pointer
L #NumberOfBytes // Load number of bytes to transfer
T LW 2 // transfer it to the "Source" ANY pointer
L #SourceDB // Specify source DB
T LW 4 // transfer it to the "Source" ANY pointer
L #StartAdrSource //Start of the source
SLD 3
OD DW#16#84000000
T LD 6 // transfer it to the "Source" ANY pointer
Network 2
L B#16#10 // Load the syntax ID and
T LB 10 // transfer it to the "Target" ANY pointer
L B#16#2 // Load data type Byte and
T LB 11 // transfer it to the "Target" ANY pointer
L #NumberOfBytes // Load 160 bytes
T LW 12 // transfer it to the "Target" ANY pointer
L #TargetDB // Specify target DB
T LW 14 // transfer them to the "Target" ANY pointer
L #StartAdrTarget //Start of the source
SLD 3
OD DW#16#84000000
T LD 16 // transfer it to the "Target" ANY pointer
Network 3
CALL "BLKMOV"
SRCBLK :=#Source
RET_VAL:=#Errorcode
DSTBLK :=#Target
NOP 0
Network 4
A L 20.7
SAVE
BEC
Network 5
CLR
SAVE