Author: Admin 06/12/2021
Language:
C#
Tags:
Write coils using the FieldTalk Modbus Master Library.
private void WriteCoil()
{
OpenConnection();
try
{
bool CoilTrueFalse = Convert.ToBoolean(1);
Poll_Result = myProtocol.writeCoil(1, 1, CoilTrueFalse);
if (Poll_Result == BusProtocolErrors.FTALK_SUCCESS)
{
lblResult.Text = "Completed OK";
}
else
{
lblResult.Text = "Error was: " + BusProtocolErrors.getBusProtocolErrorText(Poll_Result);
}
GetCounters();
//Close connection
if (myProtocol.isOpen())
myProtocol.closeProtocol();
myProtocol = null;
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
Read More: https://www.modbusdriver.com/doc/mbusmaster.net/index.htm