Hi swat cat,
Isn't it slave ID 2 not 0?
Try these changes to ModbusMasterVer1.c:
Change the baud rate:
Code:
EnableRS232Cmds(RS232_BAUD_19200);
Change to do only 1 Write of 1 register to the PLC on both initial connection and monitor loop - Device=2 Address=0000 Length=0001
Code:
ModbusMaster_Cmds ModbusMaster_ConnectList[] =
{
// string is "dev,cmd,adrhi,adrlo,lenhi,lenlo" bytes of modbus command. bytelen, data, and checksum are added.
{"\x02\x10\x00\x00\x00\x01", 6, 0}, // Write outputs from MBRegisters[0]
{0,0,0} // end flag
};
ModbusMaster_Cmds ModbusMaster_MonitorList[] =
{
// string is "dev,cmd,adrhi,adrlo,lenhi,lenlo" bytes of modbus command. bytelen, data, and checksum are added as necessary.
{"\x02\x10\x00\x00\x00\x01", 6, 0}, // Write outputs from MBRegisters[0]
{0,0,0} // end flag
};
As a test just put a fixed value in the ModBus register to be sent
Code:
// marshal and move values read from PLC/Slave into MBRegisters to KFlop memory
void ModbusMaster_RegUnload()
{
// nothing to read
}
// marshal and move values to be sent to PLC/Slave into MBRegisters
void ModbusMaster_RegLoad()
{
// put RPM into a Output Register
MBRegisters[0] = 1000; // Set fixed integer RPM value as a test
}