Expanding Output using BS2P24 and the PCF8574
G McMurry
Posts: 134
in BASIC Stamp
I just would like to have 8 additional outputs on my current BS2P24 project.
I have the PCF8574 Data pin attached to P8 and Clk pin to P9.
The PCF8574 is tied as Address 000 (Pin 1,2 and 3 are gnd)
From what I read, I should only have to send one I2COut command.
Such as:
I2COUT 8,64,[Value]
Where: 8 is the Data Pin (9 then the clk pin by default)
Where: 64 sets the PCF8574 to SlaveID 00 and sets R/W to 0 for Write "01000000"
Where: [Value] is the variable that I would like sent to the PCF8574 8-bit output port.
I wouldn't be writing here if it seemed to work... It doesn't seem to work
I have a V1.5 BS2P24
I believe the output pins of the PCF8574 are open drain so therefore need pullup resistors, correct?
Should I be able to perform this function with only the 3 arguments following I2COUT? Pin, SlaveID-R/W, and Data?
As usual I am always grateful and hopeful for help on this forum.
Greg
I have the PCF8574 Data pin attached to P8 and Clk pin to P9.
The PCF8574 is tied as Address 000 (Pin 1,2 and 3 are gnd)
From what I read, I should only have to send one I2COut command.
Such as:
I2COUT 8,64,[Value]
Where: 8 is the Data Pin (9 then the clk pin by default)
Where: 64 sets the PCF8574 to SlaveID 00 and sets R/W to 0 for Write "01000000"
Where: [Value] is the variable that I would like sent to the PCF8574 8-bit output port.
I wouldn't be writing here if it seemed to work... It doesn't seem to work
I have a V1.5 BS2P24
I believe the output pins of the PCF8574 are open drain so therefore need pullup resistors, correct?
Should I be able to perform this function with only the 3 arguments following I2COUT? Pin, SlaveID-R/W, and Data?
As usual I am always grateful and hopeful for help on this forum.
Greg
Comments
Thought I would add a schematic
Its a subroutine within an already working piece of code.
Do_Relays:
I2C_Relay = 0 'Start with I2C_Relay variable at Zero
IF Nemostring(5) & 001 THEN I2C_Relay = I2C_Relay | 001 'Relay 1 Lights
IF NemoString(5) & 002 THEN I2C_Relay = I2C_Relay | 002 'Relay 2 Stop
IF NemoString(4) & 001 THEN I2C_Relay = I2C_Relay | 004 'Relay 3 Ignition
IF NemoString(4) & 008 THEN I2C_Relay = I2C_Relay | 008 'Relay 4 Horn
I2COUT GAIO1,64,[I2C_Relay] 'Pin, Address, [variable]
RETURN
Basically, I have a serial string "Nemostring(x)" that gets bit checked so I can build a variable called "I2C_Relay" using the OR(|) operator. I use this technique elsewhere to build an output variables and it has always works for me.
I can see both SDA and SCK toggling with my O-Scope, so I know something is happening.
I am just wondering if talking to the PCF8574 is as simple as I have assumed? (pin,SlaveID, variable). My PCF8574 outputs don't seem to change.
Greg
I'll give it some closer examination.
Greg
Messed around with it again, and now it is working fine. My mistake was really stupid. Lets just say there was a problem with the PCF8574.
But I do use 4.k pullup resistors on SDA and SCL. They are at the source.
I added pullup resistors to the inputs of the ULN but I was pretty sure it would have worked without them. Since then I build another unit using the same PCB and with no pullups on the ULN, all the relays are clicking away. The scope shows a 0 - 3.3 v voltage swing. I think it is OK without pullups.
I have an unusual way of notating pullups on my schematics. The little arrows pointing upward. Not sure where I started using these, but someone taught me many moons ago and I still do it.
Thanks everyone for the comments. I wanted to close this out as perhaps someone else can use the information here and I am sure they would like to know that it does work.
Greg