Shop OBEX P1 Docs P2 Docs Learn Events
Expanding Output using BS2P24 and the PCF8574 — Parallax Forums

Expanding Output using BS2P24 and the PCF8574

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

Comments

  • PCF8574-to-BS2P24.jpg

    Thought I would add a schematic
  • Probably good to include the code that is not working. Might just be a typo.
  • Here is the actual code:

    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
  • Mike GreenMike Green Posts: 23,101
    edited 2016-02-14 19:13
    The PCF8574 is indeed pretty simple. The outputs have weak pullups on them so, when they're inputs, they can be used directly to sense switch closures. I think your problem is that the SDA and SCL lines (I/O pins 8 and 9) need pullups on them (4.7K to +5V should do). The I2CIN and I2COUT statements automatically set the R/W bit so you don't have to bother with it.
  • Thanks Mike,

    I'll give it some closer examination.

    Greg
  • Remember, too, that the ULN has pull-downs on the inputs; this may be affecting your circuit.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    I don't see the traditional 4.7K pull-up resistors on your SDA/SCL lines. Are these included outside the circuit shown?
  • G McMurryG McMurry Posts: 134
    edited 2016-03-07 00:54
    I got pulled away from this project.

    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
Sign In or Register to comment.