HS Banner
Back
Write Multiple Registers Using Modbus

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


Description:

Write multiple registers using the FieldTalk Modbus Master Library.

Article:

private void WriteInputs()
        {
            OpenConnection();

            try
            {
                var Vals = new float[1];
                Vals[0] = Convert.ToSingle(tbWriteInputValue.Text);
                Poll_Result = myProtocol.writeMultipleRegisters(1, 101, Vals);

                if (Poll_Result == BusProtocolErrors.FTALK_SUCCESS)
                {
                    lblResult.Text = "Completed OK";
                }
                else
                {
                    lblResult.Text = "Error was: " + BusProtocolErrors.getBusProtocolErrorText(Poll_Result);
                }

                Vals = null;

                //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.