Thursday, April 21, 2011




Final

Here's the final post. I used a 4.5V worm gear box by Tamiya as the motor to raise and lower the claw. I constructed a lightweight claw using the Antman232 design (http://www.instructables.com/id/The-Claw-1/) instead of the heavier commercial claw I initially intended to use. The claw is motored by a 5V servo. The Arduino motor shield can support up to 4 DC motors but they all are powered by the external power supply you provide. So if you use a 12V power supply, they all get 12V unless you reduce their speed. Well I had a problem because the worm drive was rated 4.5V. I reduced the set speed to 75 in order to drop the voltage down to 5-6V. I intended to use a fixed 5V voltage regulator in line with the power supply to this specific motor but as I soon discovered, the motor jacks reverse polarity when motor direction changes. The servo has it's own regulated 5V supply so that wasn't a problem. Anyway, the project is running albeit a bit slow. The wheel assemblies move in staccato fashion due to the time delays in the code. The claw close in an all or nothing fashion. Ideally, I would have liked to control the closing pressure.
 The following is a summary handout for the Expo exhibit:
Patients who have had surgery or trauma to the hands often need formal hand therapy.  The therapist often prescribes a home exercise program to complement the supervised sessions.  Compliance can be variable.
As an incentive to comply with the instructions, I thought a prototype interactive game using a glove with built in sensors might encourage the desired motions such as wrist flexion and extension.  
Our final project for the Physical Computing class is to create a physically interactive system focused on sensing the relevant actions of the user combined with the appropriate physical response. Representing hand motion in an abstract way, I chose the classic “claw game”, as seen in the arcades, to represent the physical component.  To substitute for the joystick, I constructed a sensor glove using a flex sensor and accelerometer.
The Arduino Duemilanove microcontroller and motor shield allowed me to use three DC motors and one servo.  The accelerometers’ three sensors, x, y, and z, provided the input for left/right, forward/back, and up/down motions respectively.  The flex sensor, attached to the middle finger, controlled the open/close of the claw.
Ideally, a method to record and store the actual joint angles would have been useful to monitor a patient’s progress.  In addition, a scoring system also helps reinforce the behavior.  The ability to control the amount of force applied by the claw is also desirable from the standpoint of incremental muscle recruitment.
The Arduino sketch code is :
const int xpin = A3;
const int ypin = A2;
const int zpin = A1;
const int cpin = A0;
int cVal = 0;
int yVal = 0;
int xVal = 0;
int zVal = 600;
#include <AFMotor.h>
#include <Servo.h>
#define BUTTON 2

int val = 0;
int old_val = 0;
int state = 0;

unsigned long time = 0;

Servo myservo;
AF_DCMotor motor(1, MOTOR12_64KHZ);
AF_DCMotor motor2(2, MOTOR12_64KHZ);
AF_DCMotor motor3(3, MOTOR34_64KHZ);

boolean downClaw = false;
void setup()
{
  pinMode(BUTTON, INPUT);
  myservo.attach(9);
  motor.setSpeed(255);
  motor2.setSpeed(255);
  motor3.setSpeed(75);
  // start serial port at 9600 bps:
  Serial.begin(9600);
}

void loop()
{
  val = digitalRead(BUTTON);
   if ((val == HIGH) && (old_val == LOW)){
      state = 1 - state;
      delay(10);
      }
  old_val = val;
  if (state == 0) { }
      else if(state == 1)
 {
      time = millis();  //start the clock
      if(time< 60000)  //30 seconds to play
   {
 xVal= analogRead(xpin);
  if((xVal >= 525)&&(zVal>450))
        {
        xRight();
        delay(15);
        }
      
        if((xVal <=480)&&(zVal>450))
        {
        xLeft();
        delay(15);
        }
      
        if(xVal <=525 && xVal >=480){}
        Serial.print(xVal, DEC);
  yVal= analogRead(ypin);
  if((yVal >= 525)&&(zVal>450))
        {
        yBack();
        delay(15);
        }
      
        if((yVal <=480)&&(zVal>450))
        {
        yFront();
        delay(15);
        }
      
        if(yVal <=525 && yVal >=480){}      
  Serial.println(yVal, DEC);
 
   zVal= analogRead(zpin);
   if((zVal <=450)&&(downClaw == false))
        {
        Serial.println(zVal, DEC);
        zLower();
        delay(15);
        }
      
     
      if((zVal >=550)&&(downClaw == true))
        {
        zRaise();
        Serial.println("down");
        delay(15);
        }
      
        //if(yVal <=525 && yVal >=480){}      
  Serial.println(zVal, DEC);
   cVal = analogRead(cpin);
  if(cVal>=920){
          cOpen();
        }
        if(cVal<=915){
          cClose();
      }
 Serial.println(cVal, DEC);
   Serial.println(millis());
  // wait 10ms for next reading:
  delay(500);               
}
   
      else if(time >= 60000){
       Serial.println("time's up");
       //lowerClaw();
    }
 }
}
void xRight(){
      motor.run(FORWARD);
      delay(250);
      motor.run(RELEASE);      // stopped
      delay(500);
}
void xLeft(){
      motor.run(BACKWARD);
      delay(250);
     motor.run(RELEASE);      // stopped
     delay(500);
}
void yBack(){
      motor2.run(FORWARD);
      delay(1000);
      motor2.run(RELEASE);      // stopped
      delay(500);
}
void yFront(){
      motor2.run(BACKWARD);
      delay(1000);
     motor2.run(RELEASE);      // stopped
     delay(500);
}
void zLower(){
      motor3.run(BACKWARD);
      delay(4000);
      motor3.run(RELEASE);      // stopped
      downClaw = true;
      //delay(1000);
}
void zRaise(){
      motor3.run(FORWARD);
      delay(6000);
     motor3.run(RELEASE);      // stopped
     downClaw = false;
     //delay(8000);
    // motor3.run(FORWARD);
    //  delay(8000);
      //motor3.run(RELEASE);      // stopped
      //delay(1000);
}
void cOpen(){
      myservo.write(180);                  // sets the servo position according to the scaled value
      delay(15);                           // waits for the servo to get there
      }
