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

Hi, I'm setting up a modbus master on an S7-300. It seems to work in OB1 but not when I use it in OB35. Does anyone have any ideas why? Could...
Replies
9
Views
61
The past week we received a new piece of equipment from Germany which utilizes siemens controls. Typically in our company we use A.B. controls for...
Replies
12
Views
315
Hello I have a s7-1200 and I would like to read the tags present in this controller with my controllogix controller. The two controllers don't use...
Replies
5
Views
164
Hi need help why this “failure 5 emergency stop “ appears at every startup in the morning ? Have to shut off main switch at least 10 times on...
Replies
19
Views
313
i have two plc 1. s7-1212dc/dc/dc ip; 192.168.0.1 2. s7-1500 1513-1pn ip; 192.168.3.2 i need to get data from plc1 to plc2. any idea how to do...
Replies
5
Views
127
Back
Top Bottom