Files
JIMRI/help/en/html/hardware/modbus/index.shtml
T
2026-06-17 14:00:51 +02:00

183 lines
7.7 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="generator" content="HTML Tidy for HTML5 for Apple macOS version 5.8.0">
<title>JMRI Hardware Support - Modbus</title><!--#include virtual="/help/en/parts/Style.shtml" -->
</head>
<body>
<!--#include virtual="/help/en/parts/Header.shtml" -->
<div id="mBody">
<!--#include virtual="../SidebarUp.shtml" -->
<div id="mainContent">
<img src="https://modbus.org/images/logo_new.jpg" alt="Modbus logo" height="40" width=
"145" class="floatRight">
<h1>Hardware Support: Modbus</h1>
<b>There is no released JMRI support for anything on this page yet.
This was a planned addition that never was ready for release.</b><br/>
If you're interested in ModBus support in JMRI, please
<a href="https://groups.io/g/jmriusers">contact us on the JMRIusers list</a>.
<ul class="snav">
<!-- TOC -->
<li>
<a href="#hardware">Hardware</a>
</li>
<li>
<a href="#limitations">Limitations</a>
</li>
<li>
<a href="#connecting">Connecting</a>
</li>
<li>
<a href="#tools">Tools</a>
</li>
<li>
<a href="#documentation">Documentation</a>
</li>
</ul>
<p><a href="https://modbus.org">Modbus is an industrial control system</a> that's usually
used with pretty tough, highly-engineering equipment. The Modbus nodes are often
"programmable logic controllers" (PLCs) which can do their own calculations of how to control
devices.</p>
<h2 id="hardware">Supported Hardware</h2>
<h3>Modules</h3>
<ul>
<li>Modbus Nodes</li>
</ul>
<p>JMRI provides support for general JMRI <a href="../../tools/Sensors.shtml">Sensors</a> and
<a href="../../tools/Turnouts.shtml">Turnouts</a> via Modbus (Node) connections.</p>
<h2 id="limitations">Limitations</h2>
<p><em>Modbus support is rapidly evolving; the actual code might be ahead or behind the
documentation on any given day. Note that Modbus support is not in any JMRI test or
production releases yet.</em>
</p>
<p>JMRI as Master Node is not supported yet. JMRI will eventually support operation as either
the Master Node, or as one of the Slave Nodes.</p>
<h2 id="connecting">Connecting</h2>
<h3>Software settings</h3>
<p>A Modbus installation has one Master node, and one or more Slave nodes. Generally, the
Master writes to "Coil" objects in the Slave nodes, and reads from "Discrete input" objects
in the Slave nodes. The "Coil" terminology comes from relay coil, solenoid coil, etc.; a way
to change the node's output signals. The "Discrete input" is a single bit from some external
input. By reading and writing these in a Node, a Modbus Master can sense the condition of the
layout (through Discrete inputs) and control it (through Coils).</p>
<h3>JMRI as Master Node</h3>
<p><em>(There is no code support for this yet)</em>
</p>
<p>When JMRI is the Master Node driving a selection of remote Modbus Nodes, the net effect is
very similar to the familiar C/MRI system. There's a Master (JMRI) that communicates with
input (Sensors) and output (Turnouts, Lights) lines in remote Nodes. Each Modbus Discrete
input in a remote Node gets configured as a JMRI Sensor; each Modbus Coil becomes a Turnout
or Light.</p>
<p>JMRI can handle multiple remote Nodes once they've been configured in the JMRI
Preferences.</p>
<p>There are multiple ways to configure this connection: TCP/IP vs RS485, ASCII vs RTU
protocol, etc. Each of these requires separate code.</p>
<h3>JMRI as Slave Node</h3>
It's also possible for JMRI to be a Slave Node. In that case a PLC or other unit is the
Master Node, and reads/writes JMRI when it needs to. At first, this will probably seem odd;
JMRI is usually used as the central control for the layout. But note that Modbus is an
industrial-strength system, and JMRI is not. If you want <em>really</em> robust railroad
controls, you can built it using PLCs communicating with each other for operation, and only
communicating with JMRI to display status on a Panel, get operator input, etc.<br>
In that case, it's quite natural for JMRI to appear as a slave node on the Modbus.
<p>When configured as a Slave, JMRI appears as Coils and Discrete inputs to the Modbus
Master. Modbus:</p>
<ul>
<li>allows the Master to read and write Coils in the Slave, but can only read Discrete
inputs; it can't write to Discrete inputs in a Slave.</li>
<li>some popular PLC environments can only write to Coils and read from Discrete
inputs.</li>
</ul>
<p>The Master Node can read from either the Coil or Discrete input for either Turnout or
Sensor (see <a href="#naming">Naming</a> below). It can write to the Coil number to change
the status of the Turnout or Sensor within JMRI. A "1" is THROWN or ACTIVE, respectively; a
"0" is CLOSED or INACTIVE.</p>
<p>Until each Coil is first written or set within JMRI, the state of the associated Turnout
or Sensor will be "UNKNOWN" and it will be read back as "zero" on Modbus.</p>
<p>With this convention, you can put Turnouts and Sensors on your JMRI Panel, and then
connect them to PLC code that will tell them what to display. If desired, local changes, e.g.
clicking on the screen, can be read back and used to control the railroad.</p>
<h4>Configuring as a Slave Node</h4>
In the Preferences pane for Connections, select "Modbus" as the System manufacturer and
"RS485 ASCII Slave" as the System Connection. Under Settings, select the communications
(serial) port your interface is connected on, the baud rate, and enter the node number your
Modbus Master Node will use to refer to JMRI. Click "Save", quit and restart.
<p>Next, use the Turnout Table and Sensor Table to define Turnouts and Sensors, which will in
the process define the Coils and Discrete inputs that Modbus will read and write. Save this
configuration to a Panel file so that it can be reloaded when you start JMRI again later.
<h3 id="naming">Naming</h3>
<p>The default <a href="../../../html/doc/Technical/Names.shtml">system letter</a> for Modbus
connections is "M". It can be configured to another letter if desired.</p>
<p>Normally, JMRI provides an interface to the real layout via internal objects such as
Turnouts and Sensors that are closely mapped to corresponding physical devices. This mapping
is done via "System Names", which both identify the how to access a particular device, and
are the key to looking up the corresponding object in JMRI. Here, we have to pick a naming
convention that allows those inside-JMRI work with the properties of Modbus.</p>
<p>We therefore provide the following mapping:</p>
<dl>
<dt>JMRI Turnout MTnnn, e.g. MT123</dt>
<dd>This will appear as Modbus coil nnn and discrete input nnn, e.g. coil 123 and discrete
input 123</dd>
<dt>JMRI Sensor MSnnn, e.g. MS123</dt>
<dd>This will appear as Modbus coil nnn+1000 and discrete input nnn+1000, e.g. coil 1123
and discrete input 1123</dd>
</dl>
<h2 id="tools">JMRI Tools</h2>
N/A
<h2 id="documentation">Documentation</h2>
<h3>Third Party info</h3>
<p><a href="https://modbus.org">Modbus website</a>
</p>
<!--#include virtual="/help/en/parts/Footer.shtml" -->
</div>
<!-- closes #mainContent-->
</div>
<!-- closes #mBody-->
<script src="/js/help.js"></script>
</body>
</html>