what are Integer, Real #, word, Hex, bin, etc

Siemener

Member
Join Date
Sep 2007
Location
Now on the move!
Posts
41
I'm looking for some link or document,
to clear some basics formats used in PLC programming to store, read, calculate, compare DATA.

I've at times had some problems converting one into another or comparing ONE TYPE with ANOTHER,
usually this happens when we working on a half developed system,
where half of the programming was done, and we are to complete where the dude left of, cleaning all his mistake.

for instance, I was installing a HMI on a machine where the PLC was compeletely programmed, the gentleman used BYTES to store some data, just a single digit number, when I hooked up the HMI (Maples) which I programmed to use WORD, had to change the PLC program on site to replace the BYTE to WORD instruction.

Can some 1 shed light, which type format is good for which type, any pros/cons for the types,.

I know these are the fundamentals, but I'm not ashamed to say, "YES, People I dont understand"
Please guide me to a source if explain this on a thread would be too complicated!

Regards,
 
thanks a lot

Thanks - that sorted out most of the confusions.

Now, once I encountered following scenario, let me know where I went wrong.


The Data was written in WORD say VW100
the DATA was for instance a Number "2"

If I'm not wrong word means two consequetive BYTES.
like,

"00000000 00000010"

Now when I read the BYTE VB100

I couldnt get the DATA correct? why is it?
my question, that since the other BYTE is not utilized,
or does not contain DATA,
actually WORD was used to store data, since the DEVICE did not have an option to write to a BYTE (and I had to EDIT the PLC program as stated in the above thread)

more confusions on the way....
 
If I'm not wrong word means two consequetive BYTES.
like,

"00000000 00000010"
Yes, you're right. The word VW100 is two bytes, VB100 and VB101. You're wrong in thinking that VB100 should contain the bit pattern 00000010, because VB100 is the left part of VW100 and contains 00000000. The right part containing 00000010 is VB101.

Kind regards,
 
Siemener said:
Thanks - that sorted out most of the confusions.

Now, once I encountered following scenario, let me know where I went wrong.


The Data was written in WORD say VW100
the DATA was for instance a Number "2"

If I'm not wrong word means two consequetive BYTES.
like,

"00000000 00000010"

Now when I read the BYTE VB100



I couldnt get the DATA correct? why is it?
my question, that since the other BYTE is not utilized,
or does not contain DATA,
actually WORD was used to store data, since the DEVICE did not have an option to write to a BYTE (and I had to EDIT the PLC program as stated in the above thread)

more confusions on the way....


I take it then you must be using an old TI , or the Simatic TI.

S5/S7 are the same

FW100 = FB100 and FB101
 
JVDCANDE,


Thanks for clearing the error.

You mean to say, that if a value is stored in the WORD,
and the Value is Equal or less than 255,
I will be able to read it with the BYTE instruction without any ERROR, by reading the Higher or RIGHT most BYTE.

In short the BYTES are read from LEFT to RIGHT,
however, the Bits are read from RIGHT to LEFT, so that;

A DW100 (being 4 Conseq. Bytes) stores a value of '2',
would mean the leftmost BYTE is B100, B101, B102 & B103,
and would mean BIT 103.1 would be 'ON'.

I'm just want to clear some fundamentals, of DATA handling and would apprecaite anything else you think I might come across.
 
Following corrections from others and more questions I have edited my original reply.

Binary, Integer and Real are the types of number that you will normally use in a PLC.

Binary can only have two values 0 or 1, Off or On.
Integer numbers don't have a decimal point and so can only be whole numbers.
Real or Float numbers do have a decimal point and so can be numbers like 3.142.

Bit, Byte, Word, and Double Word are the things that you store the numbers in.
So a bit will store a Binary number.
A Byte will store a small Integer number.
A Word will store a larger Integer number.
A Double Word will store either a Real number or a large Integer number.

How to choose an Integer or Real

It can be tempting to use Real numbers all the time because it can be any value you want with or without numbers after the decimal point. But Real numbers always need the storage space of a Double Word and Real calculations usually take longer than Integer ones. Also Real numbers are less accurate than Integer ones, for instance get your calculator and divide 1 by 3 and you get 0.33333 (may be more or less 3s depending on the screen size). But that isn't the true value, you would have to have an infinite number of 3s to truly represent 1/3. If you now multiply 0.33333 by 3 you get 0.99999 which is nearly the 1 we started with, but not quiet, it is an inaccurate 1. So use Real where you need to but use Integer wherever you can.

Byte, Word Or Double Word
Real numbers always use a Double Word so for them you have no choice but Integers can use any one of the three, and it is all about size. If you were asked to move two gallons of water would you choose to use a 5 gallon bucket or a 60 gallon drum, the bucket is more appropriate because that is the best fit. Same when it comes to Integers if you have a small Integer and any maths you do on it will result in a small Integer then use a Byte or Word size of storage. If you have a large Integer or any maths you do will result in a large Integer then use a Double Word size. There are exceptions to this rule, if most of the time a Word length will be OK but occasionally you need Double Word then you can convert from Word to Double and back again. But generally stick to the rule and you won't go wrong. And yet another exception, HMIs don't always like Bytes, so check what values your HMI can use.

What vaules can a Byte, Word and Double Word hold
This totally depends on your PLC and how many bits it uses in its calculations but listed below are the current norms for 16 bit system:
A Byte is 8 bits and storing an Integer can hold 255 without a + or -, or -128 to +127.
A Word is 16 bits and storing an Integer can hold 65535 without a + or -, or -32768 to +32767.
A Double Word is 32 bits and storing an Integer can hold 4294967295 without a + or -, or -2147483648 to +2147483647. Storing a Float/Real it can hold (-1.175495E-38 to -3.402823E+38 negative) to (+1.175495E-38 to +3.402823E+38 positive). A float/real value uses some of the 32 bits to hold the number before the E and some of the 32 bits to hold the number after the E. This is why if you view an integer value as a float/real or a float/real as an integer you will get a rubbish answer.
For an explanation of the E number system see below. The values given are for a Siemens S7-200 range PLC, check the manual of your PLC to be certain that they are the same.

If you want to see how Bits and Integer numbers are related start calculator in Windows and choose scientific from the View menu. Click on Bin and then enter a value of 16 1s. Click on Dec and it will convert that value to a Decimal Integer.

If you want to see the E notation in use then again use the Windows calculator and choose scientific from the View menu. Enter 5.27 then press the Exp button and enter 3, the result is 5270. So to translate 5.27E+3 to normal notation you just move the decimal point 3 places to the right. To translate 5.27E-3 you would move the decimal point 3 places to the left, 0.00527. (To use the negative values with the Windows calculator enter a value and then press the +/- key).

Relationship between Bits, Bytes, Words and Double Words
The relationship varies between PLCs, for instance for the Siemens S7-200 range the bits use a totally separate section of memory from the rest of the numbers. The picture below shows the relationships for a Moeller Easy Smart relay and a Siemens S7-200, check your PLC manual to be certain that it is the same.
Below for the Moeller: if you set M15 to 1 then MB01 would be 0, MB02 would be 64, MW01 would be 16384, MD01 would be 16384. Enter the values on the calculator to check.

Bryan

BitsBytesWords2.jpg
 
Siemener said:
A DW100 (being 4 Conseq. Bytes) stores a value of '2',
would mean the leftmost BYTE is B100, B101, B102 & B103,
and would mean BIT 103.1 would be 'ON'.
That's exactly what it would mean. You're spot on.

Kind regards,
 

Similar Topics

Good morning all, I'm integerating a device with a Rockwell PLC with V34 Studio 5000. The device reports error codes using a single integer to...
Replies
19
Views
1,265
Hi all, I've got a bit of a need to convert an integer (and a real in another situation) to a string with a particular format. This seems possible...
Replies
11
Views
2,435
Hello, Could somebody give for me advice how to seperate real number to integer Entered from Mitsubishi HMI GS Series to Mitsubishi PLC FX-1n...
Replies
2
Views
2,545
Hi everyone :* I am using using unity pro v.13 i want to do the mathematical function of floor() which makes for example 1.2 to 1 and makes 2.9...
Replies
7
Views
3,039
Have a device sending me 2 integers one is the value and the other is the divisor. Would there be a compact way to divide this value not have to...
Replies
11
Views
1,977
Back
Top Bottom