We were reading some posts form earlier about sending negative numbers to and from a PLC and robot. In our case we are using a Beckhoff PLC. We were having problems figuring out how to send negative numbers.
We were using 32 bit numbers. Unlike maybe other sizes of data this seems to have a sign bit already associated with it.
We looked at an example where a 12 bit number required adding out and then adding or subtracting 2^12 = 4024 seemed was suggested.
With the 32 bits though having a sign already in it the solution was simpler.
We simply defined in the PLC that the value coming in is a DINT and also the value going out to be a DINT. Using a DWORD, there was is a work around using the adding and subtracting of 2^32 but we found using DINT was more straightforward.
To retain decimal precision we also multiplied by 1000 before sending and divided by 100 on both the PLC and Robot before sending data.