KMtronic

(We are on holiday until 13.09.2010)
It is currently Thu Sep 09, 2010 10:22 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: USB Eight channel relay
PostPosted: Thu Mar 11, 2010 12:34 am 
Offline

Joined: Thu Mar 11, 2010 12:31 am
Posts: 3
I managed to get the board connected to my mac. I installed the drivers and I can see the device in /dev as 'tty.usbserial-A6008501' The lights on the usb controller light up when I plug it into my computer, but I can't seem to get the relay board to do anything.

I'm starting to guess that I need to apply some power to the relay board itself. I'm a complete novice at this sort of thing, but understand that I need a 12V/300mA power supply. What's the best way to get one? Would Radio Shack have such a thing with exposed leads?

thanks!


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Thu Mar 11, 2010 5:16 am 
Offline
Site Admin
User avatar

Joined: Mon Dec 28, 2009 2:16 pm
Posts: 50
Hi,

You can use any adapter like this one:

Image

Simple cut connector and connect +12V to VCC and -12V to GND.

Recommend 12V/500mA.

Regards


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Thu Mar 11, 2010 5:28 pm 
Offline

Joined: Thu Mar 11, 2010 12:31 am
Posts: 3
Okay. I attached the power supply, but I still can't get any of the LEDs on the board to light. I'm running this script:

#!/bin/sh
while true
do
echo -e "\xFF\x00\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x00\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x00\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x00\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x00\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x01\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x02\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x03\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x04\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x05\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x06\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x07\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x08\x01" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x01\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x02\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x03\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x04\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x05\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x06\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x07\x00" > /dev/tty.usbserial-A6008501 ; sleep .1
echo -e "\xFF\x08\x00" > /dev/tty.usbserial-A6008501 ; sleep .1


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Sat Mar 13, 2010 6:00 am 
Offline
Site Admin
User avatar

Joined: Mon Dec 28, 2009 2:16 pm
Posts: 50
Hi

Please in first provide test relay board.

Disconnect relay board from USB output board, add power and using one wire add +12V (VCC) to In1, In2..
Relays must turn ON/OFF.

For control please check this post:
http://www.sigma-shop.com/board/viewtopic.php?f=2&t=2

Regards


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Tue May 11, 2010 11:43 am 
Offline

Joined: Tue May 11, 2010 11:26 am
Posts: 1
I have been able to get the 8 port relay board to work under OS X but only when running in Parallels under Windows XP virtual machine. So I know that my board works. I am still however unable to get response from relay board itself using OS X Zterm or terminal. I noticed this response from blowupp on another post here:

___
To get the thing working with OS X 10.4.11 on my system I needed to send the comand to the alternative port
ie: echo -e '\xFF\x01\x00' > /dev/cu.usbserial-xxxxxxx
___

Since I see TX led activity when I send commands via Zterm, I think that my commands are getting to the board's USB controller. I also am not sure what the \x in the command line above signifies though I have tried it to no avail. Not sure how to switch to alternative port cu.usbserial, and not sure how to identify the identifier of my board (the x's in /dev/cu/usbserial-xxxxxx)

Thanks to anyone for any hints or ideas?


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Thu May 13, 2010 11:35 am 
Offline

Joined: Sun Apr 04, 2010 10:20 am
Posts: 5
Hi Spanky,

If you do get through (LED lights up shortly) to the USB->RS484 board; but the relays don't change it sounds to me like a speed/communications problem.

Try setting the speed to 9600 baud ("stty -F /dev/cu.usbserial-xxxxxxx 9600") and then "echo -e '\xFF\x01\x01' > /dev/cu.usbserial-xxxxxxx".

The "\x" in the echo command is a so-called "backslash escape" (they are enabled by the "-e" option of the echo command"). I means the next couple of digits are the hexvalue of an ascii character which is embedded in the string being echo'ed to the device. In this particular case the sting holds three characters only, a character 255 ("hey, wake up, dude"), a 001 ("I mean to alter relay no 1") and yet another 001 ("I want you the relay to open"). You could also write "echo -e '\0377\0001\0001' > /dev/whateveryourdeviceiscalled" for the same effect - only that would be in octal notation :o)

If the speed does not fix it it's related to handshake/stopbits/parity. Do an "man stty" and look for a definition of your your "sane" settings. (They are also normally the default values). If they differ from the requirements of the board you need to change them with further "stty" flags than just the baudrate. I dont recall the exact needed settings; but i do recall seeing them somewhere here at the forum.

Cheers Claus


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Thu May 13, 2010 12:16 pm 
Offline
Site Admin
User avatar

Joined: Mon Dec 28, 2009 2:16 pm
Posts: 50
Hi Kildeskum,

Thank you for post!
In Hex format is : echo -e '\xFF\x01\x01' >
In Octal format is : echo -e '\0377\0001\0001' >

Do you know how send the same in Dec (255, 1, 1)?

Regards


Top
 Profile  
 
 Post subject: Re: USB Eight channel relay
PostPosted: Fri May 14, 2010 12:29 am 
Offline

Joined: Sun Apr 04, 2010 10:20 am
Posts: 5
Hi KMtronic,

Hmm, as far as I know that's not possible with "echo". The echo command is not a stand alone command but is build into the shell (the command interpreter). I don't know all shells - far from it - so I could easily be mistaken. In the good old days the only shells around were "sh" and "csh". In those two only the octal notation was possible (because the backslash notation for character escape sequenses was derived directly from the ANSI C definition, I guess and that definition knew of neither decimal nor hexadecimal notation). When "ksh" and "bash" came around their echo command had the hexadecimal "\x" notation added - probably because it was also added to the "printf" command.

I don't know much about MAC OS - actually i dont even know which shell is the default (a "basename $SHELL" will reveal that :o); but i would guess it does not support decimal notation either. If it is indeed possible, it should be explained in the system - try a "man bash" or whatever shell you use on your system and seach for "echo" (just type "/echo<return>" when the manpage is shown (find next is "n")).

On my system (ubuntu, actually) even printf does not support a decimal notation for character backslach escape sequences - at least not directly. It would be possible to do something like this however:
Code:
let var=255
printf \\$(($var/64*100+$var%64/8*10+$var%8))

- to print an ASCII character based on it's decimal value; but it's a bit like crossing the stream in order to get a drink of water....

It would very simple to make a script or function to do this translation as well (or compile a small c program that did it if need be).

Anyway, I kind of like the hexnotation - it looks short and neat in my opinion. Why would something like "\d255" be better or easier to understand than "\xFF"? I do realize "\x0A" is less intuitive as a reference to the tenth relay than for instance "\d010"; but it's probably only being used when the program controlling the device is being developed - and not by the end user...

Np help - I know. Sorry.

Cheers
Claus


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Localized by MaĆ«l Soucaze © 2010 phpBB.fr