Change the first letter of a string in the global DB (Siemens STL)

Aleksandra

Member
Join Date
May 2018
Location
Belgrade
Posts
35
Hello everyone,

I have made a sample project with one FC, and one global DB with a few strings.

In the global DB all strings are written lowercase. In the FC block, I load the first letter of the first string, and I check if it is lowercase. Since this condition is fullfiled, I want to change it to uppercase. Here comes the problem.

OPN "Strings" // Here I open DB with strings

L 0
SLD 3
LAR1 // Here I make the pointer

L DBB [AR1,P#2.0] // Load the first character of the first string
T #FirstChar
A( // Here I check if it is lowercase
L #FirstChar // with the help of ASCII table
L 96
>I
)
A(
L #FirstChar
L 123
<I
)
JC Chng

Chng: L #FirstChar // Since the condition is fullfiled I convert
L 32 // the ASCII code of the small letter
-I // to the ASCII code of the big letter
T #ChangedChar // I transfer it to the local variable just for check
T DBB [AR1,P#2.0] // BUT, when I try to transfer it to the global DB
// it doesn't work!!!

Can anyone please help? What am I missing?

I am using STEP 7, CPU 315-2 PN/DP.
 
I have tested it with and without the jump, that is not the problem.


Yes, I open the DB (see the first line of code), and I successfully read the first character of the first string (I have seen this in ACCU1). I also successfully test if it is lowercase (I have also seen this in monitoring mode).


The only problem comes with the last line of code, when I try to transfer the byte (char), converted from lowercase to uppercase, INTO the DB.
 
Are you calling the FC all the time?
When you say it doesn't work, what information are you looking at?
 
Yes, in the OB1 I have written:


CALL FC 1


Shouldn't it be like that?


I know that it doesn't work because values in the ACCU1 are changing constantly (I don't know how and why). When I go online in the DB, I don't see any changes - the first character stays lowercase, it doesn't change to uppercase.


If I do exactly the same thing with variable of type INT, it works fine, it changes the value in global DB.
 
You cannot monitor a string in a db, use a VAT table with chars.
As you are not skipping the case conversions if the char is not lower case, you are subtracting 32 from DBB2 every scan.

uc.jpg
 
The only thing that comes to my mind is the following: When I try to write the uppercase character into the DB, I write:


T DBB [AR1, P#2.0]


Should I somehow convert the value form ACCU1 to Byte?


I am going nuts...
 
Code fixed: (NB I used a different symbol name for the DB)
Reload the string by downloading DB1 after you have fixed the FC



Code:
      OPN   "dbstrings"                 // Here I open DB with strings

      L     0
      SLD   3
      LAR1                              // Here I make the pointer

      L     DBB [AR1,P#2.0]             // Load the first character of the first string
      T     #Firstchar
      A(                                // Here I check if it is lowercase
      L     #Firstchar                  // with the help of ASCII table
      L     96
      >I    
      )     
      A(    
      L     #Firstchar
      L     123
      <I    
      )     
      JC    Chng
      JU    Noch

Chng: L     #Firstchar                  // Since the condition is fullfiled I convert
      L     32                          // the ASCII code of the small letter
      -I                                // to the ASCII code of the big letter
      T     #changedchar                // I transfer it to the local variable just for check
      T     DBB [AR1,P#2.0]             // BUT, when I try to transfer it to the global DB
Noch: NOP   0
 
Code fixed: (NB I used a different symbol name for the DB)
Reload the string by downloading DB1 after you have fixed the FC



Code:
      OPN   "dbstrings"                 // Here I open DB with strings

      L     0
      SLD   3
      LAR1                              // Here I make the pointer

      L     DBB [AR1,P#2.0]             // Load the first character of the first string
      T     #Firstchar
      A(                                // Here I check if it is lowercase
      L     #Firstchar                  // with the help of ASCII table
      L     96
      >I    
      )     
      A(    
      L     #Firstchar
      L     123
      <I    
      )     
      JC    Chng
      JU    Noch

Chng: L     #Firstchar                  // Since the condition is fullfiled I convert
      L     32                          // the ASCII code of the small letter
      -I                                // to the ASCII code of the big letter
      T     #changedchar                // I transfer it to the local variable just for check
      T     DBB [AR1,P#2.0]             // BUT, when I try to transfer it to the global DB
Noch: NOP   0

You are awesome! It works 🍻
 

Similar Topics

Hoping someone can give me some guidance or confirmation of what I need to do. We have a FactoryTalk SE program that I need to change the IP...
Replies
2
Views
82
Hey all, i have a panelview screen (image attached), with 4 items on it. Program 1, Program 2, ...3, ...4. The PLC i am using is a compactlogix...
Replies
5
Views
169
Greetings I have a problem, my system is the following: wincc v8.0 (demo), logo8.3, abb m2m analyzer. I created some pages to display the...
Replies
0
Views
61
We had one go down. we have a new one. Their emergency Number don't work. The Model is TLSA046AAH-330N01-007 A catalog says we need software TET...
Replies
2
Views
170
“The HMI files we cannot open—they were saved in V13—we do not have that—I cannot restore file –please have them save in V11 and send them back to...
Replies
4
Views
173
Back
Top Bottom