Pages: [1]   Go Down
Author Topic: Help with PCF8574 port expander and relay  (Read 1798 times)
0 Members and 1 Guest are viewing this topic.
Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anyone point me to an example of a PCF8574 port expander circuit that controls a number of relays with a coil of 5 volts.  I can get the arduino to control an led without a problem but not a relay.  I'm sure it is because the PCF8574 doesnt have enough juice to activate the coil.
Any help or advise would be greatly appreciated.
Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 668
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Playground has a lot of examples how to connect all kinds of stuff.

http://arduino.cc/playground/uploads/Main/relays.pdf

In this example it's assumed the relay is driven by an arduino pin, but you could drive it with an output of the PCF8574 as well.
Logged

Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Kind of tried that circuit, but probably did something wrong and didn't have the exact components.  Couple guestion I have is what is all the stuff to the right of the diode, and will this work with these parts with the PCF8574?  Or would it need to be modified?  If it will work I'll order the exact parts right now.
« Last Edit: April 17, 2011, 04:06:58 pm by k3v1np » Logged

Netherlands
Offline Offline
God Member
*****
Karma: 7
Posts: 668
A naughty mind is a joy forever.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's the relay.

The relay in the circuit is just an... example, many different types exist.
The magnetic coil is connected at "1 & 16" in this circuit. (which may be different on other relays).

At the right side S1, O1 and P1 are connectors of the switch inside the relay.
These may also differ on other relays.

There shouldn't be a difference whether you use an arduino-pin or an output-pin of the pcf8574.
Both drive their pins with 0 or 5 volts.


Logged

Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was able to get the example circuit below to work off the arduino pin but not a pin off the PCF8574.



I'm able to blink an LED from a pin off the the PCF8574 by connecting it like this ...

+5 ------- (+)LED(-) ------330 ohm Resistor-------- PCF8574 P0 pin 4

Using the following code ...

Code:
#include <Wire.h>

#define expander 0x20 //expander address with 3 address pins grounded

void setup() {
  Wire.begin();
}

void loop() {
  expanderWrite(B11111111); //turn all ports high
  delay(1000);
  expanderWrite(B00000000); //turn all ports low
  delay(1000);
}


void expanderWrite(byte _data ) {
  Wire.beginTransmission(expander);
  Wire.send(_data);
  Wire.endTransmission();
}
 

I think I understand why its working this way, but please someone correct me if I'm wrong.  When the arduino turns an i/o port high it is sourced to positive and when the PCF8574 turns the i/o port high it sinks it to ground.  (hope my terminology is correct as well). 
If my thinking is correct then what do I need to change in order to get the relay circuit above to work with the PCF8574?
Logged

Pages: [1]   Go Up
Jump to: