Sei sulla pagina 1di 21

Food Living Outside Play Technology Workshop

Build a big crane game


by marc.cryan on March 3, 2012

Table of Contents

Build a big crane game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Intro: Build a big crane game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Step 1: Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 2: Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Step 3: X - Axis Mechanical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Step 4: Y-Axis mechanical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Step 5: Z-axis mechanical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 6: X-axis electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Step 7: Y axis electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Step 8: Y and Z axis electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 9: IR Control Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 10: IR Receiver Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Step 11: IR Decode Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Step 12: X-axis control code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Step 13: Y and Z axis code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Step 14: Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Step 15: Play with it . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Step 16: What's next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Step 17: Complete Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

Step 18: Complete Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

http://www.instructables.com/id/Build-a-big-crane-game/
Intro: Build a big crane game
How to build a whole room crane game. Based on the arcade style 'Crane Game' or 'Claw Machine'. This is a continuation of a previus instructable titled CRANE GAME
in which we built a 2-axis crane game in a door frame. We have now added a third axis and wireless control. And made it big.

A few technical and functional improvements:

Less wires - controllers and batteries move with the motors and are signaled with IR light.
Precision not needed - I was able to set-up a 8x10ft track without measuring anything
Reproducible - used standard parts, used the same components in many spots
Expandable - use longer tracks to make it bigger - track cost is about 50cents a foot.
Removable - hangs from the ceiling by 4 small hooks
Future? Could be used as basis for a big 3D printer

Overview

1. Materials
2. Frame
3. X-Axis Mechanical
4. Y-Axis Mechanical
5. Z-Axis Mechanical
6. X-Axis Electronics
7. Y-Axis Electronics
8. Z-Axis Electronics
9. IR Control Overview
10. IR Receive Circuit
11. IR Transmitter (TV remote)
12. IR Decode Process
13. X-Axis Control Code
14. Y/Z - Axis Control Code
15. What's next?
16. Complete Wiring
17. Complete Code

note: this still has some holes in it, feel free to ask for stuff

http://www.instructables.com/id/Build-a-big-crane-game/
http://www.instructables.com/id/Build-a-big-crane-game/
http://www.instructables.com/id/Build-a-big-crane-game/
Step 1: Materials
Materials:
6 - 6' J channel
7 - Big continous servo motors
1 - Roll of electrical tape
2 - Arduino UNO boards
3 - Small peices of perferatored board
2 - IR demodulator
1 - Universal TV remote control
1 - 25' coiled phone chord
1 - 15' straight phone chord
1 - Roll packing tape
1 - Pre-made claw with servo
2 - 4 AA battery packs, rechargable
6 - screw hooks
3 - Peice plywood - 2x6" each
1 - roll metal plumbers strap

Tools:
- Drill
- Computer
- Soldering iron

Step 2: Frame
Frame:

X-Axis -
-The X-Axis consists of 2 parrallel tracks mounted to the ceiling about 9' appart
Y-Axis
-One track that is supported on either end by the Y-Axis

To Make the Tracks:


- Place 2 J channels back-to-back
- Run a peice of clear tape down the top seam, and fold over
- Run a second peice of tape along the bottom

Using 6 peices of J channel, make 3 tracks

Hang X-axis
-Put 2 screw hooks in the ceiling, one at each end of the expected X tracks
-Cut 4 peices of plumbers strap, about 6 inches long
-Thread the peice of plumbers strap towards the end of each track
-Bend the plumbers strap, like an L, so that it will hold up the track
-Hang the other end of the plumbers strap on the hooks on the ceiling
-Adjust as needed

Prepare Y-axis
-The Y axis will be suspended from the motorized carriages on the X-axis
-For now, cut 2 more pieces of plumbers strap and thread through each end of Y-axis

http://www.instructables.com/id/Build-a-big-crane-game/
http://www.instructables.com/id/Build-a-big-crane-game/
Step 3: X - Axis Mechanical
X-Axis Mechanica
The X axis has 2 motorized carrages

Modify servos for continous rotation


-Take the 4 screws out of the fron of the motor
-Take off the smaller part of the plastic shell
-Disassemble gears
-There is a small white disk around the shaft of the potentioometer
-Remove the smal white disk
-Re-assemble

