necroware/ps2-serial-mouse-adapter

Mouse stuck in PS/2 communication

Closed this issue · 13 comments

Some mice seem to stuck in the PS/2 communication. So far two mice had such a problem - HP and A4tech. The behavior is the same on both, lights up but gets stuck at (serial monitor output):

Starting serial port
Init 3-buttons mode
Listening on RTS
Reseting PS/2 mouse

An educated guess: The communication with the PS/2 port fails completely due to internal pull-up resistors. In the adapter the Arduino's internal pull-ups for the PS/2 clock pin are used. I heard, that the resistors which Arduino uses are quite low, so the pull-up can be to strong for some devices. I tested the adapter with many mice and never encountered such problems, but there is always the first time. I'd suggest to solder a 10k resistor between VCC and PS/2 clock pin on the Arduino socket (pin 5) and change line 89 in the file Ps2Mouse.cpp:

from: pinMode(m_ref.m_clockPin, INPUT_PULLUP);
into: pinMode(m_ref.m_clockPin, INPUT);

this way, internal pull-up in the Arduino would not be used anymore and external pull-up of 10k would be used instead.

Following pull request ps2-serial-mouse-adapter-fix-remote-mode:

-A4Tech OP-720 behavior changes.
+When connected to the Arduino IDE the mouse now reports proper initialization on Serial Monitor (Previously would get stuck at "Reseting PS/2 mouse"
+When connected to a retro pc the mouse driver detects a mouse at COM1 and loads into memory but there is no cursor movement
-The issue remains the same with HP P/N 417441-001 optical PS/2 mouse.
+When connected to the Arduino IDE, the mouse initialization gets stuck at "Reseting PS/2 mouse"
+When connected to a retro pc the mouse driver detects no mouse.

I will test the 10K resistor mod at earliest opportunity.

I have tested the 10K resistor mod:

PS2-Serial 10K Resistor Mod

And the results are:

A4Tech OP-720: Reports proper initialization on Serial Monitor when connected to Arduino IDE and works properly with retro PC in either mode.
HP P/N 417441-001: Still stuck on "Resetting PS/2 mouse" on Arduino IDE and does not work in retro PC in either mode, despite driver detecting a mouse on COM1.

So this fixed the issue with one of the two remaining problematic mice.

Ok, thank you very much for testing this. I'll add a resistor to the PCB design to improve the compatibility. In regards of the HP mouse, I guess we need to debug it with a logic analyzer attached to see, what is happening. My assumption is, that the adapter hangs at the clock waiting for the mouse to drive the bus, but it never happens. What you can try is to take even higher resistor, let's say s.t. around 15K, may be the mouse drives the clock really weakly. If that doesn't change anything, then I'm out of ideas and we really have to debug with a logic analyzer.

I have 15K resistors at hand so I will test one of the adapters with a 15K resistors and see if that works. If it does, I can replace the 10K test unit with 15K as well. Is there a danger to going too high on the resistor value? Could it damage the serial port or the mouse?

No, if you go higher it shouldn't be a problem, but if it is too high, it will stop working as a pull-up from there on. I think, there is no reason to go higher, than 15K, I can't imagine, that the mouse drives the line that weakly.

Ok, I checked and the highest I actually have are 12K resistors anyway, so I will try that and report back.

Using a 12K resistor produced no observable difference in the adapter's behavior I'm afraid :(

Than unfortunately we have to put the HP mouse to a set of mysteries for now. If you like you can try to debug the code try to find out, where it hangs. If I'll find another mouse with a similar behavior, I'll investigate it further.

One thing, I would like you to ask, could you please test the unchanged code, with INPUT_PULLUP left there, but with a 10K resistor installed on the A4tech mouse once again? I would like to keep the code compatible to the old version of the adapter and if we remove PULLUP from the code it will not work on the older PCB anymore. If there is a way to leave the code compatible, that would be great.

Happy to report that the A4Tech OP-720 mouse works with the original code:

pinMode(m_ref.m_clockPin, INPUT_PULLUP);

With the 10K resistor installed, so you don't have to break code compatibility with older revisions of the board :)

I am also a little bit confused to be honest beaming face with smiling eyes As I asked you to try that, I was somehow on the wrong path. Afterwards I thought, that it shouldn't work, because then we'd have two pull-ups in parallel, which means, that the overall resistance should be actually less, than with only internal resistor. And now, where you say, that it works I'm even more confused.... I'll dig into the Datasheet of the Arduino to see how exactly they made the internal pull-ups, may be I'll be able to explain then, why it is still working....

I think, I found something interesting. The information, which I had previously was wrong. The internal resistors are not too low, the are in reality up to about 30K. But some people say, that they can be very noisy and by using external resistors with lower values, the noise can be reduced. So, as we tried 10K resistors on your device, we actually lowered the resistance and not raised it. Probably reducing the noise, which may be your HP/A4 mice don't like. Some people advice to go even further down to 4,7K. An if we connect external 10K in parallel to the internal we also reduce the overall resistance. That makes sense. Furthermore people say, that the noise and the internal resistance values can vary from Arduino to Arduino quite a lot, what again would explain, why all mice which I have do work on my adapter. May be there are some slight differences in our Arduino devices as well.

I have replaced 10K resistor with 4.7K to no effect. Reading up on this issue I see 2.2K recommended for some circuits, worth trying?