Usb relay: Difference between revisions

From SundanceWiki
Jump to navigation Jump to search
(Created page with "The USB relay box contains one of these: File:https://wiki.sundance.com/images/thumb/3/39/USB_relay_image.jpg/284px-USB_relay_image.jpg It is a simple device that conver...")
 
No edit summary
Line 1: Line 1:
The USB relay box contains one of these:
The USB relay box contains one of these:


[[File:https://wiki.sundance.com/images/thumb/3/39/USB_relay_image.jpg/284px-USB_relay_image.jpg]]
[[File:USB relay image.jpg|240px]] 
[[File:USB relay image btm.jpg|240px]]


It is a simple device that converts USB to a serial UART / Comport.
It is a simple device that converts USB to a serial UART / Comport.


When special commands are sent to the comport it either energises or de-engeriges the relay, switching between NC (Normally Connected)  and NO (Normally Open.
When special commands are sent to the comport it either energises or de-engeriges the relay, switching between NC (Normally Connected)  and NO (Normally Open).
So if a wire is routed through NO -> Com, when the relay is switched on the contacts close and the circuit completes.  When switched off again it opens and breaks the circuit.
 
So if a wire is routed through NO -> COM, when the relay is switched on the contacts close and the circuit completes.  When switched off again it opens and breaks the circuit.


NC is the other way round.
NC is the other way round.


In windows you need to
=== Windows ===
In windows the easiest way I found of controlling it was to use a program called "SSCOM32E".  I've saved a copy of this to our FTP server [https://ftp2.sundance.com/Pub/Support_Files/Wiki_images/extras/UART-Communication-Software-SSCOM32.rar HERE].
 
When the box is plugged into your windows PC, check the device manager to see which comport it has been allocated.
 
Open the program and select the comport from the drop down box (Green).
 
Set the string that you need to send to change the state of the relay (Red) and then press Send (Blue).
 
[[File:SSCOM usage.png]]
 
You should hear the relay click and see a second LED come on through the slot.
 
The commands to send are
"A0 01 01 A2" to switch it on - no quotes.
"A0 01 00 A1" to switch it off - no quotes.
 
=== Linux ===
 
In Linux you don't need any additional programs.
 
To find out which USB device it has been allocated run this command:
 
'''dmesg | awk '/tty/ && /USB/ {print "/dev/"$10}'|tail -1'''
 
This will tell you the ttyUSB number of the last thing that was connected to the PC.
 
To control the relay enter the following commands in terminal (changing the ttyUSB number to the one reported):
 
To switch on:
'''echo -en '\xA0\x01\x01\xA2' > /dev/ttyUSB3'''
 
To switch off:
'''echo -en '\xA0\x01\x00\xA1' > /dev/ttyUSB3'''

Revision as of 10:07, 11 April 2024

The USB relay box contains one of these:

It is a simple device that converts USB to a serial UART / Comport.

When special commands are sent to the comport it either energises or de-engeriges the relay, switching between NC (Normally Connected) and NO (Normally Open).

So if a wire is routed through NO -> COM, when the relay is switched on the contacts close and the circuit completes. When switched off again it opens and breaks the circuit.

NC is the other way round.

Windows

In windows the easiest way I found of controlling it was to use a program called "SSCOM32E". I've saved a copy of this to our FTP server HERE.

When the box is plugged into your windows PC, check the device manager to see which comport it has been allocated.

Open the program and select the comport from the drop down box (Green).

Set the string that you need to send to change the state of the relay (Red) and then press Send (Blue).

You should hear the relay click and see a second LED come on through the slot.

The commands to send are "A0 01 01 A2" to switch it on - no quotes. "A0 01 00 A1" to switch it off - no quotes.

Linux

In Linux you don't need any additional programs.

To find out which USB device it has been allocated run this command:

dmesg | awk '/tty/ && /USB/ {print "/dev/"$10}'|tail -1

This will tell you the ttyUSB number of the last thing that was connected to the PC.

To control the relay enter the following commands in terminal (changing the ttyUSB number to the one reported):

To switch on: echo -en '\xA0\x01\x01\xA2' > /dev/ttyUSB3

To switch off: echo -en '\xA0\x01\x00\xA1' > /dev/ttyUSB3