Modbus Relay Modules

Prodigy USB Modbus Relay Modules With Analog and Digital Inputs (DIN Rail Compatible)

0 views March 20, 2018 admin 0

Introduction

Numato Lab’s 8/16 Channel DIN Rail compatible Modbus USB Relay Module with Digital IO and Analog Inputs offers great flexibility at lower cost.  Ease of use and wider operating system compatibility are the primary goals behind this product’s design. Built in USB to serial conversion allows the module to be used without any USB specific knowledge. Industry standard Modbus protocol support allows this product to be used with most automation software that supports Modbus. For power users, this module can be controlled by writing programs in various programming languages of their choice. A complete list of Modbus Relay Modules available from Numato Lab can be found here.

Features:

  • Industry standard Modbus protocol support
  • DIN Rail compatible
  • 8/16 Mechanical Relay with contact rating up to 250V/5A each
  • 8 TTL (3.3V) compatible Digital IOs
  • 8 analog inputs with 12-bit resolution (multiplexed with Digital IOs)
  • USB interface with CDC support. As easy as using a serial port, no USB knowledge required
  • Fully isolated design with opto-couplers and built in DC – DC converter
  • Relay contacts available on easy to access screw terminals
  • 12V external power supply (included)
  • Can be controlled by using industry standard automation applications or custom applications

Some of the possible uses of this module include

  • Home Automation
  • Lighting Control
  • Garden Equipment Control
  • Industrial Automation
  • Test Fixtures
  • DIY and Hobby

This product is compatible with the following operating systems:

  • Windows XP and later versions (Windows 7, 8/8.1, 10 and future versions)
  • Windows 7 Embedded and later
  • Linux
  • Mac OS X
  • Android
  • Or any other operating system that supports USB CDC devices.

And these are some of the languages that can be used for programming:

  • C/C++
  • Visual Basic (VB6, VB2008, VB2010 express and other editions)
  • Visual Basic for Applications (Microsoft Office VBA)
  • Perl
  • Python
  • JAVA
  • Android
  • Javascript (Node.js)
  • Labview
  • And many more…

This product has 8/16 on board relays and associated drivers capable of controlling variety of devices including lamps, motors, locks etc… (Please see recommendations for using this product with inductive loads elsewhere in this document). This module also includes General Purpose I/Os, and analog inputs (multiplexed with GPIOs) that can be accessed over USB interface for extended functionality. The module communicates with host PC over full speed USB link. When connected to PC, the module will appear as a serial port in Windows Device Manager (or a serial tty device in Linux and Mac).

How to Use Prodigy Relay Modules

Using this product is very easy,  thanks to support for industry standard Modbus protocol and the USB CDC interface that  allows the device to be used with most off the shelf Automation/SCADA software that supports Modbus.

  • Windows
    • QModMaster
    • Radzio! Modbus Master Simulator
  • Linux
    • Coming soon
  • Mac OS X

    • Coming soon

Using this product involves the following simple steps.

  1. Connect the Modbus Relay Module to a USB port on the host system
  2. Install driver if applicable
  3. Open the COM port corresponding to the device using a software that supports Modbus
  4. Read/Write Coils and Registers
  5. Optionally write a script or custom application to automate your task

All aspects of the above steps are covered in the following sections including step by step demonstration.

Components/Tools Required

Along with your Prodigy UR Modbus Relay Module, you will need the items in the list below for easy and fast installation.
1. USB A to B cable (Included).
2. 12V Power Supply (Included).
3. Medium size Philips screw driver.

Connection Details

IMPORTANT! Please exercise utmost caution while working with electrical mains or other high voltages. Failure to comply with safety regulations may result in injury and or death.

The picture above shows basic connection diagram that can be used in most of the situations. The connection diagram is same for both AC and DC loads. Please make sure to use a freewheeling diode or snubber circuit if the load is inductive. More details about using inductive loads is available elsewhere in this document. Use a USB A to B cable to connect the unit to a PC. It is important to make sure that the wires used to connect loads are sufficiently rated to handle expected load current. Exercise caution while working with high voltages. Short circuits can cause damage to the module and the PC. The following sections identify individual connections in detail.

USB Interface

The on board full speed USB controller helps a PC/Linux/computer to communicate and control this module seamlessly. Use a USB A to B cable (Included) to connect the unit to a PC. The device can be connected directly to the host PC or connected through a compatible USB hub. For high-performance system integration, it is recommended to connect the device directly to one of the root ports.

Relay Contacts

