From Technologic Systems Manuals
Jump to: navigation, search
TS-1400
TS-1400.jpg
Released March 2013
Product Page
Documentation
FTP Path
Relays
External Interfaces
2x RJ45 Modbus
Power Requirements
24V
Operates between 0.435W-9.75W
Operating Temperature
Cold -40C
Hot 85C
Mechanical
164mm x 112mm
Height 58mm (with relays)
Weight 467g

Contents

1 Overview

The TS-1400 is a modbus peripheral device which features 6x 24VDC 30A relays.

2 Getting Started

2.1 Using TS-ARM Products

Our TS-ARM products use Debian Linux which can use Modbus to communicate with the TS-1400. We have created a patch to libmodbus to allow guaranteed timing which is available here. For ARMEL(EABI) compatible systems we have debian package here.

To install this on a board, connect it to the internet and run these commands:

wget ftp://ftp.embeddedarm.com/ts-modbus/libmodbus_3.0.3-1_armel.deb
dpkg -i libmodbus_3.0.3-1_armel.deb

This package includes both the library and the supporting headers needed for building libmodbus compatible examples. For other platforms other than OABI ARM you can use the sources provided by the libmodbus project.

3 Example Code

This code uses the patched libmodbus for xuart support communicating at 9600, 8n1, and with the default modbus address 247:

// TS-1400 Coil-toggle example.
// Written by Michael D Peters for Technologic Systems, Inc.
// Copyright March 22, 2013
//
// This code assumes six relays on a TS-1400 that is configured
// in legacy mode, 9600 baud, 8, N, 1, Device address 0xAC.
//
// This code assumes the use of the Technologic Systems XUART
// controller, xuartctl, and the appropriately modified version
// of Libmodbus.  Patch files available near here:
// http://forum.embeddedarm.com/
//
// These settings are modifiable in the #define block below.
//
// This program demonstrates both methods of setting coils on
// the TS-1400.
// First by setting coils using the holding register address.
// Second by setting individual coils using the write coil command.
 
#include <stdio.h>
#include <stdlib.h>
#include <modbus.h>
#include <errno.h>
 
#define DEVICE_ID 0xf7
#define SPEED 9600
#define PORT "127.0.0.1:7350"
#define RELAY_REGISTER 0x40
 
modbus_t *mb;
 
int main(int argc, char* argv[])
{
	int c = 0;
 
	// modbus setup
	mb = modbus_new_rtu(PORT, SPEED, 'N', 8, 1);
	if(!mb){
		fprintf(stderr, "Unable to open bus at port %s.\n", PORT);
		return 0;
	}
 
	modbus_set_debug(mb, (argc > 1));
	modbus_set_slave(mb, DEVICE_ID);
	modbus_connect(mb);
 
	// Demo functions
	printf("Ticking relay pattern...\n");
	c = set_multiple_relays();
	if(c == -1){
		return 0; // error output by function.
	}
 
	printf("Ticking individual relays...\n");
	c= set_single_relay();
	if(c == -1){
		return 0; // error output by function.
	}
 
	return 0;
}
 
// throws relays in a 24 position countup -- that's 64 iterations.
// returns -1 and prints stderr if there was a problem, 
// returns 1 if no trouble was detected.
int set_multiple_relays()
{
	uint16_t c = 0;
	int d = 0;
	for(c = 0; c < 64; c++){
		d = modbus_write_register(mb, RELAY_REGISTER, c);
		usleep(100000);
		if(d == -1){
			fprintf(stderr, "Problem with write.  Error %d: %s", 
				errno, modbus_strerror(errno));
			return -1;
		}
	}
	return 1;
}
 
// Throws relays individually using the write relay modbus command.
// Throws each relay on and then off in sequence.
// Returns -1 if error condition and writes an error to stderr.  Returns 1 otherwise.
int set_single_relay()
{
	int c = 0;
	int d = 0;
	d = modbus_write_register(mb, RELAY_REGISTER, 0);
	while(c<6){
		d = modbus_write_bit(mb, c, 0xffff);
		usleep(1000000);
		d = modbus_write_bit(mb, c++, 0x0);
		if(d == -1){
			fprintf(stderr, "Problem with write.  Error %d:  %s", 
				errno, modbus_strerror(errno));
			return d;
		}
	}
	return 1;
}

To compile and run this as test.c:

gcc `pkg-config --libs --cflags libmodbus` test.c -o test
./test

4 Power Requirements

The TS-1400 requires 0.435W under normal operation, and approximately 1.6W for each active relay.

5 Features

5.1 TS Modbus Support

