Followers 0

# +32767 limitation

## 10 posts in this topic

Good day, I have a Stepper Motor with position feedback. It gives values from -2,147,483,648 to +2,147,483,647. I only need values from some -200 to +46,900. The problem occurs is when the feedback reaches +32767. Instead of an incrementing value, it goes immediately to -32768, -32767, -32766 instead of +32768, +32769 and so on. This problem is solved when I use "Signed Double Integer (DINT)". The problem this time is when the value reaches (-). Instead of -1, -2, it gives me a value of +65535, +65534 and so on. I don't know what to do converting these numbers and it confuses me a lot much more scaling them into measurement (mm). Someone please help me. Thanks, Andrei K.

##### Share on other sites

DINT should be fine for your application. You are probably just not monitoring the value as a signed double integer. Change your format so that you can see it as a signed double integer and when you drop below 0, you will see a -1. The way that the formatting for an integer works is as follows: If you are using an unsigned integer (UINT), the values can range from 0 - 65,635 as shown below:

For signed integers (INT), the negative numbers are determined by bit 15. If bit 15 is on, then the number is negative. This range is shown as an unsigned integer in the pic below:

Conceptually in your mind, you can think of it as if the upper half of the range of values is picked up and shifted to be the lower half (negative values) as I am trying to illustrate in the picture below:

When you are monitoring the value as an INT, 32768 (as a UINT) becomes -32767 and 65535 becomes -1. So, it is all in how you are looking at the data: A binary pattern of all 1s: 1111 1111 1111 1111 can be interpreted many ways. As an unsigned integer it = 65,535 As a signed integer it = -1 It is in how it is interpreted. The same applies to DINT and UDINTs, but the number ranges are much higher since the values are 32 bit. (0 - 4,294,967,295 as a UDINT and -2,147,483,648 to 2,147,483,647). Hopefully this helps you to understand.

##### Share on other sites

By the way, to change the format that you are monitoring in CX-Programmer, you need to do the following things: If you are monitoring in the watch window at the bottow, make sure to choose the format DINT as shown below:

If you are monitoring the data in your ladder program, make sure that the instruction that you are using is a double integer function and then make sure that the signed integer button is pressed as shown below:

And if you are in the Memory window, make sure to choose the signed integer button and the 2W (2 word, 32 bit) button as shown below:

Good luck!

1 person likes this

##### Share on other sites
Again great instructins, Mike! You're batting 1.000!

##### Share on other sites
Awww shucks. Thanks Jay!

##### Share on other sites

Your instructions are good but I've already done that. Two points: 1) If I use Signed INT, it reads (-) Integers but can only read up to +32767. 2) If I use Signed Double INT, -1 becomes +65535 (FFFFh) though it can read more than +32767. More importantly, I need to Scale these values into measurement (mm). Thanks, Andrei K.

##### Share on other sites
Your GUI (interface) is writing the data as a single (16-bit) signed integer. You need to change the interface to write the data as a 32-bit Double signed integer. For simple scaling in the PLC, I would use a structured text function block to do a quick scale. I will post one for you later if I get a chance (I will assume CP1H). I also assume that you want to scale the DINT to another DINT that specifies mm. If you want to scale the command in your interface, I am not sure how to do that, it depends upon your interface. Edited by Michael Walsh

##### Share on other sites
Right on! I just figured that out. Oriental Motor gives #FFFF instead of #FFFFFFFF that's why it doesn't give me "-1". For this matter, I'll just add #FFFF in case I encounter values such as "#FFFF using comparison logic. Oh yeah, thanks, I'll need the scaling function. I learned how to Scale in Structured Text using "y=mx+b". I'm using CP1E though. Thank you very much.

##### Share on other sites
Sorry, I don't believe that any of the models of the CP1E support Function Blocks (correct me if I am wrong).

##### Share on other sites
They don't support FB's. :)