Converting Byte to ASCII Character

Rusty_K

Member
Join Date
Mar 2004
Location
Norway
Posts
73
Hello,
I am reading several BYTES from a PLC which each represent one ASCII character. How do I convert this so that WinCC will display the actual ASCII character and not the numeric ASCII code.

Any help would be greatly appreciated.

Cheers Mates!

R.K.
 
Hello, Rusty_K;
In WinCC tag management, you can set the type of data used by each tag used. Even if the value you collect from the PLC is purely numerical, you can determine how WinCC will treat the data.
Select the tag you want to display as a character (Open your channel configuration in Tag Management, double-click on the tag), open the droplist for data types, select "8-bit char" (my winCC is in French, so this might not bve the exact wording in english; Ipresume you will fing waht you need). Then go to runtime.
Hope this helps,
Daniel Chartier
 
Hey Dchartier,

What you mentioned is the very first thing I tried before I posted my question. However it still does not read it correctly and I'm not sure what I am doing wrong.

I have tried 2 methods :

1) I defined tag datatype as a 8 bit character (of length 1) while keeping the OPC address datatype as 8 bit unsigned value. This gave me an output of zero ( The 8 bit character I am reading is 57 > (9 in ASCII Format)

2) I defined both the tag datatype and OPC address datatype as 8 bit character (of length 1) and "string" respectively and this still did not work.

What am I missing?

Thanks for the help!

Cheers

R.K.
 
To view string characters in WinCC, the length of the tag has to be set to at least 3 and the tag type set to (Text tag 8-bit character set).

If you create a DB to store your strings and lets say you want 10 characters in the string. The string length in the DB must be set to 12. S7 uses the first 2 bytes to store string length data. When accessing the string from WinCC the tag will also have the length of 12.

S7-Example: address: DB1200.DBB0 Type: String [12]
WinCC- Example: address: DB1200.DBB0 Type: Text tag 8-bit character set Length: 12
In the above example, WinCC will display the characters starting with byte address DB1200.DBB2, which is the beginning of your 10 character string.

Just remember that the first 2 bytes are only used by the software.

Hope this helps,
Jeff M.
 

Similar Topics

Hi, I'm faced with a rather annoying issue. I'm using CoDeSys 2.3 on an IFM CR0401 PLC which is talking to a CR0451 HMI via a CANfox network. The...
Replies
10
Views
5,464
Hi, I am new to codesys programming and need some help converting a word variable into 2 byte variables. If anyone provides the sample in Codesys...
Replies
9
Views
22,985
Has anybody got a routine handy that will take an INT as input (1 - 21) and convert it to the Byte.Bit format that is needed to add to a basic...
Replies
14
Views
21,274
Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
208
Hello PLCs Forum, I am in a bit of a pickle and was hoping someone could offer me some help. I have a .rss file and just need to see the ladder...
Replies
2
Views
122
Back
Top Bottom