Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I'm using an Arduino to control a PlayStation 2 Controller and microSD card over SPI. As usual, they share a MISO, SCLK, and MOSI pin. Each has their own slave select pin.

The PS2 controller's MISO line is an open collector output, so I would guess that I need a pullup resistor there. How can I isolate this from the other non-open collector MISO? If the non-OC device is active, won't the pullup resistor interfere with its non-OC MISO line?

Thanks,

Edit

I suppose I could use a non-inverting open collector buffer to convert the non-OC output to OC?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

The only difference between a "normal" and "open collector" (or "open drain") output is the addition of an extra transistor (or FET).

enter image description here

Adding an external transistor (with base current limiting resistor) to an output in such a fashion will make it an open-collector output. A single NPN transistor is probably cheaper than a non-inverting buffer if you only need to convert one output. If you are doing multiple outputs then a buffer (say an octal one) would be more sensible from both space and cost points of view.

EDIT

To The simple circuit above will be inverting. One way to make it non-inverting would be to use two transistors:

enter image description here

The first one is the equivalent of the open collector circuit above, which inverts. The second one is the same - open collector that inverts. A pull-up resistor on the first transistor lets it control the second transistor properly. The net effect is a non-inverted open collector conversion.

share|improve this answer
    
You read my mind; I was just about to buy a non-inverting hex buffer with open collector outputs. But, this makes much more sense. Thank you! –  Chris Laplante Sep 21 '11 at 20:33
    
Wait a second. On my non OC-output device, Won't I need an inverter between the IC Output and the transistor? That way, high transforms into high impedance, and low connects to ground. –  Chris Laplante Sep 21 '11 at 22:40
    
Hmmm... you may well have a point there. Guys... any "easy" way to convert that circuit so that it's non-inverting? –  Majenko - not Google Sep 21 '11 at 22:48
    
I suppose I could build an inverter with a few basic parts? –  Chris Laplante Sep 21 '11 at 22:50
    
Double the transistor up, so you have the output through a transistor to make it inverted OC, then a pull-up resistor, and another transistor, to invert it again? –  Majenko - not Google Sep 21 '11 at 22:54

The pull up resistor will appear as a load to either of the MISO pins when they are actively driving low. Obvoiusly, the open-collector output is designed to drive the pull up resistor when it pulls the line low.

It is quite possible that the non-open-collector is also capable of driving the resistor. When the output is driving high, there should be no issues, as the ouput will be at a level similar to the logic supply voltage, so the current through the resistor will be negligible. When the output is driven low, the current through the resistor is determined by the supply voltage and the resistor value so that i = v/R, where v ie the supply voltage and R is the resistor value. (I'm neglecting here, the fact that the low driven voltage will not be exactly zero.)

So, you should check to see if the output can drive the current needed by your pull-up resistor. This specification is commonly refered to as output low current, or IOL (the OL is often shown as a subscript). If so, you should be fine.

You can adjust the value of the pull-up if necessary. Higher value resistors will draw less power, lower resistor values will speed up the transition from low to high logic level for the open-collecotr driver. Keep in mind that the pull up resistor will only draw current when one of the outputs is driving low, which is only when one os the CS pins is pulled low and when a low level bit is being transmitted.

share|improve this answer
    
When the open-collector MISO is pulled low, won't the pullup resistor have no effect? It's when it goes into a state of high impedance that the pullup resistor pulls the line to high. –  Chris Laplante Sep 19 '11 at 13:43
1  
The resistor is "pulling up" on the line in either case. When the pin is to be driven low, the open collector driver must draw enough current through the resistor to cause the voltage across the resistor to approach the supply voltage, per Ohm's law. In essence, the open-collector output "pulls harder" than the resistor. When the line is in a high impedance state, or is being driven high by a non-open-collector driver, the resistor current draw will be negligible, again by Ohm's law, as there will be a negligible voltage drop across the resistor. –  B Pete Sep 19 '11 at 14:33
2  
@SimpleCoder: Another way of saying that is that the pull-up resistor will not probably appreciably affect the voltage on the pin when a device is trying to pull it low, but will affect the amount of current drawn from the supply; depending upon the total power budget, this excess current draw may be too trivial to worry about, or it may be enormous. –  supercat Sep 19 '11 at 18:00
    
@B Pete and @supercat: Thanks for the clarifications. In other words, as long as I have a huge resistor (1 mOhms?) I will be fine without the need for a buffer or other form of isolation? That way, the resistor will only noticeably (which, in my case, would be enough for the Arduino to recognize the pin as HIGH- 3.3V - 5V, I believe) pull up the line during high impedance. The huge resistance will prevent it from messing with LOW signals. –  Chris Laplante Sep 19 '11 at 18:38
3  
@SimpleCoder: If you're going to use a resistance of 1M or thereabouts (note: 1m is one thousandth of an ohm--probably not what you meant) be sure to check the leakage current specs for all devices attached to that pin. Also check the capacitance specs and be aware that a large resistor will not pull up the line very quickly. If the line has a total capacitance of 100pF, it will take about a 100us for a a 1M line to pull it high (50pF would be 50us, etc.) In some cases, a 1M pull-up may be reasonable, but at 3.3 volts, values between 3.3K and 33K would be more typical (for 5 volts, 4.7K-47K) –  supercat Sep 19 '11 at 18:51

It's unlcear exactly who the master is in your setup. You say the Arduino is controlling a PlayStation and a SD card, which implies the Arduino is the master and the others slaves. But, you also say they share MISO and MOSI "as ususual", although I don't know what you think usual is.

SPI is intended to have a single known fixed master. Unlike IIC, there is no official multi-master mode. All the slaves share the MISO and MOSI lines, but these are flipped for the master. The SPI bus lines are also intended to be fully driven, not passively pulled up. The master always drives SCK and MOSI, and the single selected slave drives MISO. Each slave also has it's own slave select line, of which only one at a time is driven by the master. Slaves therefore set their MISO outputs to high impedance when not selected and actively drive MISO both high and low when selected. There may be a weak pulldown on MISO just to keep it from floating when no slave is selected. Its data value at that time doesn't matter, but a floating digital signal is not good for other reasons.

So now you need to explain what you're really doing in this context. You say the PS2's MISO line is open collector. That by itself is already contrary to SPI, but we still don't know whether the PS2 is the master or one of the slaves. If you're trying to implement some kind of multi-master SPI system, you need to give a lot more details since that's outside what is normally called "SPI". Why can't your slaves drive MISO when selected and go high impedance when not selected? That would be the normal way to do things on SPI.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.