08-13-2012 02:32 PM
I am using Lookout to control a variable speed drive via Modbus ethernet. If I send a number from 0 to 20000 to address 400002, it adjusts speed in the forward direction from 0 to 100%. I need to send the "two's complement" of that number to control reverse speed. Simply sending -20000 is not producing reverse direction on the drive. How do I send a two's complement of a number?
10-08-2013 01:04 PM
I need to use Lookout to control a variable speed drive by using two's complement for the negative direction. It appears, the Lookout data member does not allow you to enter a negative number to write to Modbus 40002 or 40003. Any way around this?
10-08-2013 01:06 PM
Were you able to find an answer to the 2's compement problem?
10-08-2013 01:20 PM
Use the float datamembers
10-08-2013 01:27 PM
Thanks for this. Can you be a bit (pardon the pun) more descriptive as to how a floating point number ends up in Modbus 40003 as two's complement?
10-08-2013 01:40 PM
I myself do not have the time to make an example, but this could help point you in the right direction.
http://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html
http://twos-complement.calculator.io/
10-16-2013 11:33 AM - edited 10-16-2013 11:37 AM
Basically what I discovered, behind the math geeks' mumbo jumbo, is that any binary number greater than half of the range is the equivalent of a negative number. So for a 16 bit integer, which has a decimal range of 0 to 65535, any number greater than 32767 is a negative of a number below 32766. This of course limits the decimal range to -32766 to +32767.
If I want to transfer the value +10000 the integer value would be 10000. If I want to transfer -10000 the integer value would be (65535 - 10000) which is 55535.
If I want to transfer the value +25535 the integer value would be 25535. If I want to transfer -25535 the integer value would be 40000.
Let me put it a more intuitive way. Positive numbers count forward from zero. Negative numbers count backwards from 65535, or whatever the top decimal number of the binary range is.
10-16-2013 07:17 PM
Glad you got it figured out.
And thanks for posting a solution
10-17-2013 11:10 AM
After some googling of 2's complement and significant trial and error, I managed the same result. I like your explanation but one still has to shake his head a few times while scaling this math. I am working with a ABB ACS 600 drive. ABB was no help in this matter. I will let them know the solution. Thanks
10-23-2013 06:56 AM - edited 10-23-2013 06:59 AM
That's funny. The original question was from when I was working with an ABB ACS 550 drive, and I found ABB to be no help on this question as well. In every other question for which I have called their tech support, they have been excellent, but this one issue was a dead end. "Just send over the two's complement" "What is that?" "I don't know, just send it over"