R
Rafael Cunha de Almeida
Guest
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
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