CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Dec 19, 2018 10:15 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Sep 19, 2018 12:55 pm 
Offline

Joined: Tue Sep 11, 2018 7:59 am
Posts: 5
hello ,
I am New In PLC programming And I Need Help.
I have Array Of DINT Which I want to Convert Into STRING Or ARRAY Of STRING , How Can I Do it ?


Thanks a Lot :)
Anu


Top
   
PostPosted: Wed Sep 19, 2018 1:57 pm 
Offline

Joined: Tue Jun 26, 2018 1:31 pm
Posts: 15
see its so simple

no need to use any conversion

codesys is best for this

you just define dint variable at some physical address

define string array on the same address thats it

e.x Dintarray: array[0..30] of DINT AT %MDW100;
Dintarray_STRING: array[0..30] of STRING AT %MDW100;


Top
   
PostPosted: Wed Sep 19, 2018 8:38 pm 
Offline
User avatar

Joined: Fri Jan 19, 2018 3:38 pm
Posts: 56
Allthough TurckOne's suggestion will work, it would be wiser to avoid any hardcoded memory adresses.

Instead you can use a more modern approach via a UNION for this kind of operations as it is meant for this.
I'd suggest something like the following example;
Code:
TYPE myUnion:
UNION
    ardiMyArr : ARRAY [0..4] OF DINT; // 16 byte
    sMyString : STRING[16]; // 16 byte
END_UNION
END_TYPE

See CODESYS help on UNION datatypes;
https://help.codesys.com/webapp/_cds_datatype_union;product=codesys;version=3.5.12.0

_________________
https://github.com/Aliazzzz


Top
   
PostPosted: Thu Sep 20, 2018 1:00 am 
Offline

Joined: Sun Jun 28, 2015 12:23 pm
Posts: 64
Inside a FOR loop...
StringArray[i] := DINT_TO_STRING(DintArray[i]);


Top
   
PostPosted: Fri Sep 21, 2018 2:51 pm 
Offline

Joined: Mon Oct 01, 2012 8:33 am
Posts: 47
If you want to convert the numeric value of each DINT array element then use ph0010421's method. If the DINT array contains ascii data then use Aliazzz's method.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited