TD Moose
All things moose, and, then some.-
Power MOSFET tutorial
Posted on February 3rd, 2009 No commentsBest short description of how to use
power MOSFETS that I’ve ever found.Now I know why the power sucking pig of an electomagnet I made from hookup wire and a nail is so hard to drive with a power MOSFET.
Also, shows why sometimes you are better off just buying controller chips that do the job you want than to try to roll the circuitry yourself with discreet components.
-
Arduino controlled arm
Posted on January 30th, 2009 No commentsControlling 3 motors with an Arduino board.
I dug out an old robot arm kit that I had built a long time ago. It was originally operated by push buttons for each motor with a slide switch to reverse the polarity of the current and thus the direction of the motor.
With an Arduino module, a couple of H-bridge chips, and a bit of surfing for ideas, I managed to automate it to drop a washer in a small container. The main idea comes from this page page, which describes how to hook up and control one motor. Learning to control two motors is largely inspired by this diagram.
Here it is in action. I had bigger plans for what it would do, but, it is after all, just a cheap kit with plastic parts. The jaws barely have enough grip to hold a small washer. It is a good proof of concept for controlling multiple motors with a single arduino board.


Wiring code for robot arm
int motor1Pin1 = 3; // H-bridge leg 1
int motor1Pin2 = 4; // H-bridge leg 2
int motor1SpeedPin = 9; // H-bridge enable pin
int motor2Pin1 = 5;
int motor2Pin2 = 6;
int motor2SpeedPin = 10;
int motor3Pin1 = 7;
int motor3Pin2 = 8;
int motor3SpeedPin = 11;int ledPin = 13; //LED
void setup() {
// set all the other pins you’re using as outputs:
pinMode(motor1Pin1, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor1SpeedPin, OUTPUT);
pinMode(motor2Pin1, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(motor2SpeedPin, OUTPUT);
pinMode(motor3Pin1, OUTPUT);
pinMode(motor3Pin2, OUTPUT);
pinMode(motor3SpeedPin, OUTPUT);pinMode(ledPin, OUTPUT);
// set speedPin high so that motor can turn on:
digitalWrite(motor1SpeedPin, HIGH);
digitalWrite(motor2SpeedPin, HIGH);
digitalWrite(motor3SpeedPin, HIGH);// blink the LED 3 times. This should happen only once.
// if you see the LED blink three times, it means that the module
// reset itself,. probably because the motor caused a brownout
// or a short.
blink(ledPin, 3, 100);
}void loop() {
delay(5000);
digitalWrite(motor2Pin1, HIGH); // Arm up
digitalWrite(motor2Pin2, LOW); //
delay(1000);
digitalWrite(motor2Pin1, LOW);
delay(500);digitalWrite(motor3Pin1, LOW); // Arm left
digitalWrite(motor3Pin2, HIGH); //
delay(2500);
digitalWrite(motor3Pin2, LOW);
delay(500);digitalWrite(motor2Pin1, LOW); // Arm down
digitalWrite(motor2Pin2, HIGH); //
delay(1100);
digitalWrite(motor2Pin2, LOW);
delay(500);digitalWrite(motor1Pin1, HIGH); // open jaws
digitalWrite(motor1Pin2, LOW); //
delay(4000);
digitalWrite(motor1Pin1, LOW);
delay(500);digitalWrite(motor2Pin1, HIGH); // Arm up
digitalWrite(motor2Pin2, LOW); //
delay(1000);
digitalWrite(motor2Pin1, LOW);
delay(500);digitalWrite(motor3Pin1, HIGH); // Arm right
digitalWrite(motor3Pin2, LOW); //
delay(2000);
digitalWrite(motor3Pin1, LOW);
delay(500);digitalWrite(motor2Pin1, LOW); // Arm down
digitalWrite(motor2Pin2, HIGH); //
delay(1100);
digitalWrite(motor2Pin2, LOW);
delay(500);
}/*
blinks an LED
*/
void blink(int whatPin, int howManyTimes, int milliSecs) {
int i = 0;
for ( i = 0; i < howManyTimes; i++) {
digitalWrite(whatPin, HIGH);
delay(milliSecs/2);
digitalWrite(whatPin, LOW);
delay(milliSecs/2);
}
}


