3
\$\begingroup\$

I'm currently trying to design a relay network for a piece of laboratory equipment (PPMS). I would like to describe what the setup is, what I am doing now, what I hope to do, and how I hope to do it. Skip ahead if you're bored!

The current setup and what I am doing now:

The machine has 12 pins which are accessible via a LEMO connector on the side. Thus far, a colleague made a LEMO to DA-15 cable and I made a DA-15 to 15 BNC breakout box. I have a voltmeter and a current source with BNC cables coming out for V+, V-, I+ and I-. Right now, if I wanted to, say, change V+ from pin 1 to pin 2, I physically disconnect the BNC from pin 1 and attach it to pin 2.

What I hope to do:

I would like to be able to assign roles to these pins programmatically. I have an Arduino Uno and a bunch of Magnecraft W171DIP-2 reed relays.

How I hope to do it

I am naively thinking of a scheme like this (simplified to a case of 3 pins (nodes here) and one source (CCCS1 here) rather than 12 pins and 2 "sources") (the switches "SW#" would be digital outputs of the Arduino): (sorry for the mess--I'm not experienced drawing this kind of thing)

Model of reed relay network

I would need to get some I/O expanders and/or a different microcontroller (Seeeduino Mega?) to have enough pins (I would need 48 relays to do 12 pins and 2 "sources" this way).

Now, here's my question: Is there some awesome way I can simplify this circuit? I'm not good with electronics so maybe I'm missing an obviously better approach? Or maybe there exists some IC that would bundle the functionality of a bunch of relays into one cheap, tidy package?

Thanks a lot in advance!! Criticize away! (so long as you then tell me how to do it right!)

Brian

\$\endgroup\$
6
  • \$\begingroup\$ What is the range of voltages and currents we're talking about here? Within certain limits, it could be done with ICs; otherwise, you'll need the relays -- but we can talk about ways to simplify their control. \$\endgroup\$
    – Dave Tweed
    Commented Sep 16, 2012 at 4:06
  • \$\begingroup\$ Typically less than 1 mA and less than 5 V (usually much less) but maybe say 100 mA and 100 V to cover all bases? \$\endgroup\$
    – BASnappl
    Commented Sep 16, 2012 at 5:14
  • \$\begingroup\$ 5V/1mA would be within the capabilities of analog multiplexer chips; 100V/100mA definitely requires the relays. \$\endgroup\$
    – Dave Tweed
    Commented Sep 16, 2012 at 11:04
  • \$\begingroup\$ Why are you powering the relay coils with your current source? I think you just want to use the arduino output pins, Vdd, and GND for the coils. When RLY1 is closed and Pin 1 is connected to one end of the current source, what is the return path for the current? How does the current get back from the instrument to the source? Through the ground? If you have a voltmeter, why would you want to connect V- to a pin rather than leaving it connected to ground all of the time and just connecting V+ to a pin? \$\endgroup\$
    – Joe Hass
    Commented Sep 16, 2012 at 17:26
  • \$\begingroup\$ Hey Joe. I am powering the relay coils from the Arduino digital output pins (SW# in the schematic). In the schematic, the relays on the right connect any node to I+ and the relays on the left connect to I-. I don't want V-=ground since I will be doing 4pt measurements on a device to eliminate contact resistance. If V- was ground, one of the contacts would contribute to the voltage drop. \$\endgroup\$
    – BASnappl
    Commented Sep 16, 2012 at 19:20

3 Answers 3

3
\$\begingroup\$

first:

the relays you've got can't wired directly to a arduino.

the data sheet isn't doesn't tell what current it draws / peek current not even the coil resistance or the build in resistor in series with the coil.

outgoing form the average power consumption of the coil divided by the max arduino output voltage delivers the lowest average current

P = V * I ==> I = P / U --> I = .29W / 5V = 58mA

the maximum current drawn or shucked to a IO is generally ± 25mA
the absolute maximum generally ±40 - 50mA

maybe the arduino survives the current of 58mA but it can die,
here you can find more info about not exceeding the max current.

also always put a diode across the relay coil to prevent frying the micro controller from the reverse voltage spikes coils generate when they are unloaded

it is not deadly if you don't put the diode, because the arduino outputs are push-pull; which means that that a output is shorted 5V (high) or shorted to gnd(0V) (low). So the coil is never be unloaded / floating. (but for transistors is it needed).

relay diode

something like this, the transistor can handle more current than a relay. the 12V in your case can variate between 5V and 24V.

the transistor type can be any type where

  • max Vce higher is than the supply voltage (the 5 to 24V) (almost any common transistor is can handle that)
  • max IC is higher than 100mA
  • max Power doesn't care because the transistor will act like a switch

by example the BC547B is an excellent very common transistor and has a gain (HFE) about 200 - 250.

the resistor value can be calculated with ohms law.

R = V / I

  • V = (5V -.07V) 5V is the max output voltage of the arduino, 0.7V is the voltage drop in the BE of the transistor.
  • I = Ic / HFe
    • IC = the max current drawn by the relay the previous maths says 58mA but I 'm not sure if more or less. thus i take 100mA
    • HFe is the HFe of the transistor 200

I = 100mA / 200 = .5mA = 500μA

R = 5V / 500μA = 10kΩ

important

the HFe is very dependent from time, temperature, even the collector current and base current may affect the HFe.

so to be sure mostly the resistor value is divided by 2 or more.

but because we've taken the current almost twice as high, and the minimum HFe (the BC547b's HFe is between 200 and 450) and it is not a disaster is the transistor is not fully saturated but maybe 90% (VCE about 1V in stead of 0.3V) and 10kΩ a very common resistor we can take 10kΩ but if you want to be really safe, you can take a 5.6kΩ or less.

Second:

multiplexing

there are several ways to multiplex
very common is matrixing:

matrix

just replace every led by a relay

how it works

first select a column than the row

the image is for demonstrating only, don't care about pin numbers

connect each column pin and row trough a transistor / transistor chip to the arduino if you want 48 relays then a 6 by 8 matrix may do the trick

there exist ICs that can do something similar

More IO

  1. there exist io expanders over I2C or SPI
    with a lot of libraries for arduino

    generally a io expander acts like a io on the arduino and can handle about the same current maybe more or less

  2. bcd to decimal converts a binary number to a single high output

    the 74HC42 (by example) can do this
    I don't know if there exist a library for a arduino. but if necessary, I can write you a code example that works (or a library is also possible)

    1. shift registers explained on the arduino site shiftout()

      the 74hc595 can do this
\$\endgroup\$
1
  • \$\begingroup\$ Thanks for all the information! I've got to read up about all this. \$\endgroup\$
    – BASnappl
    Commented Sep 17, 2012 at 0:25
1
\$\begingroup\$

4 switching to any of 15 will require 60 relays and 60 control lines.

If you had relays with normally open and normally closed contacts you would need just 16 control lines, but still 60 relays.

If you had relays with 8 poles 8nc 8no, you would need just 16 relays and 16 control lines.

\$\endgroup\$
1
  • \$\begingroup\$ Hello, Thanks for the response. 3 of the pics on the DA-15 aren't connected to anything so there's only 12 pins that need to be connected (hence 48 relays). Could you explain your suggestion a bit more? I'm not sure I follow. \$\endgroup\$
    – BASnappl
    Commented Sep 16, 2012 at 16:58
1
\$\begingroup\$

Since you talk about having 12 BNC jacks I will assume that you always connect both I- and I+ to the same jack, and you always connect V+ and V- to the same jack. So, from the Arduino's perspective you want to control a 1:12 selector for the current source and a separate 12:1 multiplexer for the voltmeter (not 4-to-48 switching matrix). This can't possibly require more than 24 control outputs from the processor, but each output will control two relays (for the + and one for the - connections of the source/voltmeter). If, as I assume, the connections are mutually exclusive (you won't connect the current source to two BNC jacks at the same time), then you could multiplex the relays and use 7 outputs (say 3 rows and 4 columns) to turn on one of 12 pairs of relays at any given time. This takes a little more code, but it's a very common practice for driving arrays of LEDs, just replace each LED with the coils of two relays in parallel. Now you are down to 14 total outputs.

Note that you will probably need some transistors to switch enough current for the relay coils...it looks like they need tens of milliamps. If you had DPST relays you could use half as many, and probably reduce the current required to drive the coils.

\$\endgroup\$
5
  • \$\begingroup\$ Hmmm... I'm looking into these multiplexers and selectors. I'm not familiar with them. Also, the coil resistance here is 500 Ohm at 5V, so 10mA for the coil which Arduino can supply. \$\endgroup\$
    – BASnappl
    Commented Sep 16, 2012 at 16:55
  • \$\begingroup\$ Also, what about Dave's comment suggesting that the current and voltage requirements here might require relays instead of multiplexers? \$\endgroup\$
    – BASnappl
    Commented Sep 16, 2012 at 17:00
  • \$\begingroup\$ Sorry, I should have been more specific. A selector takes in some number N and asserts (activates) its Nth output signal while all of the others are inactive. A multiplexer selects the Nth input and connects it to the output. As for the matrix idea, just google "LED Matrix Arduino" and you'll get lots of information. \$\endgroup\$
    – Joe Hass
    Commented Sep 16, 2012 at 17:04
  • \$\begingroup\$ You don't actually need a chip or device that is a multiplexer, the combination of the arduino and the relays effectively forms a multiplexer. This just means that you somehow give the arduino a number between 1 and 12 (or 0 and 11) and the arduino activates the relays so that one (and only one) of your instrument pins is connected to the voltmeter. \$\endgroup\$
    – Joe Hass
    Commented Sep 16, 2012 at 17:06
  • \$\begingroup\$ OK, I've looked at your schematic more carefully and I am confused. Maybe you really are trying to control 48 distinct relays in two groups of 24 (which can be done with 20 arduino outputs). See my questions above. \$\endgroup\$
    – Joe Hass
    Commented Sep 16, 2012 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.