HS Banner
Back
Write Coils Using Modbus

Author: Admin 06/12/2021
Language: C#
Tags:


Description:

Write coils using the FieldTalk Modbus Master Library.

Article:

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


Back
Comments
Add Comment
There are no comments yet.