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 Sat Dec 15, 2018 9:48 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jun 20, 2018 11:00 am 
Offline

Joined: Wed May 23, 2018 11:01 am
Posts: 5
Good morning,

I am kind of new to codesys, and on my project I am reading from a Schneider energy meter over modbus/tcp, but the variables that I get are in FLOAT32 format.

As an example, I read the current frequency on the network, that should be around 50Hz, and I get the 16967 value, or 4247 in Hex, which transformed with an online hex to float converter gives me the 49.75 value.

How can I transform the data in codesys?

check attached files,

thanks in advance,

Antton


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Wed Jun 20, 2018 10:13 pm 
Offline

Joined: Sun Jun 28, 2015 12:23 pm
Posts: 64
Hello
Create a UNION with members...

AsWord: ARRAY[0..1] OF WORD;
AsREAL: REAL;

Map your Modbus Words to Array members [0] and [1].
Your REAL number will be the Hz.

You may need to swap the map to [0] and [1] if the REAL number is wrong.
Regards
Paul


Top
   
PostPosted: Mon Jun 25, 2018 12:47 pm 
Offline

Joined: Wed May 23, 2018 11:01 am
Posts: 5
thanks for the reply!

I tried what I think you mean, but I do still read the 16968 value.

Any other suggestion? or may I be doing it wrong?

Thanks in advance,

Antton,


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Mon Jun 25, 2018 4:10 pm 
Offline

Joined: Tue Dec 03, 2013 11:52 pm
Posts: 94
A Union is a DUT (Data unit type). See example below. Using the original value you see the float/real value of 49.75

Attachment:
UnionExample.PNG


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Jun 29, 2018 8:14 am 
Offline

Joined: Wed May 23, 2018 11:01 am
Posts: 5
Correctly read!!

Thanks for the very helpful time you've spent!


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: Andreas Kehrer and 3 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:  
cron
Powered by phpBB® Forum Software © phpBB Limited