Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

How to convert 2 word Values to Float value (in 32 bit big endian format) in Machine Expert (M251 PLC)

HVAC and Pumping Forum

Support Forum for HVAC and pumping machines, Modicon M17x and EcoStruxure Machine Expert HVAC software for chillers, AHU, CRAC units for datacenters or process chillers applications - from design, implementation to troubleshooting and more, by Schneider Electric.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • Industrial Automation
  • HVAC and Pumping Forum
  • How to convert 2 word Values to Float value (in 32 bit big endian format) in Machine Expert (M251 PLC)
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
FedericoM
Commander FedericoM Commander
66
Bastian_Schmitz
Admiral Bastian_Schmitz Admiral
47
LeTomas
Lt. Commander LeTomas Lt. Commander
14
View All
Related Products
product field
Schneider Electric
EcoStruxure™ Machine Expert
product field
Schneider Electric
Logic Controller - Modicon M251

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Solved Go to Solution
Back to HVAC and Pumping Forum
Solved
krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-10-17 12:14 PM

0 Likes
7
1008
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-17 12:14 PM

How to convert 2 word Values to Float value (in 32 bit big endian format) in Machine Expert (M251 PLC)

Hello,

 

I am using M251 PLC to read data of Master Pact MTZ and Compact NS breakers (both status and measurement signal). Measurement signals like current, voltage, etc. getting in word format (2 words for one signal). I need to covert this 2 word values to Float value (in 32 bit big endian format) in PLC logic to display HMI but couldn't found any block in Machine expert.

 

In Modscan32, I am getting correct value in swapped float. 

 

In Machine Expert, I tried  to convert values from %MW0 and %MW1 to %MD0 (as a REAL and DWORD) but not get correct result as in ModScan32.

 

Kindly advice how to read float value (in big endian format) in Machine expert. Thanks

Labels
  • Labels:
  • Modicon M2xx
  • Tags:
  • english
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic

Accepted Solutions
krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-12-24 11:46 AM

0 Likes
0
658
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-24 11:46 AM

Hi,

Thank you @Obraysingh1122 , @johnabraham1122  and @Bastian_Schmitz  for your reply on this case.

 

Kindly find below link which is explaining the easiest way to convert 2 word Values to Float value (in 32 bit big endian format).

https://www.youtube.com/watch?v=JPJrG8t_5GA

 

krishnamodi123_0-1735068807789.png

There is a video made on SoMachine (old version of MachineExpert) in the link. I did the same way in Machine Expert and it worked.

 

Also,  explaining below as a Example for everyone:

 

%MW0     %MD0 (need to use Data Type "Real")

%MW1

%MW2     %MD1

%MW3

.

.

.

%MW100     %MD50

%MW101

See Answer In Context

Reply

Link copied. Please paste this link to share this article on your social media post.

Replies 7
Bastian_Schmitz
Admiral Bastian_Schmitz Admiral
Admiral

Posted: ‎2024-10-17 10:41 PM

0 Likes
1
983
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-17 10:41 PM

Hi,

I you could create a function like that (copied from OSCAT) (OSCAT page)

FUNCTION DW_TO_REAL : REAL
VAR_INPUT
	X : DWORD;
END_VAR
VAR
	pt : POINTER TO REAL;
END_VAR

(*
version 1.0	18. apr. 2008
programmer 	hugo
tested by		tobias

this function converts a DWORD to REAL in a bitwise manner.
*)

(* @END_DECLARATION := '0' *)
pt := ADR(X);
DW_TO_REAL := pt^;

(* revision history
hm	18. apr. 2008
	original version

*)
END_FUNCTION
 
 
Reply

Link copied. Please paste this link to share this article on your social media post.

johnabraham1122
johnabraham1122
Cadet

Posted: ‎2024-10-17 11:02 PM

0 Likes
1
969
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-17 11:02 PM

To convert two-word values to a float in 32-bit big-endian format in Machine Expert (M251 PLC), follow these steps:

  1. Combine the two words into a 32-bit value.
  2. Swap the byte order to convert it to big-endian format, if necessary.
  3. Use the WORD_TO_DWORD function to merge the words, then apply TO_REAL to convert the DWORD to a float.

Ensure the byte ordering is handled correctly to get accurate results.

Reply

Link copied. Please paste this link to share this article on your social media post.

krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-10-18 04:49 AM

In response to johnabraham1122
0 Likes
0
959
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-18 04:49 AM

Hi John,

 

Thank for your reply on my query.

 

I already tried this. WORD_TO_DWORD block combining 2 word value and make DWORD. TO_REAL block only changing datatype from DWORD to REAL, not converting DWORD to FLOAT value.  

Reply

Link copied. Please paste this link to share this article on your social media post.

krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-10-18 04:51 AM

In response to Bastian_Schmitz
0 Likes
0
959
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-10-18 04:51 AM

Hi Bastian,

 

Thanks for sharing. I will test with this and let you know.

Reply

Link copied. Please paste this link to share this article on your social media post.

Obraysingh1122
Obraysingh1122
Cadet

Posted: ‎2024-12-22 04:54 AM

0 Likes
1
677
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-22 04:54 AM

 

To convert two 16-bit word values into a 32-bit float in big-endian format in Machine Expert (M251 PLC):

  1. Combine the Words: Use a bitwise operation or a function block to merge the two 16-bit words into a 32-bit variable. Ensure the word order matches the big-endian format.

    • Example: CombinedValue := (Word1 * 16#10000) + Word2;
  2. Type Casting: Use the type casting function to convert the combined 32-bit value to a REAL type.

    • Example: FloatValue := TO_REAL(CombinedValue);
  3. Verify: Ensure the endianess and value alignment match your system’s requirements. Use a debugger or monitor the variable to confirm correctness.

Reply

Link copied. Please paste this link to share this article on your social media post.

krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-12-24 11:27 AM

In response to Obraysingh1122
0 Likes
0
659
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-24 11:27 AM

Thanks @Obraysingh1122  for sharing a solution. It might will work but I didn't tested this way. Please check my following reply which I implemented and worked perfectly fine on site.

Reply

Link copied. Please paste this link to share this article on your social media post.

krishnamodi123
Crewman krishnamodi123 Crewman
Crewman

Posted: ‎2024-12-24 11:46 AM

0 Likes
0
659
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-24 11:46 AM

Hi,

Thank you @Obraysingh1122 , @johnabraham1122  and @Bastian_Schmitz  for your reply on this case.

 

Kindly find below link which is explaining the easiest way to convert 2 word Values to Float value (in 32 bit big endian format).

https://www.youtube.com/watch?v=JPJrG8t_5GA

 

krishnamodi123_0-1735068807789.png

There is a video made on SoMachine (old version of MachineExpert) in the link. I did the same way in Machine Expert and it worked.

 

Also,  explaining below as a Example for everyone:

 

%MW0     %MD0 (need to use Data Type "Real")

%MW1

%MW2     %MD1

%MW3

.

.

.

%MW100     %MD50

%MW101

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of