void cClose(){
      myservo.write(0);                  // sets the servo position according to the scaled value
      delay(15);                           // waits for the servo to get there
      }

Wednesday, April 13, 2011

It seems the claw I bought is not going to be an option. It weighs too much and I can't find any worm drive motor to raise and lower it (at least not an affordable one). Most DC motors are too hi speed for useful movement.  By using gears, the speed is reduced and torque increased which allows for productive work. The use of belts and pulleys, while reducing noise, are only helpful in hi speed, low torque situations.  The problem is finding gears and pulleys to fit your needs. You really have to purchase pre-engineered sets that have been designed to work with a certain motor. I struggled to put motors and pulleys together and I couldn't find any inexpensive gear sets. I did find one worm drive gearbox that I will probably use in my project but it is limited to 4.5 volts (not strong enough for the claw I had in mind). I now realize why most robotic type projects utilize kits from Knex, Lego Mindstorm, and Vex Robotics to name a few. They are pre-engineered to fit precisely the built structures. The drawback is, of course, the expense. So, I will press on with what I have and probably make my own claw. The following are useful sites I used in researching my project:
http://www.vexrobotics.com/
http://mindstorms.lego.com
http://www.knex.com
http://www.instructables.com/id/The-Claw-1/
http://www.instructables.com/id/Knex-Claw-Machine-Game/
http://gicl.cs.drexel.edu/repository/data/repository/Lego/Drexel-Lego-RobotLab-99/readings/artoflego.pdf
artoflego.pdf

Monday, April 11, 2011

Attaching the motors to the x-y rail and linking them to the pulleys was a problem. Not having formal pulleys for the DC motors,  I used the existing wheel on the stem but the rubber band belt tended to slip off. Working on that problem. Also discovered that a DC motor alone will not hold up the claw with no juice applied. The weight of the claw simply spins down the spool (rigging a spool to the short stem of a  motor is also a problem). It seems I will need a worm drive because that locks in place when the motor is off. In the process of  finding one.

Friday, April 8, 2011


Well I received the KNEX pulley tires and they are perfect except that the 3/8th inch rod is to big for them. So I exchanged the rods for 1/4 inch and they ride a little wobbly but will do. I decided to start assembling the rail system and get the carriage built. Next I plan on  mounting the motors and do a trial. Bought some rubber bands to serve as pulley belts. We'll see how that goes.

Tuesday, April 5, 2011

Struggling to come up with a DIY claw component  for my project,  I considered hacking a cork screw, gear puller or even a golf ball retriever. As luck would have it, I found a commercial medium claw on the web for $25 complete with solenoid (most run for about $185). Since time is of the essence, I sprung for it. However, because it is much larger than I anticipated, I'll have to scrap the inkjet setup. Instead I purchased 4-3/8th inch x 3' rods (zinc) to serve as the rails. I'll still use the DC motors from the printers (12V) to drive the carriage (X-Y). I am having trouble with the claw solenoid. I think it may be 24V. I hooked it up to 12v and it closed but with little power. If I'm lucky it will pick up a crumbled piece of paper. Still thinking what to do about that. Ordered some pulley tires/wheels from KNEX hoping they will ride the 3/8th rod.  Started writing some code when I realized that I'll need a mechanism to stop the carriage/truck assembly when it reaches the end of the rail (stop motor). Some people have used a reed/magnetic switch. I might use a momentary switch that will be activated when carriage bumps up against it. So in summary my final box will probably be 3'x3'x3'.