Hi, I need help with my modbus program, I use W5100 and a arduino uno for this setup.
I'm unable to get reading in the modbus doctor to read the 0 from my arduino.
The following is my code.
#include <ModbusIP.h>
#include <Modbus.h>
#include <Ethernet.h>
#include <SPI.h>
//IPAddress ip(192, 168, 250, 177);
//EthernetServer ethServer(502);
//ModbusTCPServer modbusTCPServer;
int SERVO_HREG ;
const int SERVO_HREG_HR = 0;
ModbusIP mb;
void setup() {
Serial.begin(9600);
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] = { 192, 168, 250, 177 };
mb.config(mac, ip);
mb.addHreg(SERVO_HREG_HR);
}
void loop() {
mb.task();
SERVO_HREG = 123;
mb.Hreg(SERVO_HREG_HR,SERVO_HREG);
Serial.println(SERVO_HREG);
delay(200);
}