Siemens Integer to String

JOLTRON

Lifetime Supporting Member
Join Date
Aug 2006
Location
MI
Posts
692
I am having issues with the Integer to String fuction (FC16) in my cpu 313.

My FC is running and my math before hand is being calculated but not getting anything out of my FC.

The line going into the FC is green but the actual FC is dotted blue like it isn't being processed.

Am I missings something simple.

Right now it's trying to conver 310 to a string. My string in my db is set to 3 characters.

Any ideas?

Thanks,
-Joel
 
From the Siemens help (F1) for FC16:

Description
The function FC16 converts a variable in INT data type format to a string. The string is shown preceded by a sign. If the variable given at the return parameter is too short, no conversion takes place and the binary result (BR) bit of the status word is set to “0".

You need space for the sign.
 
So if I'm looking to convert
DB40.DB22 - INT which equals 310
into a string
DB40.DBB32 - STRING[4]

DB40:
DBB32 - Max bytes
DBB33 - Actual bytes
DBB34 - sign????
DBB35 - 3 (char)
DBB36 - 1 (char)
DBB37 - 0 (char)

Is this the format of how the return sends the string?

I guess I'm missing something on how this returns data. I have tried a string of length's 3,4,5,6,10,254.
I thought it would just return the max, actual, sign and 3 characters.
 
Last edited:
Your analysis is correct. Note you cannot monitor a string in a DB - I've copied the string to chars to show what is happening.

string0909.JPG
 
I'm getting confused as to why mine is not working.
Here is a pic of my call for the FC. had to rename it my program already had a FC16. My string in my DB with a max of 4. and my empty VAT for that string. Do you see anything wrong with it?
 
Can you be sure that something else in your code is not overwriting the max string length - the only reason the ENO output from FC16 is false is when the string length is insufficient to take the resultant string.

Try the following code which writes a string to the temp data area. As its the temp area, the max length has to be loaded programmatically before the string variable can be used.


mystring009.JPG
 
Set it up as Local with the manually seting up the header and it works great. Thanks for all your help.
 
I was using our training/testing station. There were some FC's in the PLC that weren't in copy I was using. So the DB was getting over wrote. My bad for not comparing first :(
 

Similar Topics

I have a cognex camera that is transmitting a trigger id as an unsigned integer. However, everything in siemens displays it as a signed integer...
Replies
10
Views
6,221
I am using Siemens Step 7 with an S7-400 Procesor. I am looking for a sleek way to count a number of bits and store the result as an integer...
Replies
5
Views
6,380
The past week we received a new piece of equipment from Germany which utilizes siemens controls. Typically in our company we use A.B. controls for...
Replies
9
Views
175
Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
5
Views
142
Hi need help why this “failure 5 emergency stop “ appears at every startup in the morning ? Have to shut off main switch at least 10 times on...
Replies
19
Views
304
Back
Top Bottom