Wednesday, March 21, 2012

Monoprice USB to PS2 Adapter Forensics

I love Monoprice. They sell the same imported accessories and peripherals that are rebranded and sold at higher prices by larger companies. All of the things I have bought from them have exceeded my expectations. You really get a sense of how much you’re being ripped off by retailers when you price their HDMI and USB cables.
However I ordered a USB to PS2 adapter a while back and finally got around to using it – it was going to allow my inlaws to use their old keyboard and mouse with the new computer I’m sending them. Unfortunately I couldn’t get it to work. I tried it on several different computers and in both XP and Linux Mint. It was recognized as a USB hub but the keyboard and mouse wouldn’t work. Power was getting through to the mouse (as evidenced by the red light of the LED).
Rather than send it back (It cost all of $1.94) I thought it would be interesting to see how and why it failed. At least in so far as my limited electronics knowledge could determine.
DSC00949
Part# 2855 which is now discontinued and completely gone from their website. I bought it in August of 2011.
I suspect that it was discontinued for exactly the problem (I think) I discovered.
DSC00954
Fun with a box cutter.
DSC00956
There’s a circuit board.
DSC00965
This is where it gets somewhat interesting. Black to VDD, Red to DATA, Green to CLK (Clock) and White to GND.
Notice I tried to scrape away the epoxy to verify that there was actually a chip under there. I saw bits of metal so I assume so.
pinout
The PS2 pinout from Wikipedia’s article. Pin 5 is Clock and Pin 1 is Data.
DSC00962
Jumper in pin 5 position, which should be CLK (Clock)
DSC00964
Showed continuity to the red wire which was soldered to the Data tab on the circuit board.
DSC00966
Jumper in pin 1 position, which should be Data.
DSC00967
Shows continuity to the green wire, which was soldered to the CLK (Clock) tab on the circuit board.
DSC00971
Here’s a shot taken by my loving wife that shows the test, this time with the green (mouse) PS2 connector. Jumper is in pin 1 (DATA), green wire (Soldered to CLK on the circuit board) shows continuity.
I really need to get some grabby probe tips for my VOM.
So unless I am mistaken (and it’s always possible I am, let me know if you see an error in my analysis), the problem with the adapter is that the CLK and DATA wires are reversed. While the adapter doesn’t work I think I had $1.94 worth of fun looking at the problem.

Sunday, March 11, 2012

Code for the Potentiometer Controlled Stepper Motor.

I received two requests for the code I used in this demo
------------------------------------------------------------------
#include
AF_Stepper motor1(225, 1);
int analogPin = 0;     // potentiometer wiper (middle terminal)
//connected to analog pin 3
// outside leads to ground and +5V
int val = 0;           // variable to store the value read
int prepos = 0;
int pos = 0; //0 to 224 .
void setup()
{
  motor1.setSpeed(60);  // 30 rpm  
}

void loop() {
 
  prepos = pos;
  val = analogRead(analogPin);    // read the input pin
 
  pos = map (val, 0, 1024, 0, 224);
 
  if (pos != prepos){
    int diststep = pos - prepos;
    if (diststep < 0) {
    motor1.step(-diststep, BACKWARD, INTERLEAVE);
    }
    if (diststep > 0) {
    motor1.step(diststep, FORWARD, INTERLEAVE);
    }
   
  }
 
}
--------------------------------------------------------------------------
AFMotor is the Adafruit stepper library used with their motor shield.
The motor I used has 3.2 degrees rotation per step, but I have the driver in half step interleaved mode, so 1.6 degrees per step. So 360 deg./1.6 deg. = 225 steps per revolution, thus the 0-224 values of pos.

Wednesday, March 07, 2012

Power Strip Modification

DSC00868
Ah, the power strip.
DSC00869
The back side.
DSC00871
To mount to a wall you are supposed to install two screws in the wall with the heads proud of the surface by the thickness of the plastic shell, then capture the heads and slide onto the screw. This usually causes much anguish as you have to mount the screws the correct distance apart. Often trying to slide it on will result in cursing.
DSC00873
Ever open one of these up? Not much to it.
DSC00874
The hole for the screw could be drilled all the way through the body…
DSC00875
Always good to check first…
DSC00876
Drill…
DSC00882
Countersink.
DSC00883
I should have spaced this hole a little closer to the end, but there it is.
DSC00884
Mounting is insanely easy – put the strip where you want it and screw it on.
DSC00885
The screw head is no uglier than the power strip.
DSC00887
This is my new bench…
DSC00888
Lots more storage space.