Hello Guest it is December 02, 2020, 08:08:55 AM

Author Topic: Modbus input of signed integer  (Read 3059 times)

0 Members and 1 Guest are viewing this topic.

Modbus input of signed integer
« on: January 15, 2016, 01:44:54 AM »

I have a VFD (Danfoss FC-102) connected to my Mach3 by ModbusRTU.
After some ostacles on my way (too short communication timeout,  address registers different from the manual), I managed to get it connected and to control start/stop, direction and speed.
Now I wanted to read out the actual speed, but this is coded as a signed interger (if bit 15 is low, bits 0-14 give the positive value, otherwise negative).
The Mach3 Modbus plugin treats the number as a unsigned integer so that a zero is represented by 2^15 (=32768).
I did not find any way to change the readout method. In addition I am missing bitwise logical operations in the formulas in the Mach3 brain.
So my solution was doing it in brain logic.

(You'll recognize that I use a fake input for being able to simulate in the warm office...)

It works, but I wonder if there is a smarter way or a trick for the conversion.