PDA

View Full Version : Driving 256 Relays???



CassLan
07-10-2009, 05:15 AM
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) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

Bean
07-10-2009, 05:18 AM
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.

·

CassLan
07-10-2009, 05:20 AM
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) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

Timmoore
07-10-2009, 05:24 AM
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

CassLan
07-10-2009, 05:35 AM
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) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

Timmoore
07-10-2009, 05:45 AM
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.

CassLan
07-10-2009, 05:48 AM
OK Well I'll give it a shot...gonna be one hell of a breadboard setup :)

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

Rick

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


Prop Forum Search (Via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

TrapperBob
07-10-2009, 05:55 AM
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 Mueller
07-10-2009, 06:01 AM
> I need to drive 256 relays....and listen to 256 inputs

That almost sounds like ... ModBus! http://forums.parallax.com/images/smilies/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. http://forums.parallax.com/images/smilies/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 (http://www.yadro.de)

Phil Pilgrim (PhiPi)
07-10-2009, 06:17 AM
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

Microcontrolled
07-10-2009, 06:49 AM
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 Mueller
07-10-2009, 06:57 AM
> 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 (http://www.yadro.de)

Microcontrolled
07-10-2009, 06:59 AM
Wow, I have not yet learned the Black Art of Matrix programming. http://forums.parallax.com/images/smilies/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!!··

kwinn
07-10-2009, 07:28 AM
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.

Rayman
07-10-2009, 07:36 AM
I wonder if this I2C PWM LED controller would work...

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



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

kwinn
07-10-2009, 09:13 AM
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. Swieter
07-10-2009, 10:41 AM
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.

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

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 (http://www.brilldea.com) - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
www.tdswieter.com (http://www.tdswieter.com)

Peter Jakacki
07-10-2009, 10:55 AM
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 Jakacki
07-10-2009, 10:58 AM
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*

kwinn
07-10-2009, 11:25 AM
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 Jakacki
07-10-2009, 11:29 AM
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.

CassLan
07-10-2009, 06:13 PM
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) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

Nick Mueller
07-10-2009, 06:38 PM
> 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. http://forums.parallax.com/images/smilies/smile.gif


Nick

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

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

Rayman
07-10-2009, 07:38 PM
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

Wurlitzer
07-10-2009, 08:47 PM
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.

Paul
07-11-2009, 01:31 AM
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 (http://propeller.wikispaces.com)

Nick Mueller
07-11-2009, 01:50 AM
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 (http://www.yadro.de)

kwinn
07-11-2009, 01:15 PM
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.

CassLan
07-11-2009, 09:40 PM
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) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)

Loopy Byteloose
07-11-2009, 09:53 PM
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 [ 黃鶴 ] in Taiwan

Post Edited (Loopy Byteloose) : 7/11/2009 2:37:57 PM GMT

kwinn
07-12-2009, 12:37 AM
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.

Loopy Byteloose
07-12-2009, 01:43 PM
We still seem to be ignoring the additional need for 256 inputs and any determination of a minimal processing speed. A BasicStamp or SX48 could handle 256 inputs and 256 outputs if lower turnaround speed were acceptable.

It might be necessary to allocate 8 cogs to a sub-group to get the kind of performance one expects. All these shift registers downgrade the response time due to the multiple shifts. One chain of 256 shifts would eat up at least 256 clock cycles. 80Mhz/256 = 312.5Khz response as the other 255 pins are waiting for the next round.

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

aka G. Herzog [ 黃鶴 ] in Taiwan

Nick Mueller
07-12-2009, 04:01 PM
@Loopy Byteloose
Even if it takes 1 µs per bit (with all the overhead) this would be roughly 0.25ms for 256 bits. Do you think that's too slow for a telephone application?

Nick

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

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

CassLan
07-12-2009, 06:17 PM
Hey Guys-

Its telephone-"esque" if I may say :)· Not using actual telephones at all, no "dialing" in the traditional sense.

Its a communication system which is currently driven by a person activating one of 212 relays by pushing one of 212 buttons. (It seems so barbaric to do it this way http://forums.parallax.com/images/smilies/lol.gif it makes me laugh every time I describe this)

Its a Many -> One situation. The "Many" can only·speak with the "One"..not each other.
I'm only in a position to change·the "One" side of the system.

Speed...not really anything to consider here accept in terms of writing the relay driving software on the prop.

Why use a prop instead of another MCU?

1) The savings...even the entire cost of the propeller chip ($8) is likely to be less than 100th of·one percent of the cost of the project, so saving any $$ on using another MCU doesn't make sense for me if I have to learn something else.
2) There is a video portion to this project, a display of which apt is being called..which apt is calling...last 10 calls...Display the time...etc. So right there the prop has me covered in a way that I don't think I'll be able to find with another MCU.
3) Even if there were 10 other MCUs that did what the prop does and they where all free, I would still use the prop. (Yeah...I'm a fanboy I guess...and I'm OK with that http://forums.parallax.com/images/smilies/tongue.gif)

Rick



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


Prop Forum Search (Via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)