Make plywood base


- Cut 2 pecised of 1/4 ply (used MDF) to 3x6"
- Drill/cut 2 slots in each peice - 1/4" wide, 2inch long, and 3.5" apart [CHECK THIS]

Attach Servos
-Attach a large wheel to the servo, use a screw
-Wrap wheel with something for friction (used this sticky foam)
-Put the servo Bracket in the slot
-Wrap servo and base with electrical tape to secure
-Repeat with the second servo
-When done, weels should be a little less than 1/8" appart (3/32" ?)

Hang the assembled carraiges, one on each X axis

Put an eye-hook on the bottom of each platform

Hange the Y-axis track from these hooks using plumbers strap

http://www.instructables.com/id/Build-a-big-crane-game/
Step 4: Y-Axis mechanical
The Y axis has one carraige.

Make the carraige just like the ones for the X axis.

But -- add a third servo, tapped to the bottom of the platform. This will control the claw (Z axis)

http://www.instructables.com/id/Build-a-big-crane-game/
Step 5: Z-axis mechanical
Tie a 8-10 ft string to the wheel on the third servo of the Y axis carriage

Assemble a claw -- used claw from sparkfun __________

Tie claw to other end of string

Step 6: X-axis electronics


Slave X-axis board

Cut a piece of proto board about 1x1"


Follow the schematic to solder on 2 3-pin headers and 3 screw terminals (used 4, 2 sets of 2)
Cut a 12' lenth of non-curly phone chord.
Tape cord to the bottom of the Y-axis
Connect 3 wires to the proto board
Using electrical tape, attach proto board to X-axis carraiage

Master X axis board

***
Arduino pins used:

D11 IR receive
D9 Servo Xa
D10 Servo Xb

http://www.instructables.com/id/Build-a-big-crane-game/
Step 7: Y axis electronics
Master X-axis board - this attaches to an arduino, like a mini-sheild.
This board had connectors for 3 servo motors (2 for Y axis, 1 for Z). It will also have screw terminals for power. In addition to the connectors it will have an IR reciever,
this is a special component that decodes IR signals from TV remotes and then sends them out to the arduino.
Here are the parts:

Cut a peice of proto boardboard about 1x3"


Cut 3 peices of header that are 3 pins long (these will go to servos)
Cut 4 pecies of header that have just one pin (these will go to control pins on arduino and to ground)
A 2 terminal screw terminal (for power)

See the schematic for wiring. Here are some general things to know:

Arduino ground connects to battery negative


Servos have 3 pins; power, ground, and control. All the grounds can be connected together, and to Arduino ground.
All the power pins can be connected to the battery positive terminal. Each control pin goes to a seperate pin on the Arduino board.
The IR decoder connector has 3 pins; power, ground and a data out. Power goes to the 5V port on the arduino. Ground goes to Arduino ground. And Data out
goes to its own pin on the Arduino.
When assembled the servo connectors and the screw terminals are on the top of the board. The single pin connections come out the bottom of the board and go
to the Arduino pins.

***
Aduino pins used:

D11 - IR receiver
D9 Servo Ya
D10 Servo Yb
D2 Servo Z
D6 Servo Claw

http://www.instructables.com/id/Build-a-big-crane-game/
Step 8: Y and Z axis electronics
The Zaxis doesn't have it's own board. It is just goes to one of the connectors on the Y board. 1 servo opens and clses the claw, one servo raises and loweres the claw
by winding up a string on a spool.

Step 9: IR Control Overview


IR signals are send from a universal television remote control. The signals are received by the Arduinos on the X and Y axis.
General steps:

build a circuit to get the signals


decode some signals for from the controller
program the Arduinos do do things when they get a signal.

Also - it is helpful to get everything working with wires first, then substitute the IR control. I started by sending commands from a laptop over the USB ports.

Step 10: IR Receiver Circuit


The circuit to recieve IR signals is pretty simple, as long as you have right parts! Mainly an IR receiver and demodulator.
The IR reciever has 3 pins; power (to 5V on arduino), ground (to arduino ground), and a digital output pin (sends data to a pin on the arduino).

