AB ControlLogix Dint and decimal places

Christoph

Member
Join Date
Sep 2003
Location
Indiana
Posts
345
All

I have an application where I will need to add a four digit decimal
triggered by an event. Will a Dint work with a 4 digit decimal?
and will its max value be lowered because of it?
 
Do you mean a number with 4 digits to the right of the decimal point? No, a DINT works for whole numbers only. Use a real number type for numbers that include fractions.
 
If you use a floating-point REAL for an accumulator, you need to understand how floating-point values are calculated and stored, or you can easily end up "losing data" because you've added a small number to a large number.

ControlLogix uses IEEE Single-Precision Floating Point encoding to handle floating-point numbers.
 
You may be able to use the DINT as a "fixed point" decimal. If, for example, you want to add 40.0001 to 123.4567, then that could be treated as 400001 + 1234567. Note that the maximum DINT (2,147,483,647) would effectively become 214,748.3647. You may need to do some kind of conversion later on, to actually use the "fixed point" number on an HMI or for normal math.
 
You may be able to use the DINT as a "fixed point" decimal. If, for example, you want to add 40.0001 to 123.4567, then that could be treated as 400001 + 1234567. Note that the maximum DINT (2,147,483,647) would effectively become 214,748.3647. You may need to do some kind of conversion later on, to actually use the "fixed point" number on an HMI or for normal math.

Fixed point is not quite that simple...for fixed point you typically separate the whole part of the number from the fractional, you multiply the fractional part by 2^x (the x is however big your "word" is minus a bit for signed and minus a bit for a whole 1 incase the number gets to big). I used fixed point quite a bit when writing filters on a micro processor that did not have embedded Floating point control

EDIT: Keeping track of the Decimal place can become very interesting which leads to the last part of fixed point you have to divide 2^z, I use z because after you do multiplication or division the decimal point moves therefor you have to change the number of decimal places to extract out
 
Last edited:
That sounds like one possible implementation of fixed point. I think it has the advantages of extra precision by using two registers instead of one, and probably also supporting multiplication and division of fixed point numbers. I think my method works only for adding and subtracting fixed point numbers from each other, and for multiplying/dividing fixed point by a standard integer.

I've seen my style of math used for things like accounting, where you might need to add two dollar values (with two fixed point decimal places) together, or multiply a dollar amount by the number of units. You would never need to multiply a dollar value by a dollar value, or add the number of units to a dollar amount.
 
Last edited:
After doing a quick check both forms are capable one is just binary fixed the other decimal fixed. The same decimal point needs to be kept track the same in both. Binary fixed point is more commonly used for speed reasons, however if you need to be exact decimal fixed point would work better. Binary fixed is typically an approximation of the number, but when you have a 32 bit number it can approximate quite accurately lol
 
Decimal vs Binary is the same principle, yeah. I like working with decimal because its easier (for me) to mentally shift a number by 3 digits than 3 bits, so I can easily see what is going on.

The other part, though, is I think the difference between you implementing a full correct mathematical system tracking the decimal point, and my simplified version which only allows certain operations in my math so the decimal point never moves.
 
Until Christoph replies, I've just had the thought that his "four digit decimal" could be a BCD number.. just saying....

Christoph, you need to define your requirements exactly, and you will get better advice.

Anyway, back to the thread title "AB ControlLogix Dint and decimal places"...

A DINT data-type has no inherent decimal places, they are used for storing whole numbers only...

The programmer may be using this "whole number" (DINT) tag to represent a number with 4 decimal places, but it is only an "implied" decimal number, and is 10,000 times bigger than the "implied" fractional number... eg. 12345678 is "representative of" 1234.5678, but that is only conceptual, i.e. an implied position of the decimal point.

Just for emphasis, I'll say it again "Christoph, you need to define your requirements exactly, and you will get better advice."
 

Similar Topics

Good Morning , I have a bank of Kinetix 6000 Drives that I'm getting faults on. I took notice in my ControlLogix , Controller Tags for the...
Replies
3
Views
3,713
In ControlLogix I have an array of 384 bits (BOOL[384]) that I need to move to an array of integers (DINT[12])so that I can refer to them in a...
Replies
17
Views
12,052
Hi guys. I have a tag in ControlLogix -> "Control" of type DINT We can have a tag of type I/O integer in Wonderware refer to the PLC tag easily...
Replies
3
Views
6,043
I'm stumped, for some reason. How do I copy 2 ints into a single dint, particularly if byteswap may be involved?
Replies
3
Views
9,938
Why does the controllogix redundancy modules use a single mode fiber vs multimode fiber?
Replies
1
Views
78
Back
Top Bottom