data type

panthripu

Member
Join Date
Mar 2004
Posts
228
hi all
i want to know, where should i use integer/real/double/words etc.or what is the differece in all these ?
 
Integer - To hold integer values - upto 32767 Eg:- 376, 5678, 2 etc.
Real - To hold real values(decimal) Eg:- 0.567, -1.245, 2345.2345 etc.

Hope this helps.
 
Generally used PLC conventions:

Integer - 16 bit signed integer value (15 bit + sign)
Word - 16 bit unsigned integer value
DInt - 32 bit signed integer value (31 bit + sign)
DWord - 32 bit unsigned integer value
Real / Float - 32 bit floating point value
Double - 64 bit floating point value.


As to which you would use? That depends entirely on your application. Keep in mind when working with reals, that in (all) computer/PLC systems, they are only approximations of actual numbers, and there is a limited dynamic range when working with them. Also keep in mind with integer types, that constantly 'adding 1' to an integer can cause it to roll over and become negative.
 
A couple of clarifications are in order.

The ranges of integers in both of the above replies are not universal. I suspect chavak and rdast are most comfortable with Allen Bradley PLCs, which do use those ranges. Other brands use different ranges. For example, AutomationDirect.com uses 0-9999 for integers. And not all PLCs have the capability to use negative integers. And not all brands have double word integers.

For most operations and wherever possible you should use integers instead of real numbers (also known as floating point). That's because integer operations are, for most PLC brands, faster and take less memory and scan time. I generally use real numbers only when I'm doing calculations that may result in a number above or below the allowable range for the particular PLC used.
 
hi tom,
In ur reply,does the range 0-9999,mean representation in BCD numbers???
bcoz 0-9999 in BCD also take 16 bits as 0-32767 in binary.
 
Yes, the representation is BCD in this example. JHowver, the math operations also work in BCD, so for all practical purposes 0-9999 is the useable range for integers.
 
Tom,

You're kidding, aren't you?

Are you saying that AD handles Integers in BCD form only???
With a range of 0 to 9999?

Please 'splain!
 
It's been a while but I think you can postscript most of the math operations in the AD stuff with a 'B' to have it operate as a binary operation.
For example a 'MUL' would be a BCD multiply and a 'MULB' would be a binary multiply.
Again, it's been a while, but I don't remember a decimal display in the AD stuff. You could view the numbers as BCD or HEX.

Keith
 
Terry Woods said:
Are you saying that AD handles Integers in BCD form only???

No Terry, that's just its default data type. It handles all the 'popular' data types as well... :nodi:

See the attached .PDF for a better 'splanation... đź““

beerchug

-Eric
 
Well, I've always said that there are some things I like and some things I dislike about every PLC brand.

0-9999 BCD for integers isn't a problem, and I have done a lot of very complex calculations using this format. Unlike many brands, the stack doesn't overflow if an intermediate result exceeds 4 digits. When it fails, the ADC line does have floating point math (Real numbers) as well as double integers.

The thing I don't like about the ADC is that converting from BCD to real numbers isn't direct - you need to do an intermdiate step. Like the limitations of any PLC, though, you get used to it and it really isn't a big problem.

(I do miss the A-B CPT function sometimes, though.)
 
Last edited:
Tom Jenkins said:
(I do miss the A-B CPT function sometimes, though.)

It looks like the ADC crew are working on something along these lines. See the LAST post by franji1 on THIS page. You'll have to manually scroll down the page. I can't link directly to the post... :(

Phil has spoiled us here, so I get frustrated when posting on that forum... :p

beerchug

-Eric
 

Similar Topics

I cannot add SLC500 analog input tag (I: 8.3) to EZSeries Touch Panel Editor (V 5.3). I used all the listed tag datatype but it all says "Invalid...
Replies
10
Views
243
Hi guys, I have no experience when working with AllenBradley PLC, but I hope someone could clarify the result of multiplication shown in the...
Replies
14
Views
2,182
Trying to get data types (AS Structures) to update after a new tag import is made from PLC. WinCC can show red if an existing element was removed...
Replies
0
Views
269
Is there a way to use LREAL Data type on L71. I am getting 64 bit Double (IEEE754 Double precision 64-bit) data from a modbus device onto PLC via...
Replies
6
Views
948
Back
Top Bottom