Shop OBEX P1 Docs P2 Docs Learn Events
Driving 256 Relays??? — Parallax Forums

Driving 256 Relays???

CassLanCassLan Posts: 586
edited 2009-07-12 10:17 in Propeller 1
Hi all,
I'm finding great ideas for the propeller with my work.
I need to drive 256 relays....and listen to 256 inputs....I'm a bit stumped on how to go about this. Luckily I have some budget to work with.
Any ideas would be appreciated.

Rick

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Prop Forum Search (Via Google)
«1

Comments

  • BeanBean Posts: 8,129
    edited 2009-07-09 21:18
    Are the relays independant or only activated one at a time ?
    Same with the inputs...Will only 1 input be active at a time ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    The needy are many, the deserving are few.

    ·
  • CassLanCassLan Posts: 586
    edited 2009-07-09 21:20
    The relays will only be active one at a time, the inputs may have 1 or 2 active at a time.

    Rick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Prop Forum Search (Via Google)
  • TimmooreTimmoore Posts: 1,031
    edited 2009-07-09 21:24
    Look at 74XX595 for output, you can chain mutiple together for as many outputs as you need. There are objects in obex for it.
    For input what about 74xx4067, connect 1 to the prop, connect 16 to each of the 1st inputs and you have 256 inputs. Need 8 pins to drive the multiplex control and 1 pin for reading the input
  • CassLanCassLan Posts: 586
    edited 2009-07-09 21:35
    Thanks Timmoore, I've thought about that approach..does chaining that many chips together work?
    I've never done something like that before.

    Rick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Prop Forum Search (Via Google)
  • TimmooreTimmoore Posts: 1,031
    edited 2009-07-09 21:45
    I think the max I have tried in a chain is 4. I dont see anything to stop you chaining much longer apart from update time, the longer the chain the longer it takes you to change 1 output. The driver I wrote in theory can support 32 in a chain but I have't tried it. There is nothing to stop you having multiple chains, e.g. you 4 data out pins with 4 595 chains, the clock etc can be paralleled on the same pins.
  • CassLanCassLan Posts: 586
    edited 2009-07-09 21:48
    OK Well I'll give it a shot...gonna be one hell of a breadboard setup [noparse]:)[/noparse]

    Just for the record...have you ever heard of a 256 bit IO expander?

    Rick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Prop Forum Search (Via Google)
  • TrapperBobTrapperBob Posts: 142
    edited 2009-07-09 21:55
    CassLan,

    Have you thought of using a·FPGA or multiple smaller CPLDs to implement this? I guess it would depend on how much other logic you need to incorporate to make it cost efficient!· It would be much better from a reliability standpoint than large numbers of 595s.

    TrapperBob
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-09 22:01
    > I need to drive 256 relays....and listen to 256 inputs

    That almost sounds like ... ModBus! smile.gif

    I'm currently writing a ModBus-interface.
    The hardware is quite simple: For the outputs, I'm using 74HC595 + OC + transistors to drive the coils
    For input, I have 74HC166 + OC. Each in/out bit has a indicator-LED.

    I have split the in/out into 4 "ports". Each port should be able to drive about 10 "cards". Each card has 16 INs or 16 OUTs. To each port, only one kind of cards can be connected (either INs *or* OUTs).
    Until now, 4 cards per port are tested (don't have more). That thing was (without the complicated mapping I do) reasonably fast. From the last bit I got over the RS232 to completed execution 64µs (with 64 outputs). Could do that a bit faster. smile.gif

    Currently, I'm implementing a quite complex mapping of coil-numbers, inputs and registers to physical inputs/outputs/RAM/EEPROM. Works, except for the unusual configurations with registers. Registers can be mapped to IO-Memory, to RAM or to EEPROM (EEPROM is missing 2 simple functions).
    Responses including error-handling are currently implemented to get the right pattern for the code (CRC-checking, parameter checking, range checking).

    I initially wrote it in SPIN and had a response-time of 2ms for 64 bits. In C, I got it about 7 times faster. Don't have the current numbers at hand with all the responses.

    Shifting data in or out is written in assembler.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-07-09 22:17
    Rick,

    If only one relay is on at a time, you can save chips by arranging them in a 16x16 array. You would need two 74HCT595s for the column and two for the rows. The columns would need 16 high-side drivers; the rows, 16 lowside drivers. It's just like driving an LED matrix, but with relays instead. If you were to use solid-state relays, you could dispense with the coil drivers and switch them directly from the '595s.

    -Phil
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-07-09 22:49
    How many Props exactly will it take to do this??

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Toys are microcontroled.
    Robots are microcontroled.
    I am microcontroled.



    If it's not Parallax then don't even bother. :-)
    ·

    Mini-Din/PS2 connectors are for sale! 5 for $1! PM me if you wish to make an order.
    Cheap·shipping unless specified!··········150 left!!··


  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-09 22:57
    > How many Props exactly will it take to do this??

    Exactly one. Like with allmost any other µC.


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-07-09 22:59
    Wow, I have not yet learned the Black Art of Matrix programming. smile.gif

    Sounds like an impressive project!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Toys are microcontroled.
    Robots are microcontroled.
    I am microcontroled.



    If it's not Parallax then don't even bother. :-)
    ·

    Mini-Din/PS2 connectors are for sale! 5 for $1! PM me if you wish to make an order.
    Cheap·shipping unless specified!··········150 left!!··


  • kwinnkwinn Posts: 8,697
    edited 2009-07-09 23:28
    microcontrolled, take a look at this post. The link will take you to page 21 of the post.

    http://forums.parallax.com/forums/?f=15&m=324351&g=366101#m366101

    This project is more complicated than what your application requires since any arbitrary number of relays may need to be activated at once. In an application where relays needs to be activated only one at a time one prop, 2 8 bit low side latch/drivers and 2 8 bit high side latch/drivers are needed.
  • RaymanRayman Posts: 14,844
    edited 2009-07-09 23:36
    I wonder if this I2C PWM LED controller would work...

    [url=http://www.nxp.com/#/pip/pip=[pip=PCA9685_1]|pp=[t=pip,i=PCA9685_1]http://www.nxp.com/#/pip/pip=[noparse]pp=[noparse][[/noparse]t=pip,i=PCA9685_1[/url|



    It has 16 channels and a programmable frequency...

    Plus, you'd have an LED indication for each servo...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • kwinnkwinn Posts: 8,697
    edited 2009-07-10 01:13
    Two 74HC154 4 to 16 line decoders with 32 drive transistors would also work and need 8/9 prop I/O pins. One 74HC154, 32 transistors and 20 pins is another option.
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-07-10 02:41
    For GPIO expansion for relay driving or input reading, you could consider the many I2C GPIO ICs available. I have specifically used the PCA9555, which is 16 bit. You can arrange to have up to eight devices on the bus if I am not mistaken. Therefore, you could use two buses (three or four I/O pins depending on how clever you want to be) to have a total of 16 ICs with 16 inputs or outputs each.

    [url=http://www.nxp.com/#/pip/pip=[pip=PCA9555_7]|pp=[t=pip,i=PCA9555_7]]www.nxp.com/#/pip/pip=[noparse][[/noparse]pip=PCA9555_7]|pp=[noparse][[/noparse]t=pip,i=PCA9555_7][/url]

    Are all these I/Os on one PCB or spread around an installation? If they are spread around an installation, then perhaps you develop a low cost board that speaks RS-485 or Modbus or similar protocol. This low cost board would have x inputs and y outputs. The Propeller would be on the "master" board and process the system I/O and speak to the daughter I/O cards. This solution may be more elegant because of flexibility, but it will be more costly in hardware and development effort.

    Can you tell us more about the application?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-07-10 02:55
    The simplest solution is also very cheap and that is to use TPIC6C596 chips which are basically 595 shift registers with open-drain outputs which can drive loads up to 33V @200ma or more. As open-drain transistors they also do not need a diode across the coil. Using the matrix idea suggested since you only need one relay on (sounds a little strange) you would drive 8 PNP or P channel MOSFETs from one device and use 4 other chips to drive the low-side of the relays. Of course you could do it with 4 chips but you would need 8 extra transistors and the 5-chip 8 transistor solution is much better.

    *Peter*
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-07-10 02:58
    As for the 256 inputs they could also be scanned in a matrix if you had access to both sides of the contact if that's what they are. If you are stuck with 256 input "signals" then you probably need 32 parallel input shift registers but what a wiring mess. Perhaps you could elaborate on your application because there might be a simpler solution again.

    *Peter*
  • kwinnkwinn Posts: 8,697
    edited 2009-07-10 03:25
    microcontrolled, Timmoores idea of using 16 74xx4067's is probably the best idea if the signals are low voltage and current. Certainly cheaper and easier to lay out than 256 relays and all the drivers. The prop could use 16 pins to select 1 of 16 chips and 4 pins to address 1 of the 16 inputs. If you want to conserve prop pins you could use 4 pins and a 74xx154 as a chip select.

    The outputs could all be connected in parallel to go to an amplifier or whatever circuit you need, although I would put a small resistor between each output and the common signal line.

    Total cost of the chips including the prop $20.00 to $40.00 before taxes depending on package used.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2009-07-10 03:29
    Using TPIC shift registers in a matrix means you can drive 24V coils easily and you only need 5 chips, 8 transistors, and 4 pins (CLK, DAT, LOAD_SOURCE, LOAD_SINK).

    *Peter*

    Total cost is under $10 at one-off prices.
  • CassLanCassLan Posts: 586
    edited 2009-07-10 10:13
    Thanks everyone for the responses.

    The application is an intercom controller for a residential apartment building.

    The current "controller" is a HUGE brass plate (~33"x20") with 212 buttons, 212 LEDs & 212 Relays, each of these was soldered by hand (not by me)...there is also a pretty big ratsnest as well.

    Each apartment has 2 wires going to it, 1 being a common shared by all apartments I'm pretty sure.
    Operation:
    When the apartment handset lifts off the cradle (The equivalent of shorting the 2 apartment wires), at the Front Desk -> that particular apartments LED lights up, and a buzzer is sounded.
    The person on duty at the front desk pushes the button for that apartment (I believe activating that apts relay), then lifts his handset (which is also a switch) and voila! They are speaking.

    When the Front desk wants to call an apt, he pushes that apts button, lifts his handset and pushes a spring loaded button to ring the apt. When the apts handset is lifted up..voila! They are speaking.

    The kicker is that the original manufacturer does not have a moderized version of this, only the same huge plate as described above.
    I figure·I can make something much better, and then I have a solution in the can for future use.
    I can't wait to hook them up with an LCD which will display which apartment is calling, allow them to scroll through recent calls, display the time...etc.
    I'd like to design for 256 apts·incase I have a need for this in the future (and keep the design to where I could double that # if needed as well).
    I want to fit this new product (at least the part that you can see) within an area of 8" x 11"; That including handset, LCD Display and buttons.

    I'm thinking as far as connecting all the wires to the system that I would use·66 or 110·punch blocks that are pre-wired to·50 pin connectors, all the apts connect to the blocks and 50 wire cables go to the system board.

    You think this will be the first propeller based intercom controller?

    Rick


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Prop Forum Search (Via Google)
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-10 10:38
    > I'd like to design for 256 apts incase I have a need for this in the future (and keep the design to where I could double that # if needed as well).

    Then the matrix (as described by Peter J.) is the right way to go. With TTL-compatibe relais, you don't even need powerful drivers. But 256 of them might ... oh! you will get a volume discount. smile.gif


    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • RaymanRayman Posts: 14,844
    edited 2009-07-10 11:38
    Oh, 256 relays!· Somehow, I·was thinking about·256 servos...
    CassLan said...


    I need to drive 256 relays....
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • WurlitzerWurlitzer Posts: 237
    edited 2009-07-10 12:47
    I use a bunch of Allegro (A6833) 32 bit shift register w/latch and open collector outputs ICs to scan over 400 inputs and over 2000 outputs (~~100ma coils) and just recently I am using the Prop to clock all the data in, process it, clock it out.

    These chips have been working for over 12 years (original DIP version) and only were killed by a lighting strike last year.

    With 32 outputs it does not take a lot of chips to handle large applications like you have.

    In my application any number of outputs can be on/off and any number of inputs can be on/off at any given time.
  • PaulPaul Posts: 263
    edited 2009-07-10 17:31
    I've driven 64 relays with 6 of the 74HC595 chips and ULN2803A relay drivers. The problem I ran into was the outputs come on high and ALL 48 relays latched at once. Nice current spike. I had to have the Stamp put the chips in tri-state mode as the very first operation. With the delay of loading the propeller from eeprom this may not be an option.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
  • Nick MuellerNick Mueller Posts: 815
    edited 2009-07-10 17:50
    That's why you need a pullup on the enable-pin of the '595.
    When the Prop is up and running, he first has to clear the registers and then enable them. There is *no* guarante what the latches contain after power up of the 595.

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • kwinnkwinn Posts: 8,697
    edited 2009-07-11 05:15
    With this being a phone type of system I am wondering if you could use triac optoisolators instead of relays. Phones usually operate at 48VDC and have a 600 ohm impedance which is a current of 80mA. Once the triac is conducting the continuous current through the phone should keep it conducting until someone breaks the circuit by hanging up.
  • CassLanCassLan Posts: 586
    edited 2009-07-11 13:40
    I'm going to do some lab testing on a smaller scale but these units dont adhere to typical phone standards.

    Rick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Prop Forum Search (Via Google)
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2009-07-11 13:53
    I think the main point is that there isn't any off-the-shelf microcontroller that provides 256 pins of I/O. Of course, 9 or 10 Propellers would provide you with 256 individual I/O pins and not be much more expensive. With 32 Propellers, you could have 256 cogs run your scheme and plenty of i/o. pins. In sum, the next best thing you can do is to exploit the Propeller's hight speed to achieve good results by finding the right parallel geometry.

    One question that will decide much of your choice is exactly how many milliamps each relay will require and what will be the overall power requirements for having a full 256 relays in their ON condition.

    At 60millamp/220ohm/12volt relay coils; the 12 volt supply with be roughly 16 amps. I am not very clear what the 5 volt stage would require, but it should be worked out.

    Furthermore, there is only so much of this that can be done on a printed circuit board. From the UUNL2803 to the relays will likely be done by wire cable and require a rather ample housing to contain 256 relays. I'd recommend modular socketed relays that mount on an aluminum rail.

    Wurlitzer seems to be doing something with a pipe organ.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ain't gadetry a wonderful thing?

    aka G. Herzog [noparse][[/noparse] 黃鶴 ] in Taiwan

    Post Edited (Loopy Byteloose) : 7/11/2009 2:37:57 PM GMT
  • kwinnkwinn Posts: 8,697
    edited 2009-07-11 16:37
    Loopy, as CassLan mentioned earlier in the post only one relay at a time will be powered up so current demand will be very low. As for mounting the relays, there are several ways to approach that. Since most small relays have a snap on cover that goes over the base I would glue them upside down in an array and solder the wires directly to the relay pins.
Sign In or Register to comment.