pragram for robotic arm

Upload: kiran-pallapothu

Post on 07-Apr-2018

234 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/6/2019 Pragram for Robotic Arm

    1/11

    Essentially another tutorial involving controlling DC motors. In this post Im going to first alter a robot arm I had built

    previously from a beginners kit so that it can be controlled fromArduino. Then Im going to write a series of posts on different

    ways to control the robot arm usingProcessingand other things. You should be able to use all of what I write for work with other

    toys and motors.

    To start with have a look at the robot arm, its an Edge Robotic Arm Kit:

    The kit is a basic construction one and costs about 30 which you can find in most gadget shops and web stores. You assemble a

    gear box for each motor/ joint in the arm, doesnt take long to build (about an hour) and is controlled by a set of switches on a

    control box. The only thing to note here is were dealing with motors, not servos or stepper motors just bog standard DC motors.

    This means calculating positions isnt going to be straightforward later on. The kit has 5 motors and 4 D series batteries to

    power them and can lift about 100 grammes.

    So this version has a controller attached that lets you move each motor by pressing a switch, the electrics are pretty basic and

    dont allow much control or further input. I have seen other versions that allow you to plug it in to a computer via USB but you

    pretty much have the same controls.

  • 8/6/2019 Pragram for Robotic Arm

    2/11

    In order for us to build our own controls/ interfaces and software we need to modify the arm to allow us to interface our

    microcontroller in this case an Arduino board. The best way I think do this, since we want to control a motor going backwards

    and forward, is to use H-bridge chips theL293D andSN754410 and wire each motor into a chip and then alter the power

    circuit to run these chips. Arduino can then digitally control the H-bridge chip to turn the motor on/off and change its direction.

    You can see some other work Ive done with motorDC motor control and Ill be covering the same info throughout these posts.

    Arduino Robot Arm Parts

    3 H-bridge chips I heavily recommend using the sn754410 chip but you can probably get away with the L293 series. Each chip

    can control 2 motors 5 motors = 3 chips.

    ArduinoDeumilanova w/ ATMEGA328

    Breadboard/ Prototyping board

    Jumper/ Connector wires

    Wire cutters/ strippers

    Hacking the Robot Arm

    I hope youre not too precious about wanting to use the control unit again, thats the first thing to go! I did look at working with

    this but it doesnt give the level of control that I want. Also Ill be cutting and stripping the wires and removing the control circuit

    from the arm. The only permanent damage is done to the wires basically cutting the plugs off of the wires, so you could always

    get new plugs if you wanted to revert it, although once Ive shown you what can be done I dont think youll mind.

    Step 1

    First we need to create our breadboard layout so we can plug in all the wires, were going to be using alot of pins on the Arduino,

    in fact I think I use pretty much all of them. You could reduce this using shift registers but for now its not an issue, although

    please follow the wiring diagrams as this layout gives the least hassle. Some pins e.g. digital pin 13 will make the motors move

    when the board is powering up so we want to avoid this.

    First of all we need to put our H-Bridge chips on the breadboard. Make sure to put them in the center like illustrated. This means

    the 2 sides of the chip are isolated it will not work otherwise!

  • 8/6/2019 Pragram for Robotic Arm

    3/11

    Next using the above image and the following wiring diagram for the chip connect the ground and power for each chip leaving

    space for the motors and Arduino pins. Note that the red wires are connecting the rails together so the power will flow around the

    whole board! These chips will be using the battery power that runs the motors in the arm the power will be plugged into the

    board, the Arduino pins are there to switch the chips on/ off etc Ive also got a table of outputs Ive done for each pin on the H-

    Bridge chip, its the same for either the L293 series or SN754410, pin configuration diagram below. The numbers 1-16 also

    correspond to the numbers on the images of the circuit.

  • 8/6/2019 Pragram for Robotic Arm

    4/11

    H-Bridge Pin Configuration

    1 to pin on Arduino board

    2 to pin on Arduino board

    3 to motor1 (either + or -) it wont matter as its DC

    4 to the gnd (-) rail on the breadboard

    5 to the gnd (-) rail on the breadboard

    6 to motor1

    7 to pin Arduino

    8 to power (+) rail.

    9 to pin Arduino

    10 to pin Arduino

    11 to motor2

    12 to GND (-) rail

    13 to GND (-) rail

    14 to motor2

    15 to pin Arduino

    16 to power (+) rail.

  • 8/6/2019 Pragram for Robotic Arm

    5/11

    So you should have 3 chips on the board and be ready to add the motors and connections to Arduino.

    Step 2

    Now the circuit layout is complete we can start stripping down the arm. First remove the control unit and unscrew the panel

    above the battery pack this should have all the motors plugged in to it. Were going to systematically disconnect each motor

    plug, remove the plug, strip the wires a little bit and wire it on to the breadboard. When stripping the wires, remember to twist the

    exposed wires to prevent them becoming stranded or solder pins to the wires.

    Heres the first motor in on the first chip:

    Its important to remember which motor youre plugging in to which chip but its not too much of an issue as with the software

    well be writing later on we can work around this with our code, just so long as each motor is wired into a chip as above. Below

    is a list of my Arduino pins used.

    Shoulder motor

    chip 1, pin 1 to Arduino pin 14 (Analog pin o)

    chip 1, pin 2 to Arduino pin 15 (Analog pin 1)

    chip 1, pin 7 to Arduino pin 16 (Analog pin 2)Base motor

    chip 1, pin 9 to Arduino pin 2

    chip 1, pin 10 to Arduino pin 3

    chip 1, pin 15 to Arduino pin 4

    Elbow motor

    chip 2, pin 1 to Arduino pin 8

  • 8/6/2019 Pragram for Robotic Arm

    6/11

    chip 2, pin 2 to Arduino pin 9

    chip 2, pin 7 to Arduino pin 10

    Wrist motor

    chip 2, pin 9 to Arduino pin 5

    chip 2, pin 10 to Arduino pin 6

    chip 2, pin 15 to Arduino pin 7

    Hand motor

    chip 3, pin 9 to Arduino pin 11

    chip 3, pin 10 to Arduino pin 17 (Analog pin 3)

    chip 4, pin 15 to Arduino pin 18 (Analog pin 4)

    Youll notice that rather than refer to the motors as M1, M2, M3 as the kit does, Im calling them something more meaningful as

    I think it makes them easier to identify you should be able to figure out which motor is which from my description I would

    hope!

    Second motor in:

  • 8/6/2019 Pragram for Robotic Arm

    7/11

  • 8/6/2019 Pragram for Robotic Arm

    8/11

  • 8/6/2019 Pragram for Robotic Arm

    9/11

    digitalWrite(baseMotorEnablePin, HIGH);

    pinMode(shoulderMotorPin1, OUTPUT);

    pinMode(shoulderMotorPin2, OUTPUT);

    pinMode(shoulderMotorEnablePin, OUTPUT);

    digitalWrite(shoulderMotorEnablePin, HIGH);

    pinMode(elbowMotorPin1, OUTPUT);

    pinMode(elbowMotorPin2, OUTPUT);

    pinMode(elbowMotorEnablePin, OUTPUT);

    digitalWrite(elbowMotorEnablePin, HIGH);

    pinMode(wristMotorPin1, OUTPUT);

    pinMode(wristMotorPin2, OUTPUT);

    pinMode(wristMotorEnablePin, OUTPUT);

    digitalWrite(wristMotorEnablePin, HIGH);

    }

    void loop() {

    /*

    // SET either one to HIGH to turn the motor on.

    // e.g.

    digitalWrite(baseMotorPin1, LOW);

    digitalWrite(baseMotorPin2, HIGH);

    */

    digitalWrite(baseMotorPin1, LOW);

    digitalWrite(baseMotorPin2, LOW);

  • 8/6/2019 Pragram for Robotic Arm

    10/11

    /*

    // more motors here added.

    digitalWrite(shoulderMotorPin1, LOW);

    digitalWrite(shoulderMotorPin2, LOW);

    digitalWrite(elbowMotorPin1, LOW);

    digitalWrite(elbowMotorPin2, LOW);

    digitalWrite(wristMotorPin1, LOW);

    digitalWrite(wristMotorPin2, LOW);

    */

    }

    Step 3

    So now you should have all the motors wired to chips on the breadboard, now we just add the power to the board and were done

    this is the power from the robot arm batteries, it can connect on either side of the breadboard as long as its connected to the

    power rails. Also remember to connect a wire from the GND rail on the breadboard to a GND pin on Arduino there must be a

    common ground connection between Arduino and the H-bridge chips for this to work. Lastly Find a way to secure the Arduino

    and breadboard to the arm to minimise the risk of wires disconnecting, I just used some blu-tak (modelling clay etc..).

    And heres the final thing:

  • 8/6/2019 Pragram for Robotic Arm

    11/11

    If you want to avoid the breadboard and make a more permanent circuit you should be able ot follow this, just make sure that the

    pins on each side of the H-Bridge are completely isolated from each other.

    Onwards

    So thats it, the arm is ready to go you can add your own switches and inputs to control this but were going to have some fun

    writing software to control this arm in the next part to move each motor AND after that were going to be looking at using

    Inverse Kinematics and trigonometry to do some cool controlling of all the motors of the arm and to maybe start program tasks.

    Oh, Inverse Kinematics basically means we can program the arm to go after a target moving all the motors in combination to do

    this trust me it is very cool!