Technical Forum

SIMATIC S7-1200

How to address byte inside a string

Erstellt von simaticfan79 am 15.04.2012 16:46 (2 Antworten)

« Vorheriges Thema Nächstes Thema »
Seite 1 von 1 (3 Objekte)
  15.04.2012, 16:46
Beigetreten am: 04.01.2011
Letzter Besuch: 30.05.2013
Beiträge: 20
Bewertung:
Bewertung: keine [0 von 5 / 0 mal bewertet]. (0) 
Bewertung: keine [0 von 5 / 0 mal bewertet]. (0) 
Dear colleagues,

I have this problem...
I want to address byte inside a string but I find it imposible with TIA portal V11 SP2.

I create standard DB (S7300 compatible) and inside DB I create string.
For example: "TESTDB".TSTRING[32]

But If I want to address byte inside that string in SCL or LAD editor with absolute addressing

for example: DB7.DBB6

it changes immediately into
"TESTDB".TSTRING
and so It is impossible to address byte inside a string.Rnf:lblSmileyTooltip_  think

What I am doing wrong?

Thank You!
Top
  15.04.2012, 20:54
Beigetreten am: 22.12.2006
Letzter Besuch: 09.06.2013
Beiträge: 1296
Bewertung:
Bewertung: Exzellent [4,01 von 5 / 151 mal bewertet]. (151) 
Bewertung: keine [0 von 5 / 0 mal bewertet]. (0) 
Hello,
There are several solutions. 
Here a less known possibility.
In SCL there is a special instruction AT that allows to define the same data but with another format.
As in the small example in annex (not tested on a real PLC, and to be adapted to your needs).
The FC gets a char (aChar) inside a String (InString) at a given position (POS).
The temporary variable TempString and TempStringChar occupy in fact the same area.
Allowing to access the data as desired.

Dateianhang: CharInString.pdf  (60 Downloads)



=== Edited by jklm @ 4/15/2012 8:58 PM [GMT ] ===



Best regards
jklm

Suggestion was helpful? Thanks to rate it.

Top
  15.04.2012, 22:44
Beigetreten am: 04.01.2011
Letzter Besuch: 30.05.2013
Beiträge: 20
Bewertung:
Bewertung: keine [0 von 5 / 0 mal bewertet]. (0) 
Bewertung: keine [0 von 5 / 0 mal bewertet]. (0) 
Thank You jklm for your answer!
I've learnt something new!

Rnf:lblSmileyTooltip_
Top
Seite 1 von 1 (3 Objekte)
Aktionen