Tuesday, June 30, 2009

More learning on the Arduino...

So I was able to control a servomotor with a potentiometer this past weekend. That was pretty cool, it was pretty much 1:1, half turn on the pot was about a half turn on the servo. I was using Analog out to control the motor, most of the tutorials I've found use PWM on a digital pin. Seems my way is easier (but I'm sure there's a reason for the PWM on digital that I have yet to discover).
Then I got the wild hair to hack an old mouse. Didn't work too well, but nothing detrimental. I cut off the PS/2 plug and stripped the wires: red, green, blue and white - notice anything missing? That's right, the black. But that's not the worst of it, the red wasn't even the power in; the blue was. green happened to be ground, red and white were send and receive. It took 5V @ 20 mA - just about the upper safe threshold for the Arduino. I wrote a program that read the red and white and sent back to the computer what it was reading to print on screen. I know something was going on because I initialized the variables to 0 but all I got on screen was:
mouseVar1 = 1
mouseVar2 = 1
mouseVar1 = 1
mouseVar2 = 1...
so it was reading something, but nothing discernible. I read online that the receive line was supposed to be a clock signal, so I'm guessing the mouse was having a hissy fit because it wasn't getting a clock in. I probably should have read a little more on the PS/2 mouse - somehow you're supposed to get an X, a Y, and 3 mouse clicks from just one line.
Next on the list, I'm going to have to buy a few MOSFETs and start learning about controlling high loads. Though here is a gripe I'm having with all of these tutorials, it's a trap I'm sure I'd fall into if I were writing them as well. It seems to me that the people writing these tutorials know the subject so well they're taking for granted that their audience knows certain things. For example, yesterday I searched between 10 and 15 tutorials for controlling DC motors with the Arduino, no two were alike when it came to the additional circuitry required to control the higher loads. That's fine, it shows the flexibility and different options. But what's not fine is not a single one explained why they chose what they did. Some used MOSFETs, others used H-bridges, some used 2 H-bridges, others used commercial motor control chips, and there were more that used off the shelf motor shields. Another example is the resistors, all the tutorials say "use xx Ohm resistor" and I'm left thinking, "Ok, no problem but... why that value?"
I'm mechanical. If I can't see it, I have a hard time figuring out how it works. A little explanation would go a long way to improving some of these tutorials.

[EDIT] Ok, so I'm learning now :P

It seems that the MOSFET is used for simple one direction high load on/off switching.
The H-bridge is for bi-direction, varying loading, and multiple high loads, and seems to be basically an array of MOSFETs.

here's a good academic link:
http://itp.nyu.edu/physcomp/Labs/DCMotorControl

2 comments:

  1. Ok, so I'm learning now :P

    It seems that the MOSFET is used for simple one direction high load on/off switching.
    The H-bridge is for bi-direction, varying loading, and multiple high loads, and seems to be basically an array of MOSFETs.

    here's a good academic link:
    http://itp.nyu.edu/physcomp/Labs/DCMotorControl

    ReplyDelete
  2. i put your comment up into the post as an edit =P

    this is really great work. i especially like how you figured out what the mosfets and h-bridges are used for =P

    ReplyDelete