Here is the IR receiver I am using: IR Sensor IC 38KHZ Vishay Infrared Receivers - Mfg p/n TSOP38238SS1V - mouser p/n 782-TSOP38238SS1V -- Pinouts are 1:data
out, 2:Grnd: 3:Vs (supply Voltage, 5V). Facing the bump pine 1 is on the left.

http://www.instructables.com/id/Build-a-big-crane-game/
Step 11: IR Decode Process
The buttons we are using are: up, down, left, right, select, and menu. DVD players usually use all these buttons, so program the TV remote to send DVD signals from a
DVD player that you do not have.

For the univerasal remove, have used code: 1119 which is for a ACESONIC DVD player.

The code below will display the values that the arduino gets from the remote.

Write down the numbers for each button. These numbers will be added to the Arduino code.

Arduino Code:

/// read IR remote

//IR setup - stuff


#include <IRremote.h>

int RECV_PIN = 11;


IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}

void loop(){
// read IR buttons
if (irrecv.decode(&results)) {
long x = results.value;
Serial.println(results.value, HEX); //for decoding buttons
Serial.println(x);
}
delay(100);

http://www.instructables.com/id/Build-a-big-crane-game/
Step 12: X-axis control code
The X axis moves in two directions.

X-axis code:

#include <Servo.h>
#include <Wire.h>
Servo XA;
Servo XB;

int dir = 0;
int oldDir = 0;

//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;
//

unsigned long time;


unsigned long timeIR;
unsigned long timeDiff;

void setup(){
Wire.begin();
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}

void loop(){
http://www.instructables.com/id/Build-a-big-crane-game/
// read IR buttons and set the action //

if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
// Serial.println(x);
timeIR = millis(); //record time of button push

switch(x){

case 351005205:
action = "up arrow";
dir = 5;
break;

case 350988375:
action = "down arrow";
dir = 6;
break;

case 350963895:
action = "left arrow";
dir = 1;
break;

case 350976645:
action = "right arrow";
dir = 2;
break;

case 350952165:
action = "ok/mute";
dir = 3;
break;

case 350986335:
action = "B2";
dir = 4;
break;

case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}

timeDiff = millis() - timeIR;


if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}

if(action != oldAction){
if (action == "up arrow"){
XA.attach(9);
XA.write(0);
XB.attach(10);
XB.write(180);
Serial.println("X go away");
delay(100);
}
if(action == "down arrow"){
XA.attach(9);
XA.write(180);
XB.attach(10);
XB.write(0);
Serial.println("X come back");
delay(100);
}
if ((action == "none") && (oldDir == 5 || oldDir==6)){
XA.detach();
XB.detach();
Serial.println("stop x axis");
}
//send commands
Wire.beginTransmission(9);
Wire.send(dir);
Wire.endTransmission();
Serial.println("send dir ");
Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
http://www.instructables.com/id/Build-a-big-crane-game/
delay(100);

Step 13: Y and Z axis code


The code to control the Y and Z axii are both loaded onto the same Arduino., So the code is all in one program.
The Y axis moves in 2 directions, the Z axis goes up and down, and the claw is opened and closed.

Arduino Code:

#include <Servo.h>
#include <Wire.h>

Servo YA;
Servo YB;
Servo Z;
Servo Claw;

//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;

unsigned long time;


unsigned long timeIR;
unsigned long timeDiff;

int dir = 0;
int oldDir = 0;

void setup(){
Serial.begin(9600);
irrecv.enableIRIn(); // Start the IR receiver
}

void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push

switch(x){

case 351005205:
action = "up arrow";
dir = 5;
break;

case 350988375:
action = "down arrow";
dir = 6;
break;

case 350963895:
action = "left arrow";
dir = 1;
break;

case 350976645:
action = "right arrow";
dir = 2;
break;

case 350952165:
action = "ok/mute";
dir = 3;
break;

case 350986335:
action = "B2";
dir = 4;
break;

case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}

timeDiff = millis() - timeIR;


http://www.instructables.com/id/Build-a-big-crane-game/
if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}

if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}

if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}

if(action == "ok/mute"){
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}

if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){


YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}

Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);

}#include <Servo.h>
#include <Wire.h>

Servo YA;
Servo YB;
Servo Z;
Servo Claw;

//IR stuff
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
String action;
String oldAction;

unsigned long time;


unsigned long timeIR;
unsigned long timeDiff;

int dir = 0;
int oldDir = 0;

void setup(){
Serial.begin(9600);
http://www.instructables.com/id/Build-a-big-crane-game/
irrecv.enableIRIn(); // Start the IR receiver
}

void loop(){
// read IR buttons and set the action //
if (irrecv.decode(&results)) {
long x = results.value;
//Serial.println(results.value, HEX); //for decoding buttons
//Serial.println(x);
timeIR = millis(); //record time of button push

switch(x){

case 351005205:
action = "up arrow";
dir = 5;
break;

case 350988375:
action = "down arrow";
dir = 6;
break;

case 350963895:
action = "left arrow";
dir = 1;
break;

case 350976645:
action = "right arrow";
dir = 2;
break;

case 350952165:
action = "ok/mute";
dir = 3;
break;

case 350986335:
action = "B2";
dir = 4;
break;

case 4294967295:
break;
}
irrecv.resume(); // Receive the next value
}

timeDiff = millis() - timeIR;


if ((timeDiff > 200) && dir !=0) { //if no button
dir = 0;
action = "none";
}

if(action != oldAction){
if (action == "left arrow"){
YA.attach(9);
YA.write(0);
YB.attach(10);
YB.write(180);
Serial.println("Y go left");
delay(100);
}
if(action == "right arrow"){
YA.attach(9);
YA.write(180);
YB.attach(10);
YB.write(0);
Serial.println("Y go right");
delay(100);
}

if(action == "B2"){
Z.attach(2);
Z.write(180); //down
Claw.attach(6);
Claw.write(100); // open?
Serial.println("claw down and open");
delay(100);
}

if(action == "ok/mute"){

http://www.instructables.com/id/Build-a-big-crane-game/
Z.attach(2);
Z.write(0); //up
Claw.attach(6);
Claw.write(20); // close?
Serial.println("claw up and close");
delay(100);
}

if((action == "none") && (oldDir == 1 || oldDir == 2 || oldDir == 3 || oldDir ==4)){


YA.detach();
YB.detach();
Z.detach();
Claw.detach();
Serial.println("all stop");
delay(100);
}

Serial.print(dir);
Serial.print(" ");
Serial.println(action);
}
oldDir = dir;
oldAction = action;
delay(100);

Step 14: Assembly


X axis motors/boards things (carriages?) hang from the X-axis tracks that hang from the ceiling.

The Y axis tracks hang from the X-axis carriages.

The Y axis carriage goes on the Y axis track.

http://www.instructables.com/id/Build-a-big-crane-game/
Step 15: Play with it
Give the conroller to the kids and let them go nuts. The whole thing does move a bit slowly, but that is probably for the best.

http://www.instructables.com/id/Build-a-big-crane-game/
Step 16: What's next
A few basic things to improve:

Claw is not great, probably just need more power to the open/close servo
Batteries have to be removed and to recharge them, so that is a hassle
If you move to a different spot in the room the controls no longer make sense

More awsome things to do:

Control with SmartPhone


Add some automation; can some routines be preprgrammed?
Add sensors/camera so the claw can find stuff on its own?
Maybe write a program to have the claw take stuff out of a toy box and arrange it in the room? Could it be used to serve salad?

Step 17: Complete Wiring


Here is all the wiring in one place.

Does this ad seem big?

http://www.instructables.com/id/Build-a-big-crane-game/
Step 18: Complete Code
Here is all the code in one place:

Related Instructables

knex claw
machine [first
Marc's entries CRANE GAME My mini bartop K'nex Claw Arcade Machine
to on site] that has
by marc.cryan arcade machine Machine Game (Photos) by instructans by
Sparkfun/Ponoko/GeekDad (pacman)
Contest (Photos) (video) by hacker3455 knexinventer
(Photos) by T86157
by marc.cryan
newtonn2

http://www.instructables.com/id/Build-a-big-crane-game/

Potrebbero piacerti anche