When using all Technologic Systems Modbus devices we include functionality to create an arbitrary chain of stock peripherals to automatically enumerate all connected devices, configure them, and generate an I/O map of all connected devices.

5.1.1 TS Modbus Autoconfiguration

The autoconfiguration works by using the optional mode pin on the RJ45 connector as designated in the MODBUS-2W standard. Technologic Systems uses this to indicate if it is a TS device. If it is asserted (low) to a TS device, then it will allow access to the #Holding Registers at address 0xf7.

This will identify the TS Modbus device model, set the first device in the chain to the user specified slave address (default is 0x10), and assert the mode line to the next port to enumerate the next device. The next device address is incremented by 1, and the process is repeated until no slave responds to a read query (timeout)indicats that no additional devices are connected to the bus chain. At this point the last device in the chain is configured to enable bus termination on the RS485 link, and all devices have their bit rates set to the user selected bit rate (default is 9600).

6 Register Interface

6.1 Holding Registers

The interface to all Modbus peripheral devices consists of a set of 127 holding registers. These registers are used to configure the device operation, read and write input output parameters, as well as various settings used to configurable Modbus Address, Termination enable, Data Format, and Bit Rate. These settings are common to all of our Modbus peripherals and can be persisted in on-board flash memory.

NOTE: The device operates ONLY in Modbus RTU communications mode. Modbus ASCII is not presently supported.

Address (hex) Address (dec) Access Description Example Values
0x70 112 Read/Write Modbus Mode 0 = ASCII (unimplemented), 1 = RTU
0x71 113 Read/Write RS485 Bus Termination Enable 0 = Termination disabled, 1 = Termination enabled
0x72 114 Read/Write Modbus Device Address 0-247 (0x00-0xf7) 0 = Broadcast
0x73 115 Read/Write Modbus bit rate Bit Rate
0x74 116 Read Only Unit Model e.g., 0x1400, 0x1700, 0x1800, etc
0x75 117 Read Only Verilog Version e.g., 1
0x76 118 Read Only ZPU Version e.g., 1
0x77 119 Read Only Bus power Supply in millivolts e.g., 23600
0x78 120 Read Only Internal Temperature in 1/100th degree Celsius e.g., 290
0x79 121 Read/Write Reserved or model specific Not applicable or model specific
0x7a 122 Read/Write Reserved or model specific Not applicable or model specific
0x7b 123 Read/Write Reserved or model specific Not applicable or model specific
0x7c 124 Read/Write Reserved or model specific Not applicable or model specific
0x7d 125 Read/Write Write listed value to persist communications (Bit rate, Data format, Address, and Termination) parameters to internal nonvolatile storage: 0xFEED = Persist configuration, 0xDEAD = Erase configuration, 0xC0DE apply configuration without persistence. In all cases the value is set to zero when completed or 0xFA17 (FAIL) if error.
0x7e 126 Read/Write Reserved or model specific Not applicable or model specific

NOTE: All Read Only registers may be written; however, writing to certain registers (e.g., Unit Model) will overwrite the information that will not be refreshed until the unit is reset.

6.1.1 Baud Rate

The TS-1400 supports 15 speeds:

Value Communication Bit Rate Maximum CAT5 Cable Length
0 300 1200 meters
1 600 1200 meters
2 1200 1200 meters
3 2400 1200 meters
4 4800 1200 meters
5 9600 1200 meters
6 19.2K 1200 meters
7 38.4K 1200 meters
8 57.6K 1200 meters
9 115.2K 800 meters
10 230.4K [1] 400 meters
11 460.8K [1] 200 meters
12 1040K [1] 100 meters
13 2080K [1] 40 meters
14 4160K [1] 20 meters
  1. 1.0 1.1 1.2 1.3 1.4 On Linux systems, stting these bit rates requires code using ioctl() with the TCGETS2 and TCSETS2 parameters.

6.2 Operating Registers

Coil addresses correspond to the appropriate relay (coil 0 == CN1). Holding Register 0x40 is read/write and always reflects the current status of each coil in the first six bits: Holding Register 0x40 bit 0:5 == Coil Register 0... 5 == Physical Relay 1... 6.

Address (hex) Address (dec) Access Description
COIL 0x0 0 Read/Write Relay 0 (1 NO, 0 NC)
COIL 0x1 1 Read/Write Relay 1 (1 NO, 0 NC)
COIL 0x2 2 Read/Write Relay 2 (1 NO, 0 NC)
COIL 0x3 3 Read/Write Relay 3 (1 NO, 0 NC)
COIL 0x4 4 Read/Write Relay 4 (1 NO, 0 NC)
COIL 0x5 5 Read/Write Relay 5 (1 NO, 0 NC)
COIL 0x6 6 Read/Write Relay 6 (1 NO, 0 NC)
HOLDING 0x40 64 Read/Write Bits 0:5 correspond with Relay 1-6

