Go Down

Topic: PCF8574AN configured as output for relay (Read 1 time) previous topic - next topic

Midway

Feb 14, 2013, 10:17 pm Last Edit: Feb 14, 2013, 10:21 pm by Midway Reason: 1

i use the output P0/P1/P2 ect... to switch independent the output, a relay and must stay ON untill this is asking in some code to switch it OFF.

for the test i made this example, but it will not work good, it is like flashing loop light.



any software example help would be great.

Code: [Select]
/*
PCF adress = 0x38

configured as output to control the relay

*/

#define PCF2_output 0x38          // (Relay) PCF8574AN, Address 0x38 with A0-A1-A2 pins grounded.
#include <Wire.h>

void setup()
{
 Wire.begin();
 Serial.begin(9600);
}
void loop()
{
 Wire.beginTransmission(PCF2_output);
 Wire.write(254);                     // turn relay 1 on (P0)
 Wire.endTransmission();
 Serial.print("Relay 1: ");
 Serial.println(HEX);
 
delay(1500);

 Wire.beginTransmission(PCF2_output);
 Wire.write(253);                      // turn relay 2 on (P1)
 Wire.endTransmission();
 Serial.print("Relay 2: ");
 Serial.println(HEX);
 
 delay(1500);
 
 Wire.beginTransmission(PCF2_output);
 Wire.write(251);                      // turn relay 3 on (P2)
 Wire.endTransmission();
 Serial.print("Relay 3: ");
 Serial.println(HEX);
 
delay(1500);
}




Grumpy_Mike

You can only sink 25mA of current on an output how have you got your relay wired? Have you used a transistor to drive it. There is probably not enough current to hold your relay in if you have wired it directly.

Midway

#2
Feb 14, 2013, 10:31 pm Last Edit: Feb 14, 2013, 10:44 pm by Midway Reason: 1
i am just test it now with some LED (20mA), and this is also not working!

dont worry the relay wiring, this is drived by some transistor, and or optocouplers ect ect,,,,

it is just the software what is not working fine.

Grumpy_Mike

Quote
it is just the software what is not working fine.

It looks fine to me.

Have you got pull up resistors?
Are you using the analogue pins 4 & 5 not the digital ones?
Have you got the anode of the LED connected to 5V, cathode to a resistor and resistor to the PCF output pin?

Midway

#4
Feb 14, 2013, 11:28 pm Last Edit: Feb 14, 2013, 11:42 pm by Midway Reason: 1
Quote
Have you got pull up resistors?

yes, offcourse.

Quote
Are you using the analogue pins 4 & 5 not the digital ones?

Im use on the arduino uno the pins located near the reset button, marked with SDA/SCL. so not use pin 3 and 4.

Quote
Have you got the anode of the LED connected to 5V, cathode to a resistor and resistor to the PCF output pin?

yes, i hope the attachment is here u can see the diagram i quickly made.

i have also tried some other LED's with same voltage and less mA. but same result.

Go Up