Question I was asked, where are these derived from

russrmartin

Member
Join Date
Aug 2002
Location
Eastman, Wisconsin
Posts
744
I was asked the other day by somebody where the #s +-32767 and +-4095 are derived from. I came to the conclusion that I had no idea really, I had just accepted the fact that they are what they are and used them accordingly. Anyone have any input?

Russ
 
+- 32767 is a 16 bit integer, i.e. if all 16 bits were on you would have a number of 65534 but they often use the last (left hand side bit) to determine + or - hence the +-32765. 4095 is the same deal but in a 12 bit format so it will be between 0 and 4095, I don't think the first bit is often used as a sign bit bit if it was it would be +-2047. Just different ways of showing 1 and 0.
 
The range, in decimal notation, for a 16-bit signed integer is -32768 to +32767 (two's complement format).

A 12-bit binary number (typical analogue input) has a range 0 to 4095.
 
The numbers you mention are defined by the number of bits.
The number is based on the 'Base 2' number system. In memory, you can only have 2 states - on or off. With one bit, you can only count to 1 - Zero or 1. With 2 bits, you can count 0-3. 4 bits, 0-15.
Each time you add a bit, the highest number doubles.
2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536.
Typical numbers in a PLC:
8 bits = 0-255
12 bits = 0-4095 (Analog cards are typically 12 bit)
16 bits = 65535. Usually split in a PLC as -32767 to +32767.
The CPU is 16 bit. Internally, they use 15 bits to count from 0-32767. The 16th bit is called the 'sign' bit.

For darrenj,
4 bits = Nibble
8 bits = Byte
16 bits = Word
32 bits = Double Word
 
No sarcasm intended here , and the advice you've been given is good , but you may also want to take a look at the other common relationships with regard to data types , as all these things are very closely tied up .
 
May PLCs now have 64 bit maths - signed and unsigned. Then there is IEEE 754 floating point and my favourite PLC now has 64 bit floating point - Mantissa etc.

When referring to word types IEC, the following applies
UINT = unsigned integer - 16 bits - 0 to 65535
INT = signed integer - 16 bits - -32767 to + 32767
ULINT = unsigned integer long - 32 bits - 0 to 4294967295
LINT = signed long integer - 32 bits - 0 to 2147483647.
Then on to 64 bit Etc, Etc

The easiest way to see the relationship is to use the Windows calculator. For example, a signed 16 bit word uses 15 bits for the value. Select binary, type in 15 x 1s and change the value representation to decimal. The result is 32767. As you have only typed in 15 x 1s, the most significant bit is the sign - 0 for positive and 1 for negative. This represents the IEC word type INT (signed integer). The Windows calculator is absolutely invaluable for converting word types. For all of us who play with word types in PLCs, the calculator is probably the best accessory available in Windows. And when one is bored beyond belief waiting on others to gate their s**t right, there is Solitare, Minesweeper etc.
 
Last edited:
Why?

Why 4, 8, 16, 32, 64, 128 bits etc?
PDP 8s have 12 bit registeres. I beleive there were some old 36 and 18 bit mini computers in the past. PIC microcontrollers have 12, 14 and 16 bit instructions depending on the model.
Early Intel micro controllers had 4 bit registers. Look up the 4004 and 4040. Actually 4 bit microcontrollers are still used today. There are Motorola/Freescale DSPs that use 24 bit registers and Analog Devices has DSPs with 48 bit instructions and 32 bit data. TI has 128 bit instructions. Actually it fetches 128 bits at a time and there are as many as 8 16 bit instructions in the 128 bits.
Why 4, 8, 16, 32, 64,128 bits etc?

LINT = signed long integer - 32 bits - 0 to 2147483647.
Not quite right. What is wrong?

What is the largest odd integer that can be represented in a 32 bit float?
 
LINT - Error is not giving the lower boundry correctly (-2147483647)

Largest odd integer for a 32 bit IEEE 754 float? Hrm...
It should be a 24 bit mantissa, no? so 16777215?

Hrm.. thinking about it... it is really a 23 bit mantissa, with a phantom 1 assumed for the 24'th bit. So, the max would be actually 0x7fffff, which is 8388607 as the fractional part, stick a 1 in front, you get 18,388,607. Is that right?

trying to remember number formats for floating point always makes my head hurt.
 
Last edited:

Similar Topics

The training class I just finished today was really great. I now have a good understanding of vfds. I cannot wait to take this knowledge into the...
Replies
2
Views
9,427
I have an HMI 2711R - T4T Series B, and I want to know which PLCs, besides Micro 820, can communicate with it.
Replies
2
Views
61
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
63
I'm working with a project that contains some routines in ST but mostly in ladder. Am I correct in assuming this 'rung': DB1001DO._01AV55_OPEN :=...
Replies
4
Views
100
Is there a way to reset the count on the RS Logix BackUp?? XXXXX PROGRAM IN PROGRESS_BAK445.RSS XXXXX PROGRAM IN PROGRESS_BAK446.RSS XXXXX...
Replies
8
Views
252
Back
Top Bottom