Prodigy UR devices has 8/16 mechanical relays that can switch up to 5A of current. Normally Open (NC) and Common (C) contacts on the relays are available externally on screw terminals for easy user access. The relays are rated for AC and DC supply voltages. Please see the electrical parameter table for more details. Each relay has two contacts(C, NO. The contacts NO and C will be connected when the relay is turned ON and will be disconnected when relay is turned OFF.  Table below summarizes possible relay contact positions.

Relay State Connection between IN and OUT
OFFOpen
ON Close

GPIO/Analog Inputs

In addition to the onboard relays, this Prodigy UR devices has 8 General Purpose IO pins that can be used for various custom applications. These pins can be used as Analog to Digital Converter inputs as well. All IO pins support 3.3V TTL signals and the ADC input range is 0 to +3.3V. The ADC can acquire analog signal at the resolution of 12 bits per sample. It is recommended to use a series resistor with the GPIO/ADC pins when interfacing with other circuits. In output mode, GPIOs can source up to 20mA. So no additional circuitry is needed to drive regular LEDs. A 470 Ohms series resistor is recommended for current limiting when connecting LED to a GPIO.

In contrast to GPIOs, Analog inputs can read voltages at any level between 0 to 3.3V. It is recommended to use a series resistor to protect the input from stray voltages and spikes. The internal Analog to Digital converter supports 12 bits resolution which is adequate for most applications. The table below summarizes the GPIO and Analog to Digital Converter input positions on the screw terminals.

GPIOADC
IO0ADC0
IO1ADC1
IO2ADC2
IO3ADC3
IO4ADC4
IO5ADC5
IO6ADC6
IO7ADC7
GNDGND

DC Power Supply

This product requires an external 12V power supply to function. The power supply unit required is included with the product. Connect the power supply to the connector on the product marked as +12V power. This product uses a single power supply for the digital circuitry and the relay coils. An internal isolated DC-DC converter and a set of opto-couplers ensure galvanic isolation between the digital circuitry and the relay coil driver circuitry.

Driver Installation

Installing Numato Lab CDC Driver - Windows Desktop and Server Editions

The driver package for Numato Lab’s products can be downloaded from the product page at https://numato.com. To install the driver, unzip the contents of the downloaded driver package to a folder. Attach USB cable to the PC and when asked by Windows device installation wizard, point to the folder where driver files are present. When driver installation is complete, the module should appear in Windows Device Manager as a serial port. The picture below shows a 1 Channel USB Relay Module visible in Windows Device Manager. For other devices (USB GPIO and USB Relay modules), the name will be different but how the device is displayed and used is exactly same.

Note down the name of the serial port (COM1, COM2 etc..). This information is required to control the module from the PC.

You may notice that the driver package does not come with a .sys or .exe file as most driver packages do and is expected to be that way. The driver binary necessary in this case is shipped with all copies of windows Desktop/Server editions and gets installed automatically while Windows is installed for the first time. The .inf and .cat files present in the driver package downloaded from http://numato.com merely associate this pre-existing driver with the attached Numato Lab device .

The following video demonstrates how to install the driver on Windows 10.

Installing on Windows Embedded Editions

Windows Embedded editions do not install the infrastructure necessary for USB CDC by default in favor of a smaller footprint. This will cause the driver install to fail unless the necessary files are manually installed prior to installing the driver. Please follow the steps below to install the prerequisites and driver correctly. These steps are tested on Windows 7 Embedded Edition. The installation procedure may vary for other versions of Windows Embedded. Please contact Microsoft for more information.

  1. Locate winemb-inf-mdmcpq.cab on Win 7 Embedded DVD/ISO image
  2. Copy winemb-inf-mdmcpq.cab to a folder Ex: C:Temp
  3. Run command DISM.exe /online /Add-Package /PackagePath:C:Temp
  4. Wait for Windows to restart (Restart machine manually if DISM does not restart the machine automatically)
  5. After reboot is complete, plug the device to a USB port and install driver normally (Driver is available for download at the product page)
For more information or for additional help on Windows Embedded editions, please contact Microsoft or your Windows Embedded reseller

Installing on Linux

To use any device that uses USB CDC protocol with Linux, USB CDC driver needs to be compiled in to the kernel. Fortunately, most Linux distributions (Ubuntu, Redhat, Debian etc..) has this driver pre-installed. The chances of you requiring to rebuild the kernel to include the USB CDC driver is very slim. When connected to a Linux machine, this product should appear as a serial port under /dev directory. Usually the name of the device will be ttyACMx or similar. The name may be different depending on the Linux distribution you have. The image below shows the result of ls /dev command on a Linux Mint system with a USB GPIO/Relay device attached.

Device Listing on Linux

In this particular case, the device shows up as ttyACM0 (highlighted in orange color) but it could be ttyACM1 or ttyACM2  etc… depending on the specific system and other connected devices. Once the device is visible under /dev directory, it can be treated just like any other serial device. Commands can be sent to the device using any mechanism that is valid for regular serial ports such as screen command or Serial Terminal Emulation applications. If there are more than one devices connected to the same host computer, each device will be displayed as separate serial devices with unique names. These separate serial devices can be used to control individual devices attached.

Installing on Mac OSX

Mac OSX is usually shipped with USB CDC driver pre-installed. When connected to a Mac computer, this product should appear as a serial port under /dev directory. Usually the name of the device will be tty.usbserialportx or tty.usbmodemx or similar. The name may be different depending on the Mac OSX version you have. The image below shows the result of ls /dev/*usb* command on a Mac OSX Yosemite system with a USB GPIO/Relay device attached.Listing USB GPIO Devices on Mac OSX

In this particular case, the device shows up as tty.usbmodem141141 (highlighted on orange color) but it could be any name starting tty.usbmodem  or even a completely different name depending on the exact version of operating system and other connected devices. Once the device is visible under /dev directory, it can be treated just like any other serial device. If there are more than one devices connected to the same host computer, each device will be displayed as separate serial devices with unique names. These separate serial devices can be used to control individual devices attached.

The Modbus Interface

Prodigy UR series Modbus Relay Modules use Modbus protocol for it’s primary interface. Modbus is a simple yet powerful industry standard protocol that was originally developed by Modicon systems for transmitting/receiving information over serial links. Although Prodigy devices use USB as the physical interface, the device represents itself to the operating system as as classic serial device which makes Modbus a very suitable protocol for this product. This also completely hides the complexities of using USB protocol and thus making Prodigy devices as easy to use as a normal serial device.

When working with Modbus, there are two important aspects of the protocol that the user may need to understand. 1) How to send and receive Modbus packets 2) The Modbus Register Map. One need to learn details of building, sending and receiving Modbus packets only if he/she is engaged in low level library or application development (and thus not covered in this document). For an end user who wish to use Prodigy devices with an off the shelf software, understanding of Modbus register map would be sufficient.

Modbus Register Map

Coils

Coils are single bit data type that represents the output state of a single bit entity such as Relay or a GPO. Please note that Coils are always used to represent and output quantity. Writing to a coil will update the output quantity with the value written. Reading a coil will return the data that was previously written. For example, writing “1” to a coil that represents a relay will turn ON the relay and vice versa. Reading from a Coils that represents a turned OFF relay will return value “0”. The Address in the table below shows the position of each coil within the Modbus register map. There are 8 coils corresponding to the 8 GPOs and another set of 8/16 coils corresponding to the 8/16 Relays on UR08/UR16. The data address of the Coils can be used to access the corresponding Relay or GPO.

No.NameCoil NumberData AddressSizeComments
GPOs
1GPO0101
2GPO1211
3GPO2321
4GPO3431
5GPO4541
6GPO5651
7GPO6761
8GPO7871
Relays
9Relay0200120001
10Relay1200220011
11Relay2200320021
12Relay3200420031
13Relay4200520041
14Relay5200620051
15Relay6200720061
16Relay7200820071
17Relay8200920081
18Relay9201020091
19Relay10201120101
20Relay11201220111
21Relay12201320121
22Relay13201420131
23Relay14201520141
24Relay15201620151

Discrete Inputs

Discrete Inputs are single bit data type that represents the input state of a single bit entity such as a GPI. For example, by reading the Input bit corresponding to a GPI, the user can get the state of the logic (HIGH/LOW) externally applied to the GPI.

No.NameInput NumberData AddressSizeComments
GPIs
1GPI01000101GPI0 Status High/Low
2GPI11000211GPI1 Status High/Low
3GPI21000321GPI2 Status High/Low
4GPI31000431GPI3 Status High/Low
5GPI41000541GPI4 Status High/Low
6GPI51000651GPI5 Status High/Low
7GPI61000761GPI6 Status High/Low
8GPI71000871GPI7 Status High/Low

Holding Registers

No.NameInput NumberData AddressSizeAccessComments
Device Info Area
1Vendor ID3800180001RO
2Product ID3800280011RO
3OEM Vendor ID3800380021RO
4OEM Product ID3800480031RO
5HW major version and Minor version3800580041ROHardware revision information.
6Firmware major, minor version3800680051ROFirmware revision information
7Firmware bugfix/patch level3800780061ROUpper byte: Developer revision. Always zero on official public releases
Lower byte: Bug fix level. Incremented when a release is made specifically to address bugs.
8PNV data format major, minor version3800880071ROMajor and minor versions for Permanent Non-Volatile data format
9Register Map major, minor version3800980081ROMajor and Minor versions for Modbus register map
10Up time counter3801080092RORun time since last power cycle in seconds.
11Total run time counter3801280112ROTotal run time since factory reset in seconds.
Device Specific Area
12User ID4805180502WRTwo registers (4 bytes) for storing custom user data.
13Relay Power ON value Register402612601WRPower ON value registers for relays.

Input Registers

No input registers implemented at this time.

Controlling Prodigy UR08 using off the shelf software

Prodigy UR devices’ support for Modbus protocol makes it easier to use with virtually any software that supports Modbus. This section of the document demonstrates how to use Prodigy UR devices with some of the software that are available in the market.

Windows

qModMaster

qModMaster is a free software that emulate Modbus master and can be used to access any device that is Modbus compatible. qModMaster can be downloaded for free at at https://sourceforge.net/projects/qmodmaster/. Follow the steps below  to see how to use Prodigy UR devices with qModMaster.

Step 1:

Download and install qModMaster from https://sourceforge.net/projects/qmodmaster/.

Step 2:

Run qModMaster and select “Modbus RTU” from Options menu. Enter Serial Port name and other settings as in the image below and click OK. Serial Port name must match the port name assigned to the device by the Operating System.

qModMaste Settings for UR08

Step 3:

Click the “Connect” button to connect to the device.

qModMaster Open Port

Step 4:

Select “Write Single Coil” function code in the Function Code combo box, enter the Data Address of the first Relay (Relay Index 0) in the Start Address box and enter value 1 (corresponds to Relay ON state) in the data cell. Now click the Read/Write button to send the new value to the device. If everything works fine, you will hear the relay clicks and any circuitry connected to the relay will be activated. To read the status of a Relay, the same sequence apply but select the “Read Coils” function code instead.

qModMaster Turn Relay ON

 

Additional Information

Using relay modules with inductive loads

Snubber Diode

Diode As Snubber

It is important to take additional care when using relays with inductive loads. An inductive load can be pretty much anything that has a coil and works based on magnetic principles like Motors, Solenoids and transformers. But in practice, even a wire longer than a few feet can display substantial inductance. Inductive loads produce back emf when the magnitude of the load current changes. The back emf can be in the order of tens or even hundreds of voltage (See this Wikipedia article http://en.wikipedia.org/wiki/Counter-electromotive_force). This effect is most severe when power is disconnected from inductive load because the rate of change of current is maximum at that point. Even though the back emf lives only for a very short time (a few milliseconds) it can cause sparks between the relay contacts and can deteriorate the contact quality over time and reduce the life span for the relays considerably.

So it is important to take countermeasures to suppress the back emf to acceptable levels to protect relay contacts. Usually this requires connecting electronic devices in parallel with the load such that they absorb the high voltage components generated by the load. For solenoids, connecting a diode (fast switching diode is recommended) in parallel to the load (in reverse direction to the load current) is very effective. A diode used for this purpose is usually called a freewheeling diode. Please see the diagram on the right for connection details.

Capacitive Snubber

Capacitor As Snubber

A capacitor with proper rating is recommended for protecting the relay contacts when a motor is used as load. The capacitor should be rated enough to withstand the back emf that is generated by the motor. Please see the diagram below for connection details.

Please note that the relay modules are NOT shipped with back emf suppression devices pre-installed. The exact kind of suppression device and the parameters of the selected device can vary depending on the load itself. Some of the parameters that affects the suppression device selection are the inductance of the load, power supply voltage, load current, physical size/structure of the load etc.. It is obvious that it is impossible for us to predict these parameters and design required back emf suppression device and incorporate that on the board. So we believe this is a task best left to the module user. There is an excellent article on designing back emf suppression on Wikipedia at http://en.wikipedia.org/wiki/Flyback_diode

Analog to Digital Converters (ADCs)

Prodigy UR devices do support Analog to Digital Conversion on some of the GPIO terminals. A list of GPIOs that supports analog function in this product is listed elsewhere in this document. GPIOs doesn’t need to be configured specially in order to use them as analog inputs. Simply reading the Analog Input Register corresponding to the IO will automatically put the IO in to Analog Input mode and read the analog value . Resolution of the ADC on this product is 12 bits. The input voltage range of the ADC is 0 – 3.3V.

GPIO with Switches

USBGpio Switch connection diagramIt is possible to read the position of a switch that is connected to a GPIO. A SPST or SPDT switch is recommended to use with GPIOs. Push switches that maintain the contacts closed only for a very short time so using them is discouraged. The fundamental idea of using a switch with GPIO is to have the switch cause a voltage level change at the GPIO pin when pressed. Usually this is achieved by using an external pull-up resistor along with the switch. The pull up resistor is connected between the GPIO and VDD and the switch is connected between the GPIO and ground. When the switch is not pressed, the pull-up resistor will cause the GPIO to stay at VDD voltage level. When the switch is pressed, the GPIO is short circuited to ground and stays at zero voltage. This change in voltage and thus the position of the switch can be read by simply reading the Discrete Input bit corresponding to the GPIO.

Technical Specifications

ParameterValueUnit
Number of relays UR08 - 8
UR16 -16
Number of GPIOs8
Number of analog inputs (Multiplexed with GPIOs)8
Power supply voltage (External)12V
IO Specifications
Maximum IO source current20mA
Maximum IO sink current20mA
GPIO input low voltage 0.8V
GPIO input high voltage 2V
GPIO output low voltage 0V
GPIO output high voltage 3.3V
ADC Specifications
Resolution12bits
Full scale range0 – 3.3V
Reference voltage2.5V
Recommended Impedance of Analog Voltage Source2.5KΩ
Relay Specifications
Nominal relay coil voltage 12V
Nominal coil power consumption (per relay)120mW
Relay contact material Silver Alloy
Contact rating 5A/ 250V AC
5A/ 30V DC
Maximum switching voltage 245VAC/ 30VDC
Maximum switching current5A
Maximum switching power1250VA/ 150W
Contact resistance (initial)100mΩ
Insulation resistance1000MΩ
Life expectancy (Electrical) 50,000 Operations
(5A 250VAC/24VDC, Resistive load)
Life expectancy (Mechanical) 20000000Operations
Maximum switching on response time10mS
Maximum switching off response time5mS
Shock resistance (Functional)98m/s2
Shock resistance (Destructive)980m/s2
Vibration resistance10Hz to 55Hz 1.5mm DA
Other Information
USB Vendor ID0x2A19
USB Product IDUR08 - 0x2001
UR16 - 0x2002

Frequently Asked Questions (FAQs)

Q. What are the serial parameters I need to use when communicating with this board?
A. Since this module uses USB as the underlying transport mechanism, most of the serial parameters do not affect the communication. You can leave all parameters to any legal value (Eg: 2400, 4800, 9600 etc… for baud rate) except Flow control. Flow control needs to be set to “None”.

Q. Where do I find driver for this product?
A. Visit http://numato.com and navigate to the product page. There will be a link to download windows driver. Linux does not require driver installation since in most cases they are shipped with the driver pre-installed.

Q. Why there is no .sys or .exe file in the Windows driver package I downloaded?
A. This product uses USB CDC driver binary which is already present on Windows. All Windows versions (with the exception of Embedded Editions) has this driver binary installed by default. The .inf and .cat files present in the zip file helps Windows identify the device properly and associate appropriate driver (.sys) to the device

Q. Does this product work with Linux?
A. Yes, this product works with Linux. Please see more details on how to use this product with Linux elsewhere in this document.

Q. Does this product work with Mac OSX?
A. Yes, this product works with Mac OSX. Please see more details on how to use this product with Mac elsewhere in this document.

Q. What are the software that this product work with?
A. This product works with almost any software that has support for standard Modbus. Some examples can be found elsewhere in this document. Different software are written by different developers with different purposes in mind. So you may encounter some software that may not work with this product. But usually alternatives are available in most if not all cases.

Q. I’m using x language for programming. How do I find out if this language can be used to program and control the GPIO module?
A. Find out if the language of interest supports some kind of APIs/Functions/Components for serial communication. If it does, most likely you should be able to use that language with this module. It may also be possible to find libraries such as libModbus that offers high-level APIs. Using such libraries can speed up development quite a bit.

Q. I need a customized version of this product, can Numato Lab do the customization for me?
A. Yes, we can definitely do customization but there may be minimum order requirements depending on the level of customization required. Please write to [email protected] for a quote.

Q. Where can I buy this product?
A. All Numato products can be ordered directly from our web store https://numato.com/. We accept major credit cards and Paypal and ship to almost all countries with a few exceptions. We do have distributors in many countries where you can place your order. Please find the current list of distributors at http://numato.com/distrib.

Suggest Edit