Connect with us

Open-collector

Discussion in 'Electronic Basics' started by Rafael Cunha de Almeida, Aug 31, 2009.

Scroll to continue with content
  1. Hello,

    I read a web page about ps/2 mouse and keyboard protocol [1] with the
    intention of doing a few experiments with my arduino board. I've found
    some code for arduino that implements a mouser driver and I could
    understand most of that web page. However, I didn't quite get the very
    first picture presented there [2] and what seems to be quite trivial
    component of electronics: open-collectors. I read a little more about
    it in the book ``Contemporary Logic Design'', but things still aren't
    all that clear.

    ``When the keyboard or mouse wants to send information, it first
    checks the Clock line to make sure it's at a high logic level.'' [1].
    I think those resistors at the top have something to do with not
    allowing a short-circuit when C or D are on, but other than that there
    was little that I understood about open-collectors and pull-up
    resistors. Looking at [2], if C is on, then what happens? The wire A
    will be HIGH? What if C is off? Then it will depend on what A is set
    on the microcontroler? Doesn't the connection of A with 5V mean that
    it will always be set to high? How can the host set that wire to high
    (or low)? How can the keyboard or mouse check if the host set clock to
    high?

    For what I understood the code from arduino that makes the clock line
    to go high is:
    pinMode(CLOCK_PIN, INPUT);
    digitalWrite(CLOCK_PIN, HIGH);
    A similar piece of code is described by arduino's manual like this:
    ``Often it is useful to steer an input pin to a known state if
    no input is present. This can be done by adding a pullup
    resistor (to +5V), or pulldown resistor (resistor to ground)
    on the input, with 10K being a common value.

    There are also convenient 20K pullup resistors built into the
    Atmega chip that can be accessed from software. These built-in
    pullup resistors are accessed in the [above] manner.''

    So setting clock to high seems to mean that you connect it to a 5V
    passing through a 20 ohms resistor. Why couldn't I just set
    pinMode(CLOCK_PIN, OUTPUT); and then digitalWire(CLOCK_PIN, HIGH); and
    allow the full 5V to go through without any resistors?

    Thank you for your time,
    Rafael

    [1] http://www.computer-engineering.org/ps2protocol/
    [2] http://www.computer-engineering.org/ps2protocol/ps2.JPG
    [3] http://www.arduino.cc/en/Tutorial/DigitalPins
     
  2. Jon Kirwan

    Jon Kirwan Guest

    I'm only just now reading about Arduino. Interesting.
    It's not too hard to understand. I'll get to that, soon.
    This is to make sure some other device isn't holding it actively low.
    (I'll explain 'actively' in a moment.)
    Well, there is that. However, that's not the best way to understand
    the resistor's function.
    In the circuit shown in your second web link, each transistor
    represents a switch. What is missing from that schematic and what may
    be confusing you a little is that they didn't include any other
    transistors sharing the same party line. For example, while C
    controls a transistor whose collector is hooked up to B, they don't
    show any other transistor collectors also hooked up to B as well. But
    they should to get the point across -- which is that doing it this way
    allows more than one such switch to be hooked up to the same, shared
    line. In this diagram, sadly, there is only one output that shares
    the line. So it looks almost like a waste. But if there were more,
    then it would start to make sense.

    So now let's make this more interesting. Looking at the picture,
    assume there are some more microcontrollers with the same schematic
    but where all the Data and Clock lines are directly connected without
    anything intervening. Just wired together, all sharing the same two
    lines. Let's call these microcontrollers Q, R, S, and T.

    Also, for discussion let's say that "active" means a transistor is ON
    and "inactive" means that transistor is OFF.

    Note that things have gotten more interesting. What happens if Q.C,
    R.C, and S.C are inactive but T.C is active? What value would be seen
    by Q, R, S, or T when reading Q.B, R.B, S.B, or T.B? What if all of
    Q.C, R.C, S.C, and T.C were inactive? What is seen reading Q.B, then?

    Now chance the context and imagine you have a phone line that is also
    shared by five other homes down the road. (This is why
    'open-collector' exists, to allow more than one talker on a shared
    line -- not only listeners.) How would you handle using the line?
    What rules would you work out with your neighbors so that you'd all be
    able to get along okay sharing this phone line?

    For one, you'd probably first just lift the handset up and listen
    before talking. If you don't hear someone else talking already, you'd
    then assume you could use the line and dial out. You'd also want the
    other homes to apply the same rules, as well. So that before they
    start dialing or talking on the phone, they also first listen to make
    sure you aren't already using it before them. Same thing, here.

    Getting back to Q, R, S, and T all sharing the same "party line" of
    (clock, data): How would you set up rules so that they could all
    share this party line well?

    I'll stop there. See if that helps (or makes things worse.)

    Jon
     
  3. Jasen Betts

    Jasen Betts Guest

    the zig-zag in the wire to 5v represents a resistor in the circuit
    shown it performs as a very poor conductor such that the transisto
    below it (or another connected between "data" and ground) can be
    turned on to change the voltage on the data wire and pin a to
    something close to 0V

    this makes the AVR microcontroller on the arduino board
    not try to force the voltage on that pin
    in input mode this enables an internal resistor between the +5V supply
    and the clock pin

    the image in the URL omits the resistors that are often needed in series
    with the connection from C&D to the transistors.
    With the arduino (and other similar microcontrollers) you can fake
    open-collector by putting the IO pins into "input mode" when you want the
    open-collector off and into output mode with a 0 value when you want
    it on, this means you can use the other pins for something else.
     
  4. Nobody

    Nobody Guest

    An open-collector output is one which behaves like a switch connecting
    the output pin to ground. If the switch is closed, the pin is pulled
    low; if the switch is open, the pin isn't connected to anything (within
    the chip).

    The advantage of an open-collector output is that you can connect several
    outputs to the same line, with a pull-up resistor connecting the line to
    the positive supply. If one or more of the outputs are low, the line will
    be pulled low; if none of the outputs are low, the line will be pulled
    high by the pull-up resistor.

    In the PS/2 mouse and keyboard interface, this allows each line to be
    bidirectional. I.e. either the device controls the state of the line and
    the host reads the state, or vice-versa.

    If totem-pole outputs were used (where the line is pulled either high or
    low), and the host and device both tried to control the line
    simulatneously, you could have a short-circuit if one pulls the line high
    and the other pulls it low.
     
  5. Jamie

    Jamie Guest

    TO add to that, keep in mind that NPN and PNP exist for open collectors.

    being a NPN, it would be low when ON, how ever, if it's a NOT output,
    it is a PNP and you'll get what ever the Vcc/(+) Line rail voltage is
    minus some losses.

    In both cases how ever, the output is in HI-Z when off.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-