Siemens Unsigned Integer format

JDCROCKETT724

Member
Join Date
Jun 2010
Location
Michigan
Posts
249
I have a cognex camera that is transmitting a trigger id as an unsigned integer. However, everything in siemens displays it as a signed integer and so the number is not sequential. i.e. 1, 2, 3 ,4, 5 Is there an unsigned data type that I can select or another way to display the Trigger ID correctly?
 
However, everything in siemens displays it as a signed integer and so the number is not sequential. i.e. 1, 2, 3 ,4, 5
What do you mean by that ?

From 0-32767 the representation of signed and unsigned INTs will be the same.
If the ID does not go past 32767 it shouldnt be a problem.

Alternatively, you should be able to transfer the content to a DINT, and it will display correctly.
If the source unsigned INT is in MW4, you can transfer to a DINT in MD10 that should display correctly:

L MW4
T MW12 // yes, to bytes 2-3 in the DINT

Try it.
 
I am throwing something in here.
Is it possible that in addition to the signed/unsigned INT problem, the endianness is different ?
Try to display the bitpattern of various known values from the cognex camera.
Post the results here.
 
Where does it display as signed int?


If it is in Monitor Variables or block view online, the options are DEC or HEX.

But you can move the value to a double integer address and watch it as DEC and it will now show values from 0 to 65536 (and up to 2 BillionAndSomething signed DINT).

In STL like this:
L myINT
T myDINT

Now you should be able to see myDINT values from 0 to 65536.

Kalle
 
Where does it display as signed int?


If it is in Monitor Variables or block view online, the options are DEC or HEX.

But you can move the value to a double integer address and watch it as DEC and it will now show values from 0 to 65536 (and up to 2 BillionAndSomething signed DINT).

In STL like this:
L myINT
T myDINT

Now you should be able to see myDINT values from 0 to 65536.

Kalle
No you have to transfer to bytes 2-3 of the DINT address to display the unsigned INT value.
Your code transfers to bytes 0-1.
edit: My bad. Actually the transfer to a doubleword takes care of putting the bytes in the right places. Your code will work !

Here is how it looks like when you transfer the bitpattern for 32768 to bytes 2-3 in a DINT:

UnsignedInt_s7.png
 
Last edited:
Ok. I didn't need the trigger ID anyways so I gave up on it. Now I have a similiar problem with a floating point. If my addressing is correct, and so far it hasn't lead me to think that it is wrong, then I cannot get my REAL "Final Torque Result" to display correctly. Maybe when you see the image you can simply tell me I screwed up somewhere in my addressing and the value I am receiving is completely wrong. For my Angle Trend and Torque Trend I used the CAW instruction to get the correct value to display, but using the CAD instuction doesn't seem to give me correct results for my Torque Result which is a REAL datatype. The manual says the controller reports this value as a REAL in IEEE format. The image shows the value before the CAD and after. The value should read 29.70. Thoughts on this?

screen shot.jpg
 
You need to swap the words not the bytes. See example code. The push instructions are only there so that accu2 shows the value in hex (whilst accu1 is displaying in floqting point).

swap.JPG
 

Similar Topics

Good morning, all I am very new to siemens family and to STL, i have been playing for two days now and manage to get the scaling do in STL. Now...
Replies
3
Views
52
Hi! What is the way to convert the code from the Codesys code to the Tia Portal? Regards, WK
Replies
4
Views
110
Good Afternoon , It has been decades since I have done anything with Siemens . What is the Siemens name of their Servo Product Line and what...
Replies
10
Views
212
I'm using the Siemens PRONETA software to do some IO testing currently. I love the simplicity and fast testing capability. Does anyone know about...
Replies
0
Views
88
Hi, First time user of S5 Siemens. Is there any solution on how to solve this kind of error. HMI OP7 $613 DB-error No. 11 (0: 15) Siemens PLC...
Replies
9
Views
173
Back
Top Bottom