DINT converting into a string... (S7)

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
I have 3 values.

DINT values.

They make a product number when assembled together.

D: DINT;
L: DINT;
H: DINT;

The variables D, L and H are entered in WinCC Flexible Runtime.

What I need as a result is:

D.L.H as string format


If D=25, L=3000 and H=30

Then I want a string like this:

25.3000.30


Can this be done in STL or SCL ?
 
That's pretty easy, but what are you doing with this string? If it needs to be converted to a string, why don't you just enter it as a string in the first place?
 
to show

I want to show a string in wincc flex...

okay, I could place 3 I/O fields and place decimal points between them...

to convert, calculate it to ascii chars and use the ASCII table ?



S7Guy said:
That's pretty easy, but what are you doing with this string? If it needs to be converted to a string, why don't you just enter it as a string in the first place?
 
hmm

I Agree

I will place I/O fields...

I made it AGAIN, to difficult


S7Guy said:
That's pretty easy, but what are you doing with this string? If it needs to be converted to a string, why don't you just enter it as a string in the first place?
 
Let me get this straight: You want them to be able to enter something like 20.1000.45. And, these three values are written down and used as INTs in the PLC? Could you just use three fields in Flex and add an ASCII "." between them? Or will Flex not let you do that?

Anyway, if converting in unavoidable, I wouldn't use a table. If you are just using numbers, all you have to do is add 48 to each digit to convert it to ASCII. For instance, decimal 5 = ASCII 53 (or it might be easier to think in terms of hex, where 0x30 - 0x39 = decimal 0 - 9). Then, for multi-digit INTs, you will have to seperate each digit by dividing by 10, 100, 1000, etc and extracting digit that needs to be converted.

edit: Ok, nevermind. I'm glad you got it working.
 
Combo, in the Standard Library under IEC Function Blocks you'll find
  • FC5 DI_STRNG to convert from DINT to string
  • FC2 CONCAT to concatenate strings
These should do the trick, even in ladder.

[edit]I just tested it and you also need IEC Function FC4 DELETE to get rid of the sign in the strings.[/edit]

Kind regards,
 
Last edited:
I'll

I'll try them, thanks

jvdcande said:
Combo, in the Standard Library under IEC Function Blocks you'll find
  • FC5 DI_STRNG to convert from DINT to string
  • FC2 CONCAT to concatenate strings
These should do the trick, even in ladder.

[edit]I just tested it and you also need IEC Function FC4 DELETE to get rid of the sign in the strings.[/edit]

Kind regards,
 

Similar Topics

We just completed the conversion of a PLC 5/80 to a 1756-L8x processor. The old 5 program had numerous MSG instructions sending data to/from...
Replies
24
Views
9,520
Is there anyway to convert a BOOL to a INT (DINT or SINT) in ladder logic. I am working in RSLogix5000 and am attempting to count 4 Discrete...
Replies
3
Views
5,503
I need to convert DINT's to INT's to provide MODBUS data registers. What is the best way to do that in a 90-30 / VersaPro project?
Replies
6
Views
14,292
Hi I am being given several fault words (as a DINT) from a Drive that I am receiving into a Compactlogix L33ER controller. I have a small...
Replies
12
Views
1,143
I am working on a project with a Controllogix 5582 processor using v32 firmware where I will be communicating with a Genset using Modbus TCP. It...
Replies
14
Views
978
Back
Top Bottom