7 Connectors

7.1 2x RJ45

Both RJ45 ports, and all of our Modbus based devices are designed to be compatible with 2W-MODBUS RJ45 following this pinout:

ModbusRJ45.png
TS-1400 RJ45.png

8 Product Notes

8.1 Modbus Linux Utility Programs

Modbus Linux register access program: mbpeekpoke

root@ts4700:/home/zpu# ./mbpeekpoke -?

Usage: mbpeekpoke -switch parameter [OPTIOSN] ...
Download and start a ZPU program.  Optionally persist the code
Default parameter values in [brackets]
  -?                     This help screen
  -b  bit_rate           Bit rate [9600]
                         300, 600, 1200, 2400, 4800, 9600, 19200
                         38400, 57600, 115200, 1000000, 4000000
  -c  connection         IP:Port IP address:port [127.0.0.1:7350]
                         Serial port [/dev/ttySP2]
  -D                     Device to access: [C]oil, [R]egister, [I]nput, [P]acket
  -d                     Display packet debugging information [Off]
  -f                     Register display output format:
                         'X' hex, 'S' signed decimal 'U' unsigned decimal [Hex]
  -h                     This help screen
  -n  number_of_items    number of items to read [1]
  -m  Board model #      7670 with serial [any other using TCP socket connection]
  -r  address            Read: Device @ specified address
  -s  slave_address      hexadecimal 00-f8; 00 is broadcast [0xf7]
  -v  data               value to write
  -V                     Verbose mode - display additional debug information
  -w  address            Write: Device @ specified address
 The (-w) write option requires a single (-v) variable
 The (-r) read option can read a number of items with the (-n) switch
 Both the -w & -r options may be used on the same or different addresses
 however, they must both use the same device (-D) and the write is performed first

Modbus Linux register access program for TS-7670: mbpeekpoke7670

root@ts4700:/home/zpu# ./mbpeekpoke7670 -?

Usage: mbpeekpoke7670 -switch parameter [OPTIOSN] ...
Default parameter values in [brackets]
  -?                     This help screen
  -b  bit_rate           Bit rate [9600]
                         300, 600, 1200, 2400, 4800, 9600, 19200
                         38400, 57600, 115200, 1000000, 4000000
  -h                     This help screen
  -n  number_of_items    number of items to read [1]
  -r  address            Read: Register @ specified hex address
  -s  slave_address      hexadecimal 00-f7; 00 is broadcast [0xf7]
  -u                     Use USB connection
  -v  data               value to write
  -w  address            Write: Register @ specified address
 The (-w) write option requires a single (-v) variable
 The (-r) read option can read a number of items with the (-n) switch


These programs are used to perform accesses to the Modbus devices register set. It allows the writing of arbitrary hex data to any hex register address one at a time and the reading of blocks of arbitrary data from any hex register addres displayed in hex, signed, or unsigned decimal.


Modbus Linux device configuration program: mb_config

root@ts4700:/home/zpu# ./mb_config -?

Usage: mb_config -switch paramater [OPTIOSN] ...
Configure a Modbus device for legacy mode by setting operational parameters
Default parameter values in [brackets]
  -?                     This help screen
  -b  bit_rate           Bit rate [9600]
                         300, 600, 1200, 2400, 4800, 9600, 19200
                         38400, 57600, 115200, 230400, 460800
                         1040000, 2080000, 4160000
  -C  Configuration      Model 1700: 8 character field starting @ DIO bit 7 thru 0
                         Use single letters 'T' Temperature; 'I' Input: 'O' Output
                         All Other model: Not required
  -c  connection IP:Port IP address:port [127.0.0.1:7350]
  -d                     Display packet debugging information [Off]
  -f  format (data)      Data format: 8N1, 8N2, 8E1, 8O1, [8N1]
  -h                     This help screen
  -i                     Display I/O accesses
  -I                     Inhibit actual writing
  -m  Board model #      7670 with serial [any other using TCP socket connection]
  -n                     Noninteractive mode [off]
  -p                     Display progress messages [Off]
  -s  slave_address      hexadecimal 00-f6; 00 is broadcast [0x10]
  -t  termination        Terminstion on / off [off]
  -v                     verboce output mode
  DIO Configration for Model TS-1700
root@ts4700:/home/zpu#

This program is used to perform configuration of a Modbus device. On older modbuc devices these settings (Slave address, Communications bit rate and data format, termination) would have been performed via DIP switches. This configuration information is stored in non-volatile memory on the device.


The primary difference in usage of these utilities depends on the hosting platform.

