LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Linux and 12v relay control (https://www.linuxquestions.org/questions/linux-hardware-18/linux-and-12v-relay-control-544912/)

jantman 04-10-2007 03:15 PM

Linux and 12v relay control
 
I was wondering if anyone knows of any products, relatively simple, to control 12v relays from within linux? Essentially, what I want to be able to do is control 6 to 12 12v relays from the command line or through another program. Something with a Python or Perl interface would be great, as that's how I'll probably end up using it.

Any suggestions? I've never programmed anything using serial or USB interfaces before, so something that comes with software would be great.

GrapefruiTgirl 04-10-2007 03:36 PM

http://www.truetex.com/poolcontrol.htm
http://www.aboutdebian.com/x10.htm
http://www.informit.com/guides/conte...eqNum=199&rl=1

Here's some stuff for you to look at. Not sure it's *exactly* what you have in mind, but it's something! :)

jantman 04-10-2007 04:00 PM

Thanks for the links. It looks like most of those things are intended for 120v relays (like X10) and I'm looking for an in-vehicle application, hence the 12V DC requirement.

Electro 04-11-2007 04:04 AM

Use a high gain transistor (not Darlington), a resistor, diode. The diode should be in parallel of the coil to act as a surge suppressor. A high gain transistor uses less current to switch on. Just make sure the current consumption of the relay's coil is lower than the transistor's maximum collector current or else it will fry.

Go to http://ourworld.compuserve.com/homep...age6.htm#PPRIC.

It is designed for a parallel port, but can be used for any parallel circuit. It will also work with a serial to parallel circuit like RS-232 (Serial Port) or USB. Parallax Basic Stamp II can convert serial into parallel. Basic Stamp II can be programmed in Linux. I think Dallas Semiconductor (Maxim) chips can be used instead of Basic Stamp II to convert serial into parallel.

jantman 04-11-2007 10:22 AM

Are there any pre-made systems out there? I'll admit I'm not the best with assembly, and really don't want anything that's less than a ready-to-solder PCB and a schematic.

I need serial or USB - I'll probably end up using more than one on the machine.

Was re-spec'ing the project... any suggestions for something with nearly 40 12V low current (2-5A) relays and about the same number of current sensing inputs (most be isolated from the computer)?

The basic concept is I'm working on a prototype of a system that will control 12v LED lights, and will also need to sense current coming back from them to run a self-diagnostic test.

Electro 04-11-2007 08:27 PM

Unfortunately, you have to design and build the device from scratch because I have not seen such device except automated Christmas lights that you may have heard on the news or read on the internet.

To sense any current with out touching the wire and with out using a shunt resistor, you will have to use either a toroidal coil or a hall-effect chip and an op-amp to amplify the current. When using the toroidal coil, put the positive wire through the middle of it.

Relays mostly used for controlling AC circuits or changing audio/video inputs to another set of inputs. You could use a MOSFET, another kind of transistor which is metal-oxide field effect transistor, that will turn off and on the LED lights at a sacrifice of the lights being dim slightly, but not as much as transistors. To separate the electronics from the computer, use optoelectronic chips. They use light to switch on a transistor or any light activate device. Look for high KV (kilovolt) optoelectronic chips.

USB can be used with this device a little easier than serial. You can use a USB to parallel device. Program it to send serial data in RS-232 scheme then use serial to parallel converters on each pin. This will provide up to 64 outputs, but may have to include extra circuitry if want to send data to the computer. Look up DLP-USB245M-G module on FTDI (http://www.ftdichip.com/) site.

To finalize your device, look up press-n-peel. You just need Gimp to create the PCB and a laser printer to make press-n-peel to work.

Pick up a few Forest Mims books at Radio Shack. They should help you with some basic electronics. Also use the internet to help you learn it further.

jantman 04-11-2007 08:44 PM

LED brightness is of paramount importance. I'm looking for relays that will switch 12V @ 5A, anything more than that I'd have the PCB onboard relay switch a 20A automotive relay.

If you look at: http://www.ozitronics.com/relay.html
they offer a pre-assembled (or kit) serial device that has 8 relays and 4 optoisolated inputs. Essentially, this is what I want, but to get the ~40 relays and inputs I think I'll need, $100 per kit is a bit much. His appears to be the same kit from www.qkits.com.

My roommate, an electrical engineering major, agreed to work with me on this and try and spec something out and price it.

Electro 04-11-2007 10:45 PM

Digi-key:
Part #255-1239-ND

or

Jameco Electronics:
Part #282255PS

When mounting very high current devices on PCB, keep in mind of the width of the copper traces.

Your project will not be cheap. It will be costly and complex.

The current rating for AC versus DC is different. If it saids 5 amperes for AC, for DC it will be around 2.5 amperes. The kit that you found will work but it will be like the The Clapper device scene in the movie "Uncle Buck". The relays will eventually fry because of DC and very high temperatures.

jantman 04-11-2007 11:07 PM

I know it won't be cheap, but I'm pretty set on doing this project.

I figured that about half of the relays will be switching LEDs (triplets of 3W LEDs) that should be around 1A max. Those could be handled by the onboard LEDs.

For everything else, I figured I'd just have the board relays drive the coil contacts for 20A automotive relays. I have about 40 of them in a box on my bench.

If need be, for a proof-of-concept, I can always just make a bunch of off-the-shelf units work. The other option is to find a used industrial computer that will interface directly with some microcontrollers.

Quakeboy02 04-11-2007 11:09 PM

You might consider using a couple of printer ports to control opto-isolators, which in turn control your relays. You could even use some simple gates to multiplex control of a gang of latching relays using a single printer port it that's acceptable. But in the end, you're either going to put in a lot of your own effort building it, or pay someone else to do it for you. Forty is simply a lot of relays to mess with. Even just paying for 40 relays is going to be expensive, and that's if you have nothing else to mess with. You might browse around in the catalog at mouser.com and see if they have anything in their PC section that might help.

jantman 04-11-2007 11:24 PM

I'll give it some thought.

As to cost - the computer running this is going to cost about $500, and it's going to be controlling nearly $2,000 of LED's and other accessories. If I could get the relay/input system built for around $300 or so, it wouldn't be a problem.

Quakeboy02 04-11-2007 11:26 PM

I just found some more ideas.

Here is a site devoted to this sort of stuff: http://www.linuxha.com/

Here is a site with some 16 relay controllers: http://www.cc-concepts.com/store/

If linux can output x10 signals and a few of those 16 relay controllers will do if for you, then that's a possible solution. Pricey, but possible.

jantman 04-11-2007 11:46 PM

Thanks for the links. Looks like everything there is 120v and not serial, but should give me some ideas...

I've also been looking around at the options for computers to control this... essentially the options are:
1) find something like a Mini-ITX board that supports everything I need and get an enclosure and a 12v PS for it.
2) Find a relatively ready-to-go "carputer" system that supports Linux
3) Find a Linux-based industrial computer that will run off of 12v.

The good news is that almost all of the options I've looked at have 2-4 serial ports plus USB. If I could find some cheap interfaces that handled 10 or so inputs and/or relays, it's possible that for a proof-of-concept, I could just grab a *bunch* of USB->serial adapters and handle each board separately.

Wim Sturkenboom 04-12-2007 02:19 AM

http://www.electronickits.com/kit/co...ec/ck1610.htm; $65 partially assembled; 8 relays, 4 inputs; serial port
http://www.electronickits.com/kit/co...ec/ck1601.htm; $40 assembled; 8 relays; parallel port

jantman 04-12-2007 09:32 AM

Thanks.

I looked at the CK1610 at
http://www.electronickits.com/kit/co...lec/ck1610.htm

Seems like a good basis, if I could find someone with enough electronic knowledge to use it as a basis to engineer something larger.

The 8 relays are good, but with only 4 inputs, I'd need to find something with a lot more.


All times are GMT -5. The time now is 05:01 PM.