Jump to content

JZ10-11-R16 : Using a float

Recommended Posts



 I successfully figured out the way to do a linear conversion (using the SI 80-85). Thing is, when i tried to code it myself, I found out that I was losing precision because of the result of (y2-y1)/(x2-x1) to find 'm' because most of the time the result is going to be a float but all we can use is an integer. So for example, if the result of your equation is 4.356, you are going to have 4 into your integer address. So that when you multiply this result to the X in "mx+b", the error is just getting bigger.


4,356 * 2456 =  10 698.336

4 * 2456 = 9824


As you can see, this doesn't make any sense. 


Now that I am trying to configure a Paddle Wheels wired on the HSC inputs, I need to find a way to use a float because of the K Factors.




I can't accept that big of an error. Any idea how i could "create" a float using signed integers with this module?

Link to comment
Share on other sites

  • 2 weeks later...

You can use SB82 the long integer function bit.  In the sample lines here this is taking a high and low range of a pressure transducer tomake sure that I can maintain the precision of my calculations for decimal points.  In you case you would use the values 4356*2456 = 10698336  which will not fit in an interger but will fit in a long integer using the SB82 bit correctly.  Then take this number and divide by whateever number you needed to divide by.  At the end divide by say 100 (not 1000) to preserve your final answer as a value equal to XXXX.X which you will be able to show on screen.


While this is a patchwork solution that works you should really upgrade to a V130 or better vision model that can just perform floating point math directly and you will like much better.


SB82 usage

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...