On SBC products using the XUART communications devices, the -c switch and parameter does not need to be specified, since the default communications port is correct.

On the TS-7670 with a standard UART communications device, the '-m 7670' switch should be specified. This allows the proper hardware setting for the RS-485 port to be utilized.

On SBC products with a host USB port for communications, the -c switch should be specified and paramater should be the USB to Serial communication device, which is generally '/dev/ttyACM0'. The '-s f6' switch and parameter is required since the unit operates at a different slave address when operating via USB. The bit rate does not need to be specified, since the USB port will operate at the fastest rate possible (up to approximately 1000000 bps).

8.2 Modbus Windows Utility Programs

Modbus Windows register access program: ModbusDeviceAccess


TsModbusAccess.PNG


These programs are used to perform accesses to the Modbus devices register set. It allows the writing of arbitrary hex data to any hex register address one at a time and the reading of blocks of arbitrary data from any hex register addres displayed in hex, signed, or unsigned decimal.

  • Use of this utility requires the following steps:
    • 1. Select the COM port from the drop down box
    • 2. Select the bit rate from the drop down box
    • 3. Select the correct data format (8N1 is default)
    • 4. Enter the connected device slave address after selecting the format (Hex or Decimal)
    • NOTICE:The coil functionality is currently not functional in Windows
    • 5. Select the resource type (Regoster, Input, or Coil)
    • 6a. Set the resoucw index (e.g., Register number) and count for reading
    • 6b. Set the resoucw index (e.g., Register number) and value for writing
    • 7. Click the appropriate button to read or write the device


Modbus Windows device configuration program: ModbusDeviceConfigure

TsModbusConfigure.PNG

This program is used to perform configuration of a Technologic Systems Modbus device. On older Modbuc devices these settings (Slave address, Communications bit rate and data format, termination) would have been performed via DIP switches. This configuration information is stored in non-volatile memory on the device. This utility is designed to operate on devices confired as factory degault, 9600, N81, address 0cf7. Windows USB connections are not currently supported, so the devie should be connected via a TS-142 ISB to Serial Modbus adapter is required.

  • Use of this utility requires the following steps:
    • 1. Select the COM port from the drop down box
    • NOTICE:The USB functionality is currently not operational on Windows
    • 2. Select the COM port type (USB or Serial)
    • 3. Click Identify
    • The model willl appear at the top of the page
    • 4. Select the Data Format, Slave Address, Bit Rate, and Termination
    • 5. Click Configure

9 FCC Advisory

This equipment generates, uses, and can radiate radio frequency energy and if not installed and used properly (that is, in strict accordance with the manufacturer's instructions), may cause interference to radio and television reception. It has been type tested and found to comply with the limits for a Class A digital device in accordance with the specifications in Part 15 of FCC Rules, which are designed to provide reasonable protection against such interference when operated in a commercial environment. Operation of this equipment in a residential area is likely to cause interference, in which case the owner will be required to correct the interference at his own expense.

If this equipment does cause interference, which can be determined by turning the unit on and off, the user is encouraged to try the following measures to correct the interference:

Reorient the receiving antenna. Relocate the unit with respect to the receiver. Plug the unit into a different outlet so that the unit and receiver are on different branch circuits. Ensure that mounting screws and connector attachment screws are tightly secured. Ensure that good quality, shielded, and grounded cables are used for all data communications. If necessary, the user should consult the dealer or an experienced radio/television technician for additional suggestions. The following booklets prepared by the Federal Communications Commission (FCC) may also prove helpful:

How to Identify and Resolve Radio-TV Interference Problems (Stock No. 004-000-000345-4) Interface Handbook (Stock No. 004-000-004505-7) These booklets may be purchased from the Superintendent of Documents, U.S. Government Printing Office, Washington, DC 20402.

9.1 Limited Warranty

Technologic Systems warrants this product to be free of defects in material and workmanship for a period of one year from date of purchase. During this warranty period Technologic Systems will repair or replace the defective unit in accordance with the following process:

A copy of the original invoice must be included when returning the defective unit to Technologic Systems, Inc. This limited warranty does not cover damages resulting from lightning or other power surges, misuse, abuse, abnormal conditions of operation, or attempts to alter or modify the function of the product.

This warranty is limited to the repair or replacement of the defective unit. In no event shall Technologic Systems be liable or responsible for any loss or damages, including but not limited to any lost profits, incidental or consequential damages, loss of business, or anticipatory profits arising from the use or inability to use this product.

Repairs made after the expiration of the warranty period are subject to a repair charge and the cost of return shipping. Please, contact Technologic Systems to arrange for any repair service and to obtain repair charge information.