JMP Protocol
EXTERNAL DEVICES
There are a number of external modules that can be used with JNIOR. These
attach to the Sensor Port and can be daisy-chained. The most popular of these
is the Power 4ROUT modules adding an additional 4 relay outputs to the JNIOR
I/O set. Up to two 4ROUT modules can be used which will logically extend the
number of relay outputs reported in the "Monitor" message. But additional
4ROUT and other modules can be used limited only by the power load on the
sensor port/network. Modules are read and written using their ID string as
an address.
Each interaction with an external module involves the exchange of a Data Block.
The data blocks will differ depending on whether a device is being read or
written. These blocks define a structure of fields. The definitions for the
device blocks are provided as part of the JNIOR Protocol Specification.
ENUMERATE DEVICES REQUEST
Each external module has a unique ID. This is a 16 character hexadecimal
string representing 8 bytes. The least significant byte or rightmost 2
characters always specify the type of module. This would be 'FB' for a
standard 4ROUT external module. The 5 bytes or 10 characters immediately
preceding the type can be considered a Serial Number of sorts. Typically
these are constrained to the digits 0 through 9. The first byte or 2
characters is a check byte and the byte following a software code (typically
but not always a '11').
The "Enumerate Devices" command is used to retrieve a list of the active
modules connected to the JNIOR. This solicits an "Enumerate Devices Response"
which includes a "Devices" list of 0 or more module IDs. Note that the "Meta"
member can be included in the request and will be returned unmodified in the
response. This can be used to pass information to the routine that will
process the response. For example we have this exchange.
TRANSMITTED RECEIVED
{
"Message":"Enumerate Devices"
}
{
"Message":"Enumerate Devices Response",
"Devices":[
"CD111090708109FB",
"16111100125011FE"
]
}
This tells us that the JNIOR has two connected modules. One is type 0xFB
which is a 4ROUT module. The other a type 0xFE which is the Analog 4-20 ma
module. The device types are described in the JNIOR Protocol Specification
document.
READ DEVICES REQUEST
The "Read Devices" command is used to obtain the current data block from one
or more devices. The format of the data block is specific to the device type.
This solicits the "Read Devices Response" which includes only those devices
successfully read and the data block content encoded in a "Hex" string. Here
we read both of the devices reported in the previous enumeration.
TRANSMITTED RECEIVED
{
"Message":"Read Devices",
"Devices":[
"CD111090708109FB",
"16111100125011FE"
]
}
{
"Message":"Read Devices Response",
"Devices":[
{
"Address":"CD111090708109FB",
"Hex":"0F000000000000000000"
},
{
"Address":"16111100125011FE",
"Hex":"000000000000000000000000"
}
]
}
The content of these blocks can be interpreted using the formats defined in
the JNIOR Protocol Specification document. From this response we can see that
all of the relays on the 4ROUT device are open and not activated. The 4-20
module is connected but since in this instance it is not wired to any current
loop devices it reports all inputs at 4 ma (0x0000) and its two outputs are
set to 4 ma (0x0000).
WRITE DEVICES REQUEST
The "Write Devices" command is used to write to an external module. Here we
pass a properly formatted data block to the 4ROUT module reported in the prior
example. The goal is to close the 3rd relay (Relay Output C). This is achieved
by setting the mask (first byte) to 0x04 informing the module that we will
only be setting the state of the 3rd relay. We define the state (second byte)
as 0x04 to close that relay. The command solicits the "Write Devices Response"
which returns the result of each write attempt. The "Result" member will be
'true' if the write is successful and 'false' otherwise.
TRANSMITTED RECEIVED
{
"Message":"Write Devices",
"Devices":[
{
"Address":"CD111090708109FB",
"Hex":"04040000000000000000"
}
]
}
{
"Message":"Write Devices Response",
"Devices":[
{
"Address":"CD111090708109FB",
"Result":true
}
]
}
Note that the relays in the 4ROUT module can be pulsed. Here we simply turned
Relay C on. The value for its pulse duration being 0x0000 in the block.
EXPANSION MODULES
The following module types are typically used with JNIOR. The type is
represented in hexadecimal. This appears as the last two characters in a
module's ID string.
Type 10 -- Temperature Probe
Type 26 -- Temperature Probe
Type 7E -- Temperature/Humidity Sensor
Type F8 -- 8DIN Digital Input Expansion Module
Type F9 -- 3-Channel LED Dimmer
Type FA -- Rack Mounted User Panel
Type FB -- 4ROUT Quad Relay Output Module
Type FC -- RTD Temperature Module
Type FD -- 10V Analog Module
Type FE -- 4-20ma Analog Module
READ DATA BLOCK
---------------
The read and write data blocks appropriate for each module are defined in the
JNIOR Protocol Specification. The data blocks for the 4ROUT Quad Relay Output
module are represented here as an example of translation between the binary
descriptions and that required for this protocol.
4ROUT Read Data Block
"Hex":"00000000000000000000"
| | | | | |
| | | | | 0000 Relay D Pulse Time Remaining
| | | | | (0 to FFFF hexadecimal milliseconds)
| | | | 0000 Relay C Pulse Time Remaining
| | | | (0 to FFFF hexadecimal milliseconds)
| | | 0000 Relay B Pulse Time Remaining
| | | (0 to FFFF hexadecimal milliseconds)
| | 0000 Relay A Pulse Time Remaining
| | (0 to FFFF hexadecimal milliseconds)
| 00 Bit mapped relay status (0-open 1-closed)
00 Bit mapped last relay mask used (1-selected)
Bit mappings (mask and status)
+-------+-------+-------+-------+-------+-------+-------+-------+
| 0 | 0 | 0 | 0 | Rly D | Rly C | Rly B | Rly A |
+-------+-------+-------+-------+-------+-------+-------+-------+
Of most importance here are the last 4 bits of the second byte. This is
basically the 4th character of the "Hex" string encoding which relays are
closed and which are open. '0' indicating that all of OFF. 'F' indicating
all are ON.
WRITE DATA BLOCK
----------------
4ROUT Write Data Block
"Hex":"00000000000000000000"
| | | | | |
| | | | | 0000 Relay D Pulse Time
| | | | | (0 to FFFF hexadecimal milliseconds)
| | | | 0000 Relay C Pulse Time
| | | | (0 to FFFF hexadecimal milliseconds)
| | | 0000 Relay B Pulse Time
| | | (0 to FFFF hexadecimal milliseconds)
| | 0000 Relay A Pulse Time (0 to FFFF hexadecimal milliseconds)
| 00 Bit mapped relay state (0-open 1-closed)
00 Bit mapped relay selection mask (1-selected)
Bit mappings (mask and state)
+-------+-------+-------+-------+-------+-------+-------+-------+
| 0 | 0 | 0 | 0 | Rly D | Rly C | Rly B | Rly A |
+-------+-------+-------+-------+-------+-------+-------+-------+
The state of the relays corresponding to the '1' bits in the 'mask' are changed
to the desired 'state'. For a permanent/static change the corresponding Pulse
Time must be 0000. To pulse Relay A ON for 5 seconds the Pulse Time field
would be set to 5000 milliseconds which is represented as 1388 hexadecimal.
The "Hex" string for this command would be "01010000000000001388". Note that
the mask indicates the target relay. The state indicates the desired change
and the length of the pulse in milliseconds is defined.
[/flash/manpages/protocol.hlp:1477]