Sign in to follow this  
Followers 0
kcox1980

Adding a REAL number to a DINT

6 posts in this topic

The application in question is a length measurement. Individual roll lengths are stored in a REAL data type but at the end of each roll the length is added to a daily total which is stored as a DINT type. At the end of the shift the operators record the number stored in the Length_Total into the log book and that value is used to determine material usage. We have some discrepancies on our usage and I suspect we are losing some length data in this calculation. The ADD instruction looks like this;

Source A: Length_Total  ~> DINT type

Source B: Roll_Length ~> REAL type

Dest: Length_Total ~> DINT

 

What happens to the numbers after the decimal in this calculation? Are they dropped off or rounded up/down?

Share this post


Link to post
Share on other sites

The DINT result should be rounded. If your 'Roll_Length' values after the decimal point are somewhat random the differences during the shift should somewhat cancel out. Note that the rounding uses 'bankers rounding' but it should have little effect. The only difference is when the fractional part is precisely .50000...

If the fractional part is very important then change 'Length_Total' to a REAL and have the shift operators record that number with however many decimal positions you feel are needed.

Share this post


Link to post
Share on other sites

Probably should have mentioned this in the original post but the units are in feet and the setpoint is 100.4 per roll. So if I understand you correctly that means I am correct in assuming that I am losing that 0.4' (plus or minus natural error in the system) on every roll?

Edited by kcox1980

Share this post


Link to post
Share on other sites

Yes, probably loosing the .4 on each roll. I suggest using the REAL format for the total.

Share this post


Link to post
Share on other sites

Thanks for your help. I realize this was probably a basic question but my primary PLC background is with Mitsubishi systems. I've been on this job for about 3 months and at this point I am basically self-taught with AB while awaiting my training classes scheduled for later this year.

Share this post


Link to post
Share on other sites

I was 'self taught' by reading ALL the manuals then doing a lot of thinking and trial and error. It is a fun profession.

1 person likes this

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