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 Thu Dec 13, 2018 4:38 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Dec 03, 2018 1:44 am 
Offline

Joined: Mon Jan 22, 2018 10:07 am
Posts: 45
Hi,
I have two words that I need to combine into a 32-bit one
word1 must be the Most Significant one
and word2 must be the Last Significant one
how could I achieve this point?
Thank you


Top
   
PostPosted: Mon Dec 03, 2018 5:06 am 
Offline
Frequent User
Frequent User

Joined: Thu Mar 17, 2016 1:24 pm
Posts: 112
Check CAA Memory library.
https://help.codesys.com/webapp/s6roH8o ... n=3.5.12.0


Top
   
PostPosted: Mon Dec 03, 2018 3:54 pm 
Offline

Joined: Mon Nov 03, 2014 7:15 am
Posts: 42
Hi mikeardy!

The direct way in structured text would be

DWord := SHL(WORD_TO_DWORD(word1), 16) OR WORD_TO_DWORD(word2);

which makes a binary OR between the two variables after shifting the word1 to the most significant position.

Good luck!

Alfred


Top
   
PostPosted: Mon Dec 03, 2018 4:00 pm 
Offline

Joined: Fri Feb 23, 2018 3:41 pm
Posts: 64
If you need it to be stored, the declaring a union datatype may help.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 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