Professional Documents
Culture Documents
Living
Outside
Play
Technology
Workshop
Make Wired Robotic Arm Edge to "Wireless" with DIY Arduino + XBee
by sath02 on April 3, 2012 Table of Contents Make Wired Robotic Arm Edge to "Wireless" with DIY Arduino + XBee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro: Make Wired Robotic Arm Edge to "Wireless" with DIY Arduino + XBee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 1: Build the Robotic Arm Edge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 2: Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 3: Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 4: Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 5: Lets the fun begin... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 6: Wiring the main Ground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 7: Motor Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 8: Motors Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 3 3 4 5 5 7 7 9
Step 9: Motor Controller Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Step 10: (Alternative) Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Step 11: Add Power Supply to Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Step 12: Test the Motors Driver Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Step 13: Configure XBee and Test XBee . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 Step 14: Arduino Sketch & Processing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Step 15: Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Author:sath02
I am Electronic Visualization Artist. I look at things through the Looking Glasses.
Intro: Make Wired Robotic Arm Edge to "Wireless" with DIY Arduino + XBee
When I finished the "RevIO" - an Arduino Clone that has the different way of exposing pins usage. I decided to go further to the next project. To test my "RevIO" board that it could do the bigger task than just blinking the LED! I modified the Wired Robotic Arm Edge to Wireless controlled, using my "RevIO" and DIY Three-Motor Driver ICs PCB together with XBee Series 1 module. This instructables introduces the way I constructed Three-Motor Driver ICs PCB from scratch. Then using it as the "piggy back" on my "RevIO" Board. To control the Robotic Arm, I designed the GUI (Graphical User Interface) with the Processing on the PC and Arduino sketch for driving the motors. I also added the 6-pin socket as an alternative to use Bluetooth module (Sparkfun's Bluetooth Modem - Blue SMiRF Silver , or Bluetooth Modem - Blue SMIRF Gold .) Again I am going to use the same presentation method as Build "The RevIO" (Arduino Clone) My Way , to build the board using the graphical illustrations, together with the photos of actual build of the board.
Image Notes 1. XBee Module on the PC(Laptop).This is the FTDI Cable Mod. I modified the cable to be located underneath the XBee module. 2. XBee Module on the Robotic Arm
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Step 2: Parts
IC1, IC2, IC3 H-Bridge Motor Driver 1A, SN754410 (Sparkfun #COM-00315 ) or L293D (Digikey#497-2936-5-ND ) R1 - 1K Resistor (Radio Shack #271-1321 or Digkey #PPC1.0KW-1CT-ND ) LED1 - 3mm Red LED (Digikey #160-1708-ND ) S1 - Slide DPDT Switch (Digikey #401-2000-ND ) JP1 - 2x6 Male Header Connector, Straight JP2, JP3 -(2) 14-pin Male header, extra long pin or use shield stacking headers (Adafruit ID#85) JP4 - 2-pin Male Header Connector, Right Angle JP5 - 6-pin Female Connector, Right angle 16-pin IC Socket (Radio Shack #276-1998 ) Multipurpose PC Board with 417 holes (Radio Shack #276-150 ) Wire The RevIO or any kind of Arduino Note: In case of using Arduino or others Arduino Clone you needed to make the Motor Control Board to match those Arduino. Other parts: 2 XBee Modules I got the Series 1 from AdaFruit 2 Xbee Adapter Board from AdaFruit Alternativel part: Bluetooth Modem - Blue SMiRF Gold (Sparkfun# WRL-10268 ) or Bluetooth Modem - Blue SMiRF Silver (Sparkfun# WRL-10269 )
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. Ready to use, RevIO - DIY Arduino 2. 3 nos. of L293D or SN754410, H-Bridge motors drivers 3. PCB with 417 holes (Radioshack #276-150)
Step 3: Layout
As mentioned in the intro. I planned to use this motors driver board as a "piggy back" on the RevIO PCB. So I obtained the same PCB (Radio Shack #276-150) to match my RevIO's exposed pins. I tried to use the plain PCB (Radio Shack #276-149) so I could put the three H-Bridge Motors Drivers in parallel to the width of the PCB, but that did not worked! Because the holes on the width side was one hole short of the RevIO. Notice that I placed the board by having the two row of individual holes on top and three rows of individual holes on the bottom. So it matches the layout of the RevIO board. Luckily, I could fit three H-Bridge Motor Drivers IC on the Multipurpose PC Board with 417 holes (Radio Shack #276-150) by put them one after another over the positive and negative rails in the middle of the board. The other good thing was that there were enough space to put 2x6 male header, for motors control pins and led on the board. So I place them on the top left corner of the board next to the top 14-pin rail. And also there were enough space to put a 6-pin connector as an alternative for Bluetooth breakout board. (Bluetooth Modem - Blue SMiRF Gold (Sparkfun# WRL-10268) or Bluetooth Modem - Blue SMiRF Silver (Sparkfun# WRL-10269)) . So I placed it on the bottom right corner of the PCB.
Image Notes 1. PCB (Radio Shack #276-150) Top and Bottom 2. Two rows of individual holes. 3. Three rows of individual holes 4. Positive and Negative rails
Image Notes 1. Motors and LED connector from Robotic Arm 2. 3 nos. H-Bridge Motors Drivers 3. Motors Power Supply connector. 4. Bluetoorh 5. Motors Power Switch 6. Motor Power Supply indicator LED
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Step 4: Tools
Solder iron and Soldering Work Station Solder - Rosin Core (Radio Shack #64-013) Hookup Wire Multimeter Diagonal cutter Pliers X-Acto Knife Wire Stripper Solder Sucker etc. (something else that you might want to use.)
Image Notes 1. JP1 - Motors and LED connector from Robotic Arm Edge
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. Motors Power Supply Jack (J4) 2. JP2 - 2x6 Motors and LED connector 3. Motors Power Supply indicator LED and 1K resistor 4. Motor Power Switch (S1) 5. Motor Power Switch (S1)
Image Notes
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. H-Bridge IC for controlling Grip (M1) and Wrist (M2)
Image Notes 1. Second H-Bridge Motor Driver, this one is controlling elbow(M3) and shoulder(M4)
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. The third H-Bridge Motor Driver, this one controls only one motor, base (M5)
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. Connect pin 16 of three H-Bridge together. 2. Connect 5V H-Bridge ICs to Arduino 5V pin. 3. Connect 5V H-Bridge ICs to Arduino 5V pin.
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Motor Pin 2x6 Motors Header Connector 11 M3 Top Row 14 M3 Bottom Row LED Light (L) 2x6 Motors Header Connector Arduino Pin L Top Row D13 L Bottom Row Gnd
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. These existing parts (Handheld controller, PCB and PCB cover) were no longer needed!
Image Notes 1. undefined 2. Drill two holes. Note: the right hole is not visible.
Image Notes 1. Drill two holes on the RevIO case to match the existing holes. And make an openning for the screw at the bottom.
Image Notes 1. Install the RevIO bottom ccover on the Robot Baterry case.
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. Connect the connectors accordingly. From left LED, Base motor, Shoulder motor, Elbow motor, Wrist motor, and Grip motor. 2. Robot motors power supply header. 3. Robot motors power supply header.
Image Notes 1. Flip the switch! "We have the power! Yeah." 2. Flip the switch! "We have the power! Yeah."
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
int elbowPin2 = 15; // Shoulder (M4) UP and DOWN action int shoulderEnablePin = 14; int shoulderPin1 = 2; int shoulderPin2 = 4; // Base (M5) RIGHT and LEFT action int baseEnablePin = 3; int basePin1 = 16; int basePin2 = 17; // LED ON and OFF action int ledLight = 13; void setup() { pinMode(ledLight, OUTPUT); // grip (M1) pinMode(gripEnablePin, OUTPUT); pinMode(gripPin1, OUTPUT); pinMode(gripPin2, OUTPUT); // wrist (M2) pinMode(wristEnablePin, OUTPUT); pinMode(wristPin1, OUTPUT); pinMode(wristPin2, OUTPUT); // elbow (M3) pinMode(elbowEnablePin, OUTPUT); pinMode(elbowPin1, OUTPUT); pinMode(elbowPin2, OUTPUT); // shoulder (M4) pinMode(shoulderEnablePin, OUTPUT); pinMode(shoulderPin1, OUTPUT); pinMode(shoulderPin2, OUTPUT); // base (M5) pinMode(baseEnablePin, OUTPUT); pinMode(basePin1, OUTPUT); pinMode(basePin2, OUTPUT); } void loop() { // turn on/off Robot LED digitalWrite(ledLight, HIGH); delay(500); digitalWrite(ledLight, LOW); delay(500); // rotate right for 1500 milliseconds baseRight(); delay(1500); // pause for 1000 milliseconds basePause(1000); // rotate left for 1000 milliseconds baseLeft(); delay(1000); basePause(1000); } void gripIn() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, HIGH); } void gripOut() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin2, LOW); digitalWrite(gripPin1, HIGH); } void gripPause(int mSec) { digitalWrite(gripEnablePin, LOW); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, LOW); delay(mSec); }
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
void wristUp() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, HIGH); } void wristDown() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin2, LOW); digitalWrite(wristPin1, HIGH); } void wristPause(int mSec) { digitalWrite(wristEnablePin, LOW); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, LOW); delay(mSec); } void elbowUp() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, HIGH); } void elbowDown() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin2, LOW); digitalWrite(elbowPin1, HIGH); } void elbowPause(int mSec) { digitalWrite(elbowEnablePin, LOW); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, LOW); delay(mSec); } void shoulderUp() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, HIGH); } void shoulderDown() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin2, LOW); digitalWrite(shoulderPin1, HIGH); } void shoulderPause(int mSec) { digitalWrite(shoulderEnablePin, LOW); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, LOW); delay(mSec); } void baseRight() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin1, LOW); digitalWrite(basePin2, HIGH); } void baseLeft() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin2, LOW); digitalWrite(basePin1, HIGH); } void basePause(int mSec) { digitalWrite(baseEnablePin, LOW); digitalWrite(basePin1, LOW); digitalWrite(basePin2, LOW); delay(mSec); }
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
File Downloads
TestRobotArm.pde (3 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'TestRobotArm.pde']
Following are the list of the links of the great resources to learn all about the XBee. Tutorials and infomation: XBee Radios at AdaFruit . Datasheet, specification, and cofiguration app. from Digi
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
Image Notes 1. XBee Module on the PC(Laptop).This is the FTDI Cable Mod. I modified the cable to be located underneath the XBee module. 2. XBee Module on the Robotic Arm
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
// set a variable to store the byte sent from the serial port int incomingByte; void setup() { // set light LED pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // set the SN754410 pins as outputs: pinMode(basePin1, OUTPUT); pinMode(basePin2, OUTPUT); pinMode(baseEnablePin, OUTPUT); pinMode(shoulderPin1, OUTPUT); pinMode(shoulderPin2, OUTPUT); pinMode(shoulderEnablePin, OUTPUT); pinMode(elbowPin1, OUTPUT); pinMode(elbowPin2, OUTPUT); pinMode(elbowEnablePin, OUTPUT); pinMode(wristPin1, OUTPUT); pinMode(wristPin2, OUTPUT); pinMode(wristEnablePin, OUTPUT); pinMode(gripPin1, OUTPUT); pinMode(gripPin2, OUTPUT); pinMode(gripEnablePin, OUTPUT); // start sending data at 115200 baud rate // I set my Xbee Baud Rate at 115200 bps, // change the Baud Rate according to your XBee Serial.begin(115200); } void loop() { // check that there's something in the serial buffer if (Serial.available() > 0) { // read the byte and store it in our variable // the byte sent is actually an ascii value incomingByte = Serial.read(); // note the upper casing of each letter! // each letter turns a motor different way. //===== Grip // Grip in if (incomingByte == controls[0]) { gripIn(); } // Grip Out if (incomingByte == controls[1]) { gripOut(); } //Wrist if (incomingByte == controls[2]) { //digitalWrite(wristPin1, LOW); //digitalWrite(wristPin2, HIGH); wristUp(); } if (incomingByte == controls[3]) { wristDown(); } //===== Elbow // Elbow Up if (incomingByte == controls[4]) { elbowUp(); } // Elbow Down if (incomingByte == controls[5]) { elbowDown(); } //===== Shoulder // Shoulder Up if (incomingByte == controls[6]) { shoulderUp(); } // Shoulder Down if (incomingByte == controls[7]) { shoulderDown(); } //===== Base
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
// Base Right if (incomingByte == controls[8]) { baseRight(); } // Base Left if (incomingByte == controls[9]) { baseLeft(); } // Light ON if (incomingByte == controls[10]) { digitalWrite(ledPin, HIGH); } // Light OFF if (incomingByte == controls[11]) { digitalWrite(ledPin, LOW); } // if a O is sent make sure the motors are turned off if (incomingByte == controls[12]) { allStop(); } delay(100); } } void gripIn() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, HIGH); } void gripOut() { digitalWrite(gripEnablePin, HIGH); digitalWrite(gripPin2, LOW); digitalWrite(gripPin1, HIGH); } void wristUp() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, HIGH); } void wristDown() { digitalWrite(wristEnablePin, HIGH); digitalWrite(wristPin2, LOW); digitalWrite(wristPin1, HIGH); } void elbowUp() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, HIGH); } void elbowDown() { digitalWrite(elbowEnablePin, HIGH); digitalWrite(elbowPin2, LOW); digitalWrite(elbowPin1, HIGH); } void shoulderUp() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, HIGH); } void shoulderDown() { digitalWrite(shoulderEnablePin, HIGH); digitalWrite(shoulderPin2, LOW); digitalWrite(shoulderPin1, HIGH); } void baseRight() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin1, LOW); digitalWrite(basePin2, HIGH); } void baseLeft() { digitalWrite(baseEnablePin, HIGH); digitalWrite(basePin2, LOW); digitalWrite(basePin1, HIGH);
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
} void allStop() { digitalWrite(baseEnablePin, LOW); digitalWrite(basePin1, LOW); digitalWrite(basePin2, LOW); digitalWrite(shoulderEnablePin, LOW); digitalWrite(shoulderPin1, LOW); digitalWrite(shoulderPin2, LOW); digitalWrite(elbowEnablePin, LOW); digitalWrite(elbowPin1, LOW); digitalWrite(elbowPin2, LOW); digitalWrite(wristEnablePin, LOW); digitalWrite(wristPin1, LOW); digitalWrite(wristPin2, LOW); digitalWrite(gripEnablePin, LOW); digitalWrite(gripPin1, LOW); digitalWrite(gripPin2, LOW); } //=========== Arduino End
Following is the Processing Source Code. You'ill need the background image file, and all the buttons image files in order to see those control buttons on the screen. And all the background and buttons are provided ad there are in the folder called data. You will need to have this folder located in the same folder of the Processing code (RobotArmControl.pde) // Language: Processing // RobotArmControl.pde // by Sam Thongrong Feb 26, 2012 // load the serial library for Processing import processing.serial.*; // instance of the serial class Serial port; // control commands array: // GripOut, GripIn, WristUp, WristDown, ElbowUp, ElbowDown, // ShoulderUp, shoulderDown, BaseCW, BaseCCW, LightOn, LightOff, Stop int[] controls = new int[] { 0x47, 0x67, 0x57, 0x77, 0x45, 0x65, 0x53, 0x73, 0x42, 0x62, 0x4c, 0x6c, 0x58 }; // Image button. // Loading images and using them to create a button. ImageButtons GripIn; ImageButtons GripOut; ImageButtons WristUp; ImageButtons WristDown; ImageButtons ElbowUp; ImageButtons ElbowDown; ImageButtons ShoulderUp; ImageButtons ShoulderDown; ImageButtons BaseCW; ImageButtons BaseCCW; ImageButtons LightOn; ImageButtons LightOff; ImageButtons Pause; // background PImage bg; // set the font PFont myFont; void controlGUI() { bg = loadImage("background.jpg"); background(bg); int buttonSize = 44; PImage selected = loadImage("controlSel.png"); //Grip In PImage gripInImage = loadImage("controlIn.png"); PImage gripInOver = loadImage("controlInOver.png"); GripIn = new ImageButtons(30, 83, buttonSize, buttonSize,
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
gripInImage, gripInOver, selected); //Grip Out PImage gripOutImage = loadImage("controlOut.png"); PImage gripOutOver = loadImage("controlOutOver.png"); GripOut = new ImageButtons(78, 83, buttonSize, buttonSize, gripOutImage, gripOutOver, selected); //Wrist Up PImage wristUpImage = loadImage("controlUp.png"); PImage wristUpOver = loadImage("controlUpOver.png"); WristUp = new ImageButtons(150, 36, buttonSize, buttonSize, wristUpImage, wristUpOver, selected); //Wrist Down PImage wristDownImage = loadImage("controlDown.png"); PImage wristDownOver = loadImage("controlDownOver.png"); WristDown = new ImageButtons(198, 36, buttonSize, buttonSize, wristDownImage, wristDownOver, selected); //Elbow Up PImage elbowUpImage = loadImage("controlUp.png"); PImage elbowUpOver = loadImage("controlUpOver.png"); ElbowUp = new ImageButtons(258, 83, buttonSize, buttonSize, elbowUpImage, elbowUpOver, selected); //Elbow Down PImage elbowDownImage = loadImage("controlDown.png"); PImage elbowDownOver = loadImage("controlDownOver.png"); ElbowDown = new ImageButtons(306, 83, buttonSize, buttonSize, elbowDownImage, elbowDownOver, selected); //Shoulder Up PImage shoulderUpImage = loadImage("controlUp.png"); PImage shoulderUpOver = loadImage("controlUpOver.png"); ShoulderUp = new ImageButtons(208, 160, buttonSize, buttonSize, shoulderUpImage, shoulderUpOver, selected); //Shoulder Down PImage shoulderDownImage = loadImage("controlDown.png"); PImage shoulderDownOver = loadImage("controlDownOver.png"); ShoulderDown = new ImageButtons(256, 160, buttonSize, buttonSize, shoulderDownImage, shoulderDownOver, selected); //Base CW PImage baseCWImage = loadImage("controlCW.png"); PImage baseCWOver = loadImage("controlCWOver.png"); BaseCW = new ImageButtons(130, 234, buttonSize, buttonSize, baseCWImage, baseCWOver, selected); //Base CCW PImage baseCCWImage = loadImage("controlCCW.png"); PImage baseCCWOver = loadImage("controlCCWOver.png"); BaseCCW = new ImageButtons(178, 234, buttonSize, buttonSize, baseCCWImage, baseCCWOver, selected); //Light On PImage lightOnImage = loadImage("LightOn.png"); PImage lightOnOver = loadImage("LightOnOver.png"); LightOn = new ImageButtons(30, 184, buttonSize, buttonSize, lightOnImage, lightOnOver, selected); //Light Off PImage lightOffImage = loadImage("LightOff.png"); PImage lightOffOver = loadImage("LightOffOver.png"); LightOff = new ImageButtons(78, 184, buttonSize, buttonSize, lightOffImage, lightOffOver, selected); } void setup() { // List all the available serial ports in the output pane. // You will need to choose the port that the Arduino board is // connected to from this list. The first port in the list is // port #0 and the third port in the list is port #2. //println(Serial.list()); // Open the port that the Arduino board is connected to // (in this case #0) // Make sure to open the port at the same speed Arduino is // using (112500bps) //port = new Serial(this, Serial.list()[1], 112500); // On Window PC, use "Outgoing" of the bluetooth device // This one for XBee port = new Serial(this, "COM30", 115200);
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
// screen size of the program //size(145, 455); size(400, 300); smooth(); // test ellipse ellipseMode(RADIUS); textFont(createFont("Verdana", 14)); controlGUI(); } void updateDisplay() { GripIn.update(); GripIn.display(); GripOut.update(); GripOut.display(); WristUp.update(); WristUp.display(); WristDown.update(); WristDown.display(); ElbowUp.update(); ElbowUp.display(); ElbowDown.update(); ElbowDown.display(); ShoulderUp.update(); ShoulderUp.display(); ShoulderDown.update(); ShoulderDown.display(); BaseCW.update(); BaseCW.display(); BaseCCW.update(); BaseCCW.display(); LightOn.update(); LightOn.display(); LightOff.update(); LightOff.display(); } //Send Commands void sendCommands() { // Grip if(GripIn.pressed) { port.write(controls[0]); //println("Grip In: " + (char)controls[0]); } if(GripOut.pressed) { port.write(controls[1]); //println("Grip Out: " + (char)controls[1]); } if(mouseX > 30 & mouseX < 129 && mouseY > 51 & mouseY < 79) { port.write(controls[12]); //println("Grip Stop! " + (char)controls[12]); } // Wrist if(WristUp.pressed) { port.write(controls[2]); //println("Wrist Up: " + (char)controls[2]); } if(WristDown.pressed) { port.write(controls[3]); //println("Wrist Down: " + (char)controls[3]); } if(mouseX > 148 & mouseX < 248 && mouseY > 5 & mouseY < 33) { port.write(controls[12]); //println("Wrist Stop! " + (char)controls[12]); } // Elbow if(ElbowUp.pressed) { port.write(controls[4]); //println("Elbow Up: " + (char)controls[4]); } if(ElbowDown.pressed) {
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
port.write(controls[5]); //println("Elbow Down: " + (char)controls[5]); } if(mouseX > 258 & mouseX < 358 && mouseY > 51 & mouseY < 79) { port.write(controls[12]); //println("Elbow Stop! " + (char)controls[12]); } //Shoulder if(ShoulderUp.pressed) { port.write(controls[6]); //println("Shoulder Up: " + (char)controls[6]); } if(ShoulderDown.pressed) { port.write(controls[7]); //println("Shoulder Down: " + (char)controls[7]); } if(mouseX > 208 & mouseX < 308 && mouseY > 130 & mouseY < 158) { port.write(controls[12]); //println("Shoulder Stop! " + (char)controls[12]); } // Base if(BaseCW.pressed) { port.write(controls[8]); //println("Base Rotate CW: " + (char)controls[8]); } if(BaseCCW.pressed) { port.write(controls[9]); //println("Base Rotate CCW: " + (char)controls[9]); } if(mouseX > 130 & mouseX < 230 && mouseY > 202 & mouseY < 230) { port.write(controls[12]); //println("Base Stop! " + (char)controls[12]); } // Light if(LightOn.pressed) { port.write(controls[10]); //println("Light On: " + (char)controls[10]); } if(LightOff.pressed) { port.write(controls[11]); //println("Light Off: " + (char)controls[11]); } } void draw() { updateDisplay(); sendCommands(); } // Button & ImageButtons Classes class Button { int x, y; int w, h; color basecolor, highlightcolor; color currentcolor; boolean over = false; boolean pressed = false; void pressed() { if(over && mousePressed) { pressed = true; } else { pressed = false; } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x & mouseX <= x+width && mouseY >= y & mouseY <= y+height) { return true; } else { return false; } } }
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
class ImageButtons extends Button { PImage base; PImage roll; PImage down; PImage currentimage; ImageButtons(int ix, int iy, int iw, int ih, PImage ibase, PImage iroll, PImage idown) { x = ix; y = iy; w = iw; h = ih; base = ibase; roll = iroll; down = idown; currentimage = base; } void update() { over(); pressed(); if(pressed) { currentimage = down; } else if (over){ currentimage = roll; } else { currentimage = base; } } void over() { if( overRect(x, y, w, h) ) { over = true; } else { over = false; } } void display() { image(currentimage, x, y); } } // Processing End To control Robot Arm motor, moves the cursor to the required button and click. To stop operation just move the cursor to any label. Robot will stop. In order to operate multiple motors at once, move the cursor to the buttons required, and click those buttons. But do not drag cursor pass over the labels, that will cause the operation to stop Enjoy!.
Image Notes
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/
File Downloads
RobotArmSourcesCode.zip (249 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'RobotArmSourcesCode.zip']
Image Notes 1. XBee Module on the PC(Laptop).This is the FTDI Cable Mod. I modified the cable to be located underneath the XBee module. 2. XBee Module on the Robotic Arm
Related Instructables
DIY Mod an Omnibot 80's Robot with Voice, Camera, Servos, Bluetooth by djsures
PROTEI_007 by gabriellalevine Modifications to Robot Arm for Opto Coupler Feedback, OWI 535, Edge etc by jomac_uk
Build "The RevIO" (Arduino OCCU(PI) Bot by Clone) My Way by sath02 randofo
http://www.instructables.com/id/Make-Wired-Robotic-Arm-Edge-to-Wireless-with-DIY/