Dear all,
I have simple modbus example below.I am using arduino Uno & RS485 sheild for programming. The code compile & execute successfully. I am facing problem while reading -ve value. it read eqivalent unsigned value. How can save /read signed variable here.
This what i read
65533 for -3
65532 for -4
655535 for -1.
IS any conversion i can to read negative equivalent value. what changes i need to make.
I have simple modbus example below.I am using arduino Uno & RS485 sheild for programming. The code compile & execute successfully. I am facing problem while reading -ve value. it read eqivalent unsigned value. How can save /read signed variable here.
This what i read
65533 for -3
65532 for -4
655535 for -1.
IS any conversion i can to read negative equivalent value. what changes i need to make.
- #include <ModbusRtu.h>
- // data array for modbus network sharing
- uint16_t au16data[16] = {
- 3, -3, -4, 4, 2, 7182, 28182, 8, 0, 0, 0, 0, 0, 0, 1, -1 };
- Modbus slave(1,0,0); // this is slave @1 and RS-232 or USB-FTDI
- void setup() {
- slave.begin( 9600 ); // baud-rate at 19200
- }
- void loop() {
- slave.poll( au16data, 16 );
- }