Unwanted “memory effect” on a bus with optocouplers

I'm working on a microcontroller driver for an equipment which can have up to 64 optically isolated digital inputs. The hardware was designed with an 8-bit bus in mind, so we have up to eight rows of 8 optocouplers arranged like this (TCMD4000 is a quad optocoupler chip with darlington transistor outputs):

Figure 1:

simulate this circuit – Schematic created using CircuitLab

The idea was to sequentially assert the control lines L1 to L8 low so the bus (bits or columns B1 to B8) can be read as a whole byte. While a Lx line is asserted low all the others should be held high so we guarantee no other opto row will interfere with the bus, for their transistors would theoretically be cut (Vc=Ve or Vc < Ve). That way a logic one on an outside input would turn the corresponding LED on and drive the bit on the bus low for the current selected row, with the bus logic level being inverted again by a 74LV240 between the resistors and the microcontroller (that way a logic "one" on the LEDs side is also perceived as a logic "one" at the microcontroller data port reading from the bus).

To make it easier to follow, consider just 1 bit; it is enough for the problem to show up:

Figure 2:

simulate this circuit

Using a frequency of 1kHz to change the asserted lines low (L1 to L8) we would reread the state of the same row at 125Hz. Initially I was asserting L1 low, read the row state and right away would assert L1 high again (this takes up only a few usec), so on the next 1kHz timer interrupt L2 would be asserted low and so on, but I was surprised to see that, when either opto on the same column is turned on, the voltage on B1 goes to 0.6V while the LED is on (low level, as expected) but instead of coming back to high (3.3V) it gets stuck forever at 1V when the LED is turned off and a Lx line is driven low (for simplicity I was using just two lines on my tests, L1 and L2). Note I said "forever" because the voltage at B1 never comes back high, even though no LED is ever turned on again, like a flip-flop that changed state (see figure below, where the yellow trace is the voltage at B1 and the green is the L1 line; the waveform underneath is the same but zoomed to show detail of B1 voltage waveform):

Figure 3:

Figure 4:

The only solution for that bit to go back high is to disconnect one of the involved transistors' collectors from the bus, which then restores the voltage B1 to 3.3V, with a time constant dictated by the 10K resistor, like shown below:

Figure 5:

Note however that while we switch the Lx lines high and low the time constant is many times greater than if L1 line is always held low (~320ms vs. 5ms):

Figure 6: opto response time with LED on and then off, with L1 always low:

That behaviour suggested me that by leaving the Lx lines asserted low until the next line time (1ms instead of the few usec required just for the state read) would give more time for the voltage at B1 to recover, and indeed it worked, with B1 not staying stuck at 1V after the LED was off. Nevertheless, I still don't understand completely these two things:

1 - why when an opto is "disabled" by pulling its emitter high it behaves like "freezing" the voltage at the level it was until the next opto is enabled by pulling its Lx line low (please refer back to figure 5, where it is noticeable this causes the time constant "expansion" if you compare with the case where you never take the Lx line high)

2 - why the "memory effect" happened (B1 staying halfway between low and high everytime L1 or L2 were asserted low, even though there was no more LED turned on anymore)

I hope I could make it a little clearer now! Sorry for the lack of information before, it was really hard to explain without these waveforms.

• I am having trouble following what you are doing. Would you have the same trouble if you were only working with one bit? If you could redraw the schematic for the one-bit case it might be easier to follow. – The Photon Dec 30 '13 at 22:57
• When you say you "assert L1 low", do you mean you have some other device that's not shown in your schematic that's able to apply a voltage to L1? When you say there are cases wher "an opto is turned on", what is turning it on? What is driving the LED side of the optocoupler(s)? – The Photon Dec 30 '13 at 22:59
• @ThePhoton I'm confused too, by language like "keeps at 1V forever each time ...", etc. – Kaz Dec 31 '13 at 2:22
• @Claudio It looks like you are observing the waveforms, perhaps with an oscilloscope. If you post the waveforms, and tell where in your circuit you're observing them, and what you were expecting it would make the question clearer. – Nick Alexeev Dec 31 '13 at 2:57
• Ok.. thanks for the observations. Like I said, I didn't have time to download the waveforms from the scope, but I'll do soon, next year! ;) hehe – Claudio Dec 31 '13 at 20:17