SillyBoy

How to handle floating numbers in CX Programmer ?

8 posts in this topic

Hello Everyone,

 

I am new to Omron PLC and HMI,

 

Currently i am working on a project using below hardware.

PLC- CP1L-EM40DT1D

HMI - NB3Q-TW01B

I want to input floating data from HMI to PLC and make some calculations using that floating data in PLC like scaling and etc...

So in NB designer i used floating input, and in cx programmer i have converted that float to 16bit, but what i am getting in 16bit is not looks correct...

Ex. I entered 10.9 from hmi and after float to 16 bit conversation it remains only 10.

 

So do you have any good idea to do this, can i use only integer instead of float in HMI ?

 

 

Share this post


Link to post
Share on other sites

CP1L will do floating point math, why convert?

Share this post


Link to post
Share on other sites

You lose the decimal point when you convert and it rounds it up. Yes you can use a UINT and scale it in the HMI so it will be entered as 10.9 but will just be 109 in the PLC.

Share this post


Link to post
Share on other sites
8 hours ago, gtsuport said:

CP1L will do floating point math, why convert?

Yes but some blocks can't, like SCL.

Share this post


Link to post
Share on other sites
1 hour ago, BobB said:

You lose the decimal point when you convert and it rounds it up. Yes you can use a UINT and scale it in the HMI so it will be entered as 10.9 but will just be 109 in the PLC.

As of now i am doing the same, in hmi it shows 10.9 and in plc i am doing all calculations as per 109.

Share this post


Link to post
Share on other sites
7 hours ago, SillyBoy said:

Yes but some blocks can't, like SCL.

The SCL instruction is for integers because you need to use it for integers to reduce rounding errors.  With floating point, you can just multiply or divide by a floating point number and then add or subtract a floating point number to do your scaling.  

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