Sign in to follow this  
Followers 0
engineerBR

DWORD to Floating Point Problem

3 posts in this topic

I am having problem converting a DWORD variable to a floating point decimal. 

I've tried using the DWORD_TO_REAL function. Having the hex value "41E9B814" as an input I was expecting to get "29.2148819" as an output. However, I'm getting "1.110194.." as the output.

Any ideas?

 

 

Capture.PNG

Share this post


Link to post
Share on other sites

The DWORD_TO_REAL treats the DWORD as if it is unsigned integer format.  Your value is already in real format, but it is in a variable that is treating it as a DWORD.  The DWORD_TO_REAL instruction then converts the UDINT value of your DWORD to a real number.  I am guessing that the Force Variable is a union and that this is coming in via EtherNet/IP or something....

You need to use the CopyDwordToReal instruction shown below:

CopyDwordToReal.jpg.973bf483087760d82425

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0