Sign in to follow this  
Followers 0
zubair136

Float Value FX2N Problem

12 posts in this topic

Dear All,

I am facing a problem in FX2n,

Infact i am making a totalizer from the flow. everything is fine. but client demands to add some totalizer value to start with totalizer.  the problem is that when i add 50000 value the value of registers stucks. although i am using 32bit float register along with DEADD command for Totalizer. the makes some steady at some place. i dont know why. but i give the totalizer 0 it works fine. 

Any Solution regarding this will be help. 

 

Value in the D72 = 0.0003

Share this post


Link to post
Share on other sites

Can you post your ladder? Also if I remember correctly, the first 127 words arent battery backed so they reset every power cycle.

Share this post


Link to post
Share on other sites

Ladder is simple as

 

M8013                                    Deadd d72 d500 d500

Share this post


Link to post
Share on other sites

The error is obvious: DEADD D500 D72 D72

1 person likes this

Share this post


Link to post
Share on other sites

in My case the value in D72 = 0.0003

then value of D500 struck at 8192.000 dont know why . Kindly help me out. you will be a life savour. 

 

Share this post


Link to post
Share on other sites

your code is not modifying D500, it is modifying D72

the other thing is that no sane person would do this in 32-bit floats. problem with it is that due to obvious way the floating type of REAL numbers are represented. they can cover wide range of values (big and mall, positive and negative) but there are limitations. one of them is that you cannot add two values  if they are too different (one is big and other is small). at some point the smaller value simply no longer contributes to the sum due to size of register. and 32-bit is really not that much, specially when you consider how those bits are used. this is why totalizers, position counters etc are implemented with integers. 

to put it in layman's term, you get 6 or maybe at most 7 good significant figures (digits) from a 32-bit real.

so your value 8192.000 requires 7 digits. in reality you may get only 8192.00

adding 0.0003 should produce result that is 8192.0003 which is 8 digits and obiously that is not going to work, result will be rounded to 6 (maybe 7) digits and you will loose the last digit(s) such as "3"

 

 

 

3 people like this

Share this post


Link to post
Share on other sites

Dear Panic Mode

thanks for your precious reply. 

 

but can u guide me that how can i do that. 

infact flow is around 6 m3/ h . i am making a totalizer . the value of flow for totalizer per second is around 0.0003 then how can i add them in previous total . 

Share this post


Link to post
Share on other sites

Try totalizing less often.  If flow is that low, why not do it once per minute?

1 person likes this

Share this post


Link to post
Share on other sites

This is a bit out of my scope of experience sorry. Could you try splitting the number up to two 32 bit reals? 8192.00 and 0.0003? then use once minute intervals (0.0003*60) for your instruction? and just use the flow per second in your display? youll lose some precision(not much). If youre doing a medical application or making rocket fuel you should avoid that. But if youre working on a dough mixer or something it should be fine.

1 person likes this

Share this post


Link to post
Share on other sites
17 hours ago, zubair136 said:

Dear. Can you explain it  please. 

 

If you have a measured value in D72 and an offset value in D500, you need to modify D72, nor D500. While would be better to store the result of operation in another pair of registers.

And yes, the colleagues are right - you need to increase a measured value in ten times at minimum, otherwise the measured value will be lost and you get an offset value as a result of operation due to resolution of floating point mantissa (2^23)

Edited by Inntele
1 person likes this

Share this post


Link to post
Share on other sites

thanks all for your great advices. thanks for helping me out. 

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