Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

I2C-to-parallel read/write question

2 posters

Go down  Message [Page 1 of 1]

1I2C-to-parallel read/write question Empty I2C-to-parallel read/write question Sun Jan 31, 2021 6:15 pm

mvandorp



Hi,

I have a circuit which uses a PCF8574 I2C to Parallel converter. Is use this for a keypad. I try to build this in SimulIDE

I use the I2C-to-Parallel component
I connect D0-D3 to the rows of my Keypad
I connect D4-D6 to the columns of my keypad
I configure the Control Code to be 32 (=0x20), the default address for PCF8574
A0-A2 are tied to ground.

Now I setup the device by writing 0xF0, making my rows logically 0. As per PCF8574, lines programmed HIGH are inputs (floating).

Because this device does not have an interrupt output, I created one using diode-logic, tying the cathode of 3 diodes each to one of the column lines, and the anodes to the interrupt pin of the Arduino (using a pullup resistor).

When I start the module (I use the PCF8574 library by Rob Tillaart because it is low level and very straightforward), I can see the rows being low, and the columns being high (animation is on). The interrupt is also high.

When I push a key on the keypad, the corresponding column goes low. This triggers an interrupt

So far, so good.

In my interrupt routine, I read the output of the PCF8574. I would expect all rows low, and two columns high and one low (the column with the pressed key).

However, I always get the value '0', but I would expect 96, 140 or 192 (the values with exactly 2 bits high).

When I search this site for info about the I2C-to-Parallel converter, something is mentioned about reading and writing to different addresses.

I do not quite understand that explanation; why would you be reading back from a different address (= a different device)?

When I upload my code to real hardware with a PCF8574, it works as expected.

The question is, how do I use the I2C-to-Parallel converter to emulate a PCF8574? It appears that writing is working okay, but reading back is somehow wrong.

Looking forward to any reply. Pointers to more info are also very welcome!

Regards,

Marcel

2I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Sun Jan 31, 2021 6:57 pm

arcachofo

arcachofo

The question is, how do I use the I2C-to-Parallel converter to emulate a PCF8574?
Not possible at the moment.
By now it only can work as output, indeed this doesn't need much work to be finished.
I will try to get it working.

3I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Sun Jan 31, 2021 7:44 pm

arcachofo

arcachofo

It should be working now (not tested).

trunk rev 104 or 0.4.14 rev 36.

4I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Sun Jan 31, 2021 9:55 pm

mvandorp



Wow! Almost instant feature requests! I am very pleased this can be done so quickly!

I will test tomorrow, after updating to the latest version, and give you feedback.

Thanks!

Marcel

5I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 10:20 am

mvandorp



I just downloaded the latest trunk (rev104), and compiled it.

Everything is built correctly, and I am able to load my circuit.

When I start the code (animation is on), I see all outputs remain high. I expected the row outputs to switch to low.

When I open the same circuit and firmware in trunk rev13 (the version I used previously), The row outputs go low.

I verified the properties of the I2C-to-Parallel module. Apart from the new layout (nice!) I still see the code byte to be 32 in both cases.

Propagation time is different though (was 1666ns, now 250000ps)

Regards,

Marcel

6I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 10:49 am

arcachofo

arcachofo

When I start the code (animation is on), I see all outputs remain high. I expected the row outputs to switch to low.
Yes, now the outputs are "quasi-bidirectional" and they are high at power on.
Before output were normal only outputs.

Propagation time is different though (was 1666ns, now 250000ps)
There is still some work to to do with this.
But this should not prevent it to work.

7I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 11:21 am

mvandorp



arcachofo wrote:
When I start the code (animation is on), I see all outputs remain high. I expected the row outputs to switch to low.
Yes, now the outputs are "quasi-bidirectional" and they are high at power on.
Before output were normal only outputs.


Propagation time is different though (was 1666ns, now 250000ps)
There is still some work to to do with this.
But this should not prevent it to work.

But in the initialization part of my code I output 0xF0, which should make D0..D3 low and D4..D7 floating high (which can be pulled low by an external signal). That is not happening in rev105, while it did work in rev13.


When you look at it from an electrical perspective:
Output a 0 will pull the pin low (low impedance)
Output a 1 will make the pin float high (high impedance)

As an input pin: A high pin can be pulled low, a low pin cannot be forced high

Reading the pins should give me the state of all pins; low output pins return 0, high output pins can return 1 or 0, depending on the external signal (effectively making it an input pin)


But I cannot make an output pin go low.



8I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 11:55 am

arcachofo

arcachofo

But in the initialization part of my code I output 0xF0, which should make D0..D3 low and D4..D7 floating high (which can be pulled low by an external signal). That is not happening in rev105, while it did work in rev13.
Ok, now I understand.

Should be solved in rev 105.

9I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 3:46 pm

mvandorp



Well, I'm using bazaar now too. Makes this kind of testing much more convenient Cool

I tried the latest version, and the I2C-to-Parallel component seems to work like a real PCF8574 (though i needed to add the IRQ output myself, as described earlier)

Thanks a lot, arcachofo, I appreciate your swift responses!

Marcel

10I2C-to-parallel read/write question Empty Re: I2C-to-parallel read/write question Mon Feb 01, 2021 4:47 pm

arcachofo

arcachofo

though i needed to add the IRQ output myself, as described earlier
A PCF8574 model coulde be done with a subcircuit.
Using the I2CtoParallel component and adding the external interrupt logic (maybe just an open collector OR gate?).

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum