I need to send a 16 bit volatile control word to a drive over modbus tcp.
I am struggling to get the code right and would appreciate some help please....
I am testing the modbus output by sending a value from the arduino to my pc which is running modbus slave software but I am getting the wrong value back.
uint16_t myValue = 49152; // Example 16-bit value
// Split the 16-bit value into two 8-bit values
byte highByte = (myValue >> 8) & 0xFF;
byte lowByte = myValue & 0xFF;
if (!modbusTCPClient.holdingRegisterWrite(0x00,(1, highByte)) || (0x00,(1, lowByte))) {
Serial.print("Failed to write coil! ");
Serial.println(modbusTCPClient.lastError());
}

