Differences between revisions 1 and 2
Revision 1 as of 2016-01-10 14:59:48
Size: 487
Comment:
Revision 2 as of 2016-01-10 20:24:17
Size: 3407
Comment: Under construction
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
'''MODBUS''' is a Dyalog namespace that builds the sequence of bytes required for the [[https://en.wikipedia.org/wiki/Modbus|MODBUS]] protocol that is commonly used for connecting industrial electronic devices with computers. Those bytes can be communicated to the industrial device via [[netCOM|Serial Port]], [[netTCP|TCP/IP]], or [[netUDP|UDP/IP]] while using those already made communication classes. '''MODBUS''' is a Dyalog namespace that builds the sequence of bytes required for the [[https://en.wikipedia.org/wiki/Modbus|MODBUS]] protocol using the RTU (Remote Terminal Unit) frame format that is commonly used for connecting industrial electronic devices with computers. Those bytes can be communicated to the industrial device via a [[netCOM|Serial Port]] or a serial device over [[netTCP|TCP/IP]] while using those already made communication Dyalog classes. Modbus devices can be reliably used for home automation, data acquisition and process control. The ''Modicon Modbus Protocol Reference Guide'' is available at this [[http://modbus.org/docs/PI_MBUS_300.pdf|link]].<<BR>><<BR>>
Here is the list of available commands from this namespace:
|| '''Method''' || '''Description''' ||
|| FORCE_COIL_ON || Force ON a Single Coil ||
|| FORCE_COIL_OFF || Force OFF a Single Coil ||
|| READ_REG_FLOAT || Read One FLOAT Register ||
|| READ_BYTE || Read Multiple Registers as Bytes ||
|| PRESET_REG_FLOAT || Write a Float Value to a Register ||
|| PRESET_REG_INT || Write an Integer Value to a Register ||

=== FORCE_COIL_ON Detailed Example ===
If you want to Force the Coil no 1 to ON on the Modbus serial slave device no 17 using the serial port no 2 at 9600 baud, 8 Data Bits, Even Parity and 1 Stop Bit:
{{{
      ⍝ Get a communication object. For serial use COM
      com ← ⎕NEW COM ⍝ Instantiate the class
      com.Open 2 9600 8 2 1 ⍝ Setup the serial communication

      ⍝ Send the Modbus command using the COM object:
      com MODBUS.FORCE_COIL_ON 17 1 ⍝ modbusAddr coilNumber
}}}
If you want to Force the Coil no 1 to ON on the Modbus serial slave device no 17 located at IP address '192.168.1.10' and port 22500 (in this case the baud rate, data bits, parity and stop bit will have to be setup separately according to the IP device):
{{{
      ⍝ Get a communication object. For serial over TCP/IP use TCP
      tcp ← ⎕NEW TCP ⍝ Instantiate the class
      tcp._SwitchingDelay ← 100 ⍝ Adjust according to the speed of the serial device
      tcp.Connect '192.168.1.10' 22500 ⍝ Connect with the serial device
                                         ⍝ Setup the serial communication (particular for each IP device)

      ⍝ Send the command using the TCP object:
      tcp MODBUS.FORCE_COIL_ON 17 1 ⍝ modbusAddr coilNumber
}}}
Internally `FORCE_COIL_ON` will use the `SendReceive` method that is common to the [[netCOM|COM]] and [[netTCP|TCP]] communication object. All the other methods of the namespace '''MODBUS''' are following the same scheme, see the comments of their corresponding individual methods for more information.

== How to install MODBUS in your workspace ==

 1. Download [[attachment:MODBUS.v1.0.txt]]
 1. Do a Select all (Ctrl+A) and a copy (Ctrl+C).
 1. In your workspace execute `)ed ⍟ MODBUS`
 1. Paste (Ctrl+V) the text into the Dyalog editor
 1. Press Escape and ')save' your workspace

== Version Information ==
{{{
     Version 1.0 January 2016, Pierre Gilbert

}}}
||Original author: ||Pierre Gilbert ||
||Responsible: ||PierreGilbert ||
||Email: || <<MailTo(apgil AT SPAMFREE videotron DOT ca)>> ||

----
CategoryDyalog CategoryDyalog

UNDER CONSTRUCTION

MODBUS

Overview

MODBUS is a Dyalog namespace that builds the sequence of bytes required for the MODBUS protocol using the RTU (Remote Terminal Unit) frame format that is commonly used for connecting industrial electronic devices with computers. Those bytes can be communicated to the industrial device via a Serial Port or a serial device over TCP/IP while using those already made communication Dyalog classes. Modbus devices can be reliably used for home automation, data acquisition and process control. The Modicon Modbus Protocol Reference Guide is available at this link.

Here is the list of available commands from this namespace:

Method

Description

FORCE_COIL_ON

Force ON a Single Coil

FORCE_COIL_OFF

Force OFF a Single Coil

READ_REG_FLOAT

Read One FLOAT Register

READ_BYTE

Read Multiple Registers as Bytes

PRESET_REG_FLOAT

Write a Float Value to a Register

PRESET_REG_INT

Write an Integer Value to a Register

FORCE_COIL_ON Detailed Example

If you want to Force the Coil no 1 to ON on the Modbus serial slave device no 17 using the serial port no 2 at 9600 baud, 8 Data Bits, Even Parity and 1 Stop Bit:

      ⍝ Get a communication object. For serial use COM
      com ← ⎕NEW COM                 ⍝ Instantiate the class
      com.Open 2 9600 8 2 1          ⍝ Setup the serial communication

      ⍝ Send the Modbus command using the COM object:
      com MODBUS.FORCE_COIL_ON 17 1  ⍝ modbusAddr coilNumber

If you want to Force the Coil no 1 to ON on the Modbus serial slave device no 17 located at IP address '192.168.1.10' and port 22500 (in this case the baud rate, data bits, parity and stop bit will have to be setup separately according to the IP device):

      ⍝ Get a communication object. For serial over TCP/IP use TCP
      tcp ← ⎕NEW TCP                     ⍝ Instantiate the class
      tcp._SwitchingDelay ← 100          ⍝ Adjust according to the speed of the serial device
      tcp.Connect '192.168.1.10' 22500   ⍝ Connect with the serial device
                                         ⍝ Setup the serial communication (particular for each IP device)

      ⍝ Send the command using the TCP object:
      tcp MODBUS.FORCE_COIL_ON 17 1      ⍝ modbusAddr coilNumber

Internally FORCE_COIL_ON will use the SendReceive method that is common to the COM and TCP communication object. All the other methods of the namespace MODBUS are following the same scheme, see the comments of their corresponding individual methods for more information.

How to install MODBUS in your workspace

  1. Download MODBUS.v1.0.txt

  2. Do a Select all (Ctrl+A) and a copy (Ctrl+C).
  3. In your workspace execute )ed ⍟ MODBUS

  4. Paste (Ctrl+V) the text into the Dyalog editor
  5. Press Escape and ')save' your workspace

Version Information

     Version 1.0 January 2016, Pierre Gilbert

Original author:

Pierre Gilbert

Responsible:

PierreGilbert

Email:

<apgil AT SPAMFREE videotron DOT ca>


CategoryDyalog CategoryDyalog

MODBUS (last edited 2016-01-11 00:39:21 by PierreGilbert)