LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 10-04-2014, 03:02 PM   #1
cigtoxdoc
Member
 
Registered: Aug 2007
Posts: 63

Rep: Reputation: 0
SainSmart USB 4-channel relay


I need to find a way of getting my PC (Ubuntu 14.04 32-bit) to program one channel of this relay such that the relay closes for 3 seconds and then remains open for the next 27 seconds and then closes for 3 seconds and repeats this cycle for ten minutes or so.

The relay uses a FT245TR USB FIFO device and I have the Linuix drivers. I understand that some have written code to operate the relay using Python or Java, etc. What I need is something easy and hopefully with graphical interface.

Thank you,

John
 
Old 10-06-2014, 11:01 AM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,906
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Member Response

Hi,

Look at: http://www.ftdichip.com/Support/Docu.../DS_FT245R.pdf for additional information.

BTW, which shield are you using? Most suppliers/vendors provide module information/drivers.
 
Old 10-06-2014, 11:03 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,906
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Moderator Response

Moved: This thread is more suitable in <Linux - Embedded & Single-board computer> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 10-07-2014, 10:21 AM   #4
cigtoxdoc
Member
 
Registered: Aug 2007
Posts: 63

Original Poster
Rep: Reputation: 0
Hello Onebuck:

Thank you for moving my request for help. but I am still as confused as ever, and I need a solution fast as I have a paper to give next week, and programming the SainSmart USB 4-channel relay is a mission critical step. No one, even Canonical (have support agreement), wants to tell me what applications softrware I need to use to make one of the four channels open and close the way I need. Apparently, if I had LabView, I would have the needed functionality. A program called KMTronic USB Timer 1.1 Beta (Windows XP) will find the board at COM112 and open and close the port, but apparently does not do anything with the channels. I am not sure why this is so difficult. I had a Mattson Instruments FT-IR back in 1986 that used AT&T UNIX, and had similar commands built into the graphical user interface.
 
Old 10-07-2014, 10:58 AM   #5
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,416

Rep: Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541Reputation: 1541
Ok, so does this device appear as a serial port on your computer?

What have you written so far to interface with it?

From a quick look around online it looks like this is supposed to appear as a serial port and the following are supposed to activate the relays:

Code:
Communication Parameters:
 8 Data, 1 Stop, No Parity
 Baud rate : 9600

 Commands:
 FIRST channel commands:
 OFF command : FF 01 00 (HEX) or 255 1 0 (DEC)
 ON command : FF 01 01 (HEX) or 255 1 1 (DEC)

 SECOND channel commands:
 OFF command : FF 02 00 (HEX) or 255 2 0 (DEC)
 ON command : FF 02 01 (HEX) or 255 2 1 (DEC)

 THIRD channel commands:
 OFF command : FF 03 00 (HEX) or 255 3 0 (DEC)
 ON command : FF 03 01 (HEX) or 255 3 1 (DEC)

 FOURTH channel commands:
 OFF command : FF 04 00 (HEX) or 255 4 0 (DEC)
 ON command : FF 04 01 (HEX) or 255 4 1 (DEC)
So try:

You may have to change the stty accordingly, I've not really looked at it in much detail.

Code:
stty -F /dev/ttyS0 speed 9600 cs8 -cstopb 
echo -e -n "\xFF\x01\x01\x0a" > /dev/ttyS0
and see if that turns relay 1 on.

If that works then you can use a quick and dirty bash script to achieve your timings.

I've a Velleman 8 relay board that's similar and appears as a com port and I've written some nice sequencer software with a GUI that sends the relevant commands down the serial port to the board. However it's also Windows only.

You may also find this link handy, it's the "missing" documentation / samples from SainSmart: https://s3-ap-northeast-1.amazonaws....20-018-909.rar

Last edited by TenTenths; 10-07-2014 at 11:00 AM.
 
Old 10-07-2014, 11:14 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,906
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Member Response

Hi,

I found for Win7 using this FTDI D2XX Driver. Maybe that will help.
There are Rpi examples for this; http://www.raspberrypi.org/forums/vi...45516&p=500639
Hope this helps.
Have fun & enjoy!
 
  


Reply

Tags
relay, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] adding an existing child channel to a base channel in Rhel Satellite server unix1adm Linux - Software 1 05-30-2013 02:30 PM
How to get 5.1 channel audio on back panel and all channel mixed stereo on headphone dr@shutosh Linux - Desktop 0 05-14-2012 03:31 PM
Help with a usb relay board Graham88 Linux - General 3 09-07-2010 03:26 PM
Postfix Relay Getting Spammed Bad -- But no open relay... ihod2008 Linux - Server 1 07-26-2008 09:24 PM
Hard drive in primary channel showing in secondary channel Ale Linux - Hardware 2 02-20-2004 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration