Vous êtes sur la page 1sur 41

2- AXIS ROBOT ARM

Book 5

Magnetcode for 2-Axis Robot Arm

Copyright © 2016 Bizchip Technology Centre. All Rights Reserved.


Unauthorized duplication or distribution is strictly prohibited.

Bizchip ® Technology Centre 3363-2, JALAN 18/31, TAMAN SERI SERDANG, 43300 SERI KEMBANGAN, SELANGOR.

TEL: 012-297 9320 FAX: 03-8948 7451 WEB: http://www.magnetcode.com EMAIL: info@magnetcode.com

Page 1 of 41
2- AXIS ROBOT ARM

Table of Content
Ref. Content Page
1 List of Equipment 3

2 List of Materials 4

3 Drilling Part 6

4 Installing Part 11

5 Wiring Part 15

6 Install Magnetcode 20

7 Magnetcode Graphic Design 21

8 Arm Robot Project 1- Candy Delivery Machine 22

9 Arm Robot Project 2- Swinging Container Game 28

10 Arm Robot Project 3- Remote Control Robotic Arm 34

Page 2 of 41
2- AXIS ROBOT ARM

1.0 List of equipment:


Hot Glue Gun Hot Glue Sticks

Cordless Drill Drill Bits


(3mm,4.5mm,5mm,6mm,12mm,14mm)

Wire Cutter Screwdriver Phillips Head

Page 3 of 41
2- AXIS ROBOT ARM

2.0 List of materials:


Carrot Project Board Servo Motor 6 Pin Toggle Switch
Quantity: 1 Quantity: 2 Quantity: 1

Green LED Red LED Yellow LED


Quantity: 1 Quantity: 1 Quantity: 1

Green Push Button Red Push Button Mini Tupperware


Quantity: 1 Quantity: 1 Quantity: 2

Page 4 of 41
2- AXIS ROBOT ARM

Box with Lead (h:2.5cm, Box with Lead (h: 5cm, Connector Wire
w:4cm, l:7cm) w:9.5cm, l:16cm)
Quantity: 2 Quantity: 1

Servo Motor Horn Acrylics (11cmx3cm) 8 AA Batteries in


Quantity: 2 Quantity: 3 Holder
Quantity: 1

4 AA Batteries in Holder L Shape Bracket


Quantity: 1 Quantity: 2

Page 5 of 41
2- AXIS ROBOT ARM

3.0 Drilling Part


Arm Drill

1. Take the acrylics with the length 11cm and width 3cm.
2. First hole with diameter 3mm, from left to right in distance 1.5cm and 2.5cm from above to
below
3. Second hole in distance 0.9cm to the below from the first hole with the same diameter,
3mm.
4. Third hole is below of the second hole in 0.9cm with 3mm diameter.
5. For the fourth hole, 1.3cm from above and 2cm from right side. Follow by another hole
which is 0.8cm from right side with same height from above, 1.3cm.
6. Another hole is on the bottom, first hole is 0.8cm from below and 1.5cm from right side,
which is on center line of the acrylic.
7. Then, other hole is 1.2cm above from the previous hole and at the center too.
8. Repeat the step 1-4 with the others acrylic.
2cm

2.5cm 1.3cm

0.9cm
0.9cm

2cm
0.8cm

1.5cm 0.8cm
9. Then, take a servo motor horn.
10. One the servo motor horn, make a hole on the third tiny hole using 3mm diameter from
center to the left and right. Refer the picture below as a reference.

Page 6 of 41
2- AXIS ROBOT ARM

Mini Box Drill

1. First hole start on the top of the box.

2. Make a hole with diameter 16mm from the left 2cm and from above 2cm of the box, for a
led.
3. From the first hole, to the right 2.6cm make another hole with diameter 5mm.
4. Refer the diagram below:

2cm
2cm

2.6cm

5mm
16mm

5. Then, on the both side of the box, right and left make a hole with diameter 6mm on the
center which is from left 2cm and from above 1.3cm.

1.3cm
6mm

2cm

Page 7 of 41
2- AXIS ROBOT ARM

Body Drill

1. Removed the body lead.


2. First hole for the body (on the lead) from front view, from left (1.5cm) and from below
(0.5cm) of the cover, make a hole with diameter 4.5mm.

3. Then, second hole is on the right of the first hole which in distance 0.5cm from right with
same diameter, 4.5mm.
4. For the last hole on center of the lead which is 4.75cm from left to right and 1.5cm from
above to below, make a hole with diameter 12mm.

1.5cm
1.5cm
1.5cm 4.75cm

12mm
4.5mm

0.5cm

Page 8 of 41
2- AXIS ROBOT ARM

5. On the top of the body, hole must be made 4.7cm from the left to right with a length 2.5cm
from above to below with the diameter 14mm.

2.5cm

4.7cm

14mm
6. The first hole with diameter 6mm for left side of the body is from bottom to the upper in
distance 2.5cm and from left to the right in 2.5cm.

Page 9 of 41
2- AXIS ROBOT ARM

7. The second hole is above the first hole, 2cm from it in center line with diameter 5mm. Refer
the diagram below:

2.5cm

2cm

5mm
2.5cm

6mm

Page 10 of 41
2- AXIS ROBOT ARM

4.0 Installing Part


Mini Box
1. Start with one mini box, install the green push button from inside and let the button out
through the hole.
2. For the smaller hole, install green LED from inside.
3. Glue both LED with hot glue gun from inside.
4. Then, repeat the step 1-3 with red push button and red LED.

Body
1. First, on the left of the body, install yellow led in the upper hole through inside the box.
2. Glue the LED to avoid it from remove.
3. The hole below, install the switch and make sure the toggle is outside the box.

4. Then, on top of the box install the servo motor. Let the shaft out through the hole.
5. Put glue around the servo motor and avoid the glue from shaft. Refer the picture below.

Page 11 of 41
2- AXIS ROBOT ARM

Arm
1. Take three acrylics and construct it like in the picture below. Screw it so that it cannot be
removed.

2. Then, glue the servo motor to the ‘L’ bracket using hot glue gun and screw it to arm. Refer
the picture below and make sure the wire of the servo motor is on upper

Page 12 of 41
2- AXIS ROBOT ARM

3. Take another ‘L’ bracket and screw it to the other end of the arm. Also screw the box to the
‘L’ bracket so it will be the same like in the picture below:

4. On the middle of arm, screw the servo motor horn under it. Refer the picture below:

Page 13 of 41
2- AXIS ROBOT ARM

5. Screw another servo motor horn on the outside of the mini box and assemble it to the
motor’s shaft.

Page 14 of 41
2- AXIS ROBOT ARM

5.0 Wiring Part


Step1: Connect the servo motor in the box to the project board

SIG
5V

SERVO1
GND

Step2: Connect the servo motor at the arm to the project board

SIG
5V

SERVO2
GND

Step3: Connect toggle switch to the project board

ONOFF2

5V

ONOFF3

Page 15 of 41
2- AXIS ROBOT ARM

Step4: Connect yellow LED to the project board

Step5: Connect red push button to the project board

DIN1

GND

Step6: Connect red LED to project board

DOUT1

GND

Page 16 of 41
2- AXIS ROBOT ARM

Step7: Connect green push button to project board

DIN2

GND

Step8: Connect green LED to the project board

GND

DOUT2

Step9: Connect 4 AA Batteries to the project board

POWER 3

Page 17 of 41
2- AXIS ROBOT ARM

Step10: Connect 8 AA batteries to the project board

POWER 1

Page 18 of 41
2- AXIS ROBOT ARM

Page 19 of 41
2- AXIS ROBOT ARM

6.0 Install Magnetcode

Step 1: Download the latest Step 2: In the Android phone Step 3: Click the downloaded
version of Magnetcode at:
magnetcode.com/app.html Magnetcode app (.apk
‘Setting’ app . Access
file) to start installation.
‘Security’ page and tick
‘Unknown sources’.

Note: Magnetcode only run on


platform Android 4.2 and above.

Page 20 of 41
2- AXIS ROBOT ARM

7.0 Magnetcode Graphic Design

Graphic design page is important for user interfacing. User can control his / her phone or
project board features through the graphic design page.

User can set title, background, buttons and LCD components in the graphic design page by
using related commands.

Title Background

User can use User can use


command to set title command to set the
text, text color and background color or
background color. background image.

Button
LCD
There are 9 buttons in
There is 1 LCD in the the graphic design
graphic design page. page. The buttons are
arranged in 3 rows (1,
LCD is used to show
2, 3) x 3 columns (A,
system status and
B, C).
message.
The buttons are used
to execute the preset
User can use commands.
command to hide or
show it. They can
also set LCD text, User can use
text size, text command to hide or
alignment, show each button.
background color, They can also set
image, text color. text, text size,
background color,
text color for each
button.

Page 21 of 41
2- AXIS ROBOT ARM

8.0 Arm Robot Project 1– Candy Delivery Machine

For project 1, we will design a project to deliver candy from left to right. Then pow the
candy and back to the left side.

Youtube Video Link- https://youtu.be/dkTLfRUatvM

Start

Set the machine facing


up and at left side

No
Red button is
pressed?

Yes

Machine turn to right


side. LED on.

Pause for 1 second


No

Machine pow the candy


down.

Turn back to left side.


LED off.

Page 22 of 41
2- AXIS ROBOT ARM

Command Related

Command Command Function


Group
Read_Controller Controller I/O Read all sensors values from the project board.

If C_Din1= 1 Decision If a specific digital sensor value on the project


board matches with a specific condition
Timer= 1sec Other Pause the program for a specific duration of
time.
Servo1= 0 Controller I/O Control servo motor angle on the project board.

Dout1= On Controller I/O Turn on or off DOUT output on the project


board
End If Decision Terminate any ‘if’ command.

Goto= 1 Other Jump to a specific line.

Page 23 of 41
2- AXIS ROBOT ARM

Program Description

LINE 1: Servo1= 0 To set the machine at the left side facing


up.
LINE 2: Servo2= 0

LINE 3: Read_Controller Read all the inputs at the controller.

LINE 4: If C_Din1= 1
If red button is pressed, red LED will turn
LINE 5: Dout1=on
on and the machine will turn to the right
LINE 6: Servo1= 180 side. Pause for 1 second.

LINE 7: Timer=1sec

LINE 8: Servo2=180 The servo motor will head down the


machine to pow the candy. Pause for 1
LINE 9: Timer=1 sec second.

LINE 10: Servo2= 0 The servo motor will head up the


machine. Pause for 1 second.
LINE 11: Timer=1 sec

LINE 12: Servo1=0


The machine will turn to left side, red
LINE 13: Dout1= Off LED will turn off.

LINE 14: End If

Jump to LINE 3 and execute the program


LINE 15: Goto= 3 again.

Page 24 of 41
2- AXIS ROBOT ARM

Program Operation

The diagram below shows the flow of the program when no button is pressed.

LINE 1: Servo1= 0

LINE 2: Servo2= 0

LINE 3: Read_Controller

LINE 4: If C_Din1= 1

LINE 5: Dout1=on

LINE 6: Servo1= 180

LINE 7: Timer=1sec

LINE 8: Servo2=180

LINE 9: Timer=1 sec

LINE 10: Servo2= 0

LINE 11: Timer=1 sec

LINE 12: Servo1=0

LINE 13: Dout1= Off

LINE 14: End If

LINE 15: Goto= 3

Page 25 of 41
2- AXIS ROBOT ARM

The diagram below shows the flow of the program when red button is pressed.

LINE 1: Servo1= 0

LINE 2: Servo2= 0

LINE 3: Read_Controller

LINE 4: If C_Din1= 1

LINE 5: Dout1=on

LINE 6: Servo1= 180

LINE 7: Timer=1sec

LINE 8: Servo2=180

LINE 9: Timer=1 sec

LINE 10: Servo2= 0

LINE 11: Timer=1 sec

LINE 12: Servo1=0

LINE 13: Dout1= Off

LINE 14: End If

LINE 15: Goto= 3

Page 26 of 41
2- AXIS ROBOT ARM

Exercise
Upgrade the program when press red button, delivery machine will pow candy at right hand side.
When press green button delivery machine will pow at middle side.

Youtube Video Link- https://youtu.be/eixmjObBupw

Answer
Servo1= 0
Servo2= 0
Read_Controller
If C_Din1= 1
Dout1=on
Servo1= 180
Timer=1sec
Servo2=180
Timer=1 sec
Servo2= 0
Timer=1 sec
Servo1=0
Dout1= Off
End If
If C_Din2= 1
Dout2=on
Servo1= 90
Timer=1sec
Servo2=180
Timer=1 sec
Servo2= 0
Timer=1 sec
Servo1=0
Dout2= Off
End If
Goto= 3

Page 27 of 41
2- AXIS ROBOT ARM

9.0 Arm Robot Project 2– Swinging Container Game

For project 2, Swing robot arm accordingly to sequence 0 degree -> 90 degree ->
180 degree -> 90 degree repeatedly for 5 times. Player can throw candy in the
swinging container. Player with higher score will be winner of the game.

Youtube Video Link- https://youtu.be/SGYBsi9lz6E

Start

Initial value 0

Add current value by 1 Display value on LCD

Pause for 1 second

Yes
Value1< is less No
The robot arm will swing
than 5?

Page 28 of 41
2- AXIS ROBOT ARM

Command Related

Command Command Function


Group
Value1= 0 Variable Set variable value with an integer.

LCD_Show= On Graphic Design Show the LCD on the user interface.

LCD_Align= Middle Graphic Design Set the alignment of the LCD content.

LCD_Text_Size= 30 Graphic Design Set text size on the LCD.

Servo1= 0 Controller I/O Control servo motor angle on the project board.

If Value1=1 Decision If the variable matches with a specific integer


condition.
End If Decision Terminate any ‘if’ command.

Value1= Value2+1 Variable Set the first variable value with calculation
result of the second variable value and an
integer.
LCD_Show_Var= Time Graphic Design Clear and save new variable in the memory of
LCD.
LCD_Update Graphic Design Display the memory content of the LCD.

Timer= 1sec Other Pause the program for a specific duration of


time.
Goto= 1 Other Jump to a specific line.

Page 29 of 41
2- AXIS ROBOT ARM

Program Description

Set integer 0 to Value1.


LINE 1: Value1= 0

LINE 2: LCD_Show= On
To display LCD on user interface. Also to
LINE 3: LCD_Align= Middle align the text to the middle of the LCD
with text size 80. The container will face
LINE 4: LCD_Text_Size= 80
up.
LINE 5: Servo2= 0

LINE 6: If Value1<5 If value inside Value1 is less than 5, the


LINE 7: Servo1= 0 arm will swing to 0 degree first for 1
second.
LINE 8: Timer=1 sec

LINE 9: Servo1= 90 Then the arm will swing to 90 degree for


1 second.
LINE 10: Timer=1 sec

LINE 11: Servo1= 180 Then the arm will swing to 180 degree
for 1 second.
LINE 12: Timer=1 sec

LINE 13: Servo1= 90 Then the arm will swing to 90 degree for
1 second.
LINE 14: Timer= 1 sec

LINE 15: Value1= Value1+1

LINE 16: LCD_Show_Var= Value1 Add the current value by 1 and display
on LCD.
LINE 17: LCD_Update

LINE 18: End If

Jump to LINE 2 and execute program


LINE 19: Goto=2 again.

Page 30 of 41
2- AXIS ROBOT ARM

Program Operation

The diagram below shows the flow of the program when the condition is false.

LINE 1: Value1= 0

LINE 2: LCD_Show= On

LINE 3: LCD_Align= Middle

LINE 4: LCD_Text_Size= 80

LINE 5: Servo2= 0

LINE 6: If Value1<5

LINE 7: Servo1= 0

LINE 8: Timer=1 sec

LINE 9: Servo1= 90

LINE 10: Timer=1 sec

LINE 11: Servo1= 180

LINE 12: Timer=1 sec

LINE 13: Servo1= 90

LINE 14: Timer= 1 sec

LINE 15: Value1= Value1+1

LINE 16: LCD_Show_Var= Value1

LINE 17: LCD_Update

LINE 18: End If

LINE 19: Goto=2

Page 31 of 41
2- AXIS ROBOT ARM

The diagram below shows the flow of the program when the condition is true.

LINE 1: Value1= 0

LINE 2: LCD_Show= On

LINE 3: LCD_Align= Middle

LINE 4: LCD_Text_Size= 80

LINE 5: Servo2= 0

LINE 6: If Value1<5

LINE 7: Servo1= 0

LINE 8: Timer=1 sec

LINE 9: Servo1= 90

LINE 10: Timer=1 sec

LINE 11: Servo1= 180

LINE 12: Timer=1 sec

LINE 13: Servo1= 90

LINE 14: Timer= 1 sec

LINE 15: Value1= Value1+1

LINE 16: LCD_Show_Var= Value1

LINE 17: LCD_Update

LINE 18: End If

LINE 19: Goto=2

Page 32 of 41
2- AXIS ROBOT ARM

Exercise
Change the counter to down counter.

Youtube Video Link- https://youtu.be/zkB3EZRS4JQ

Answer
LINE 1: Value1= 5

LINE 2: LCD_Show= On

LINE 3: LCD_Align= Middle

LINE 4: LCD_Text_Size= 80

LINE 5: Servo2= 0

LINE 6: If Value1<0

LINE 7: Servo1= 0

LINE 8: Timer=1 sec

LINE 9: Servo1= 90

LINE 10: Timer=1 sec

LINE 11: Servo1= 180

LINE 12: Timer=1 sec

LINE 13: Servo1= 90

LINE 14: Timer= 1 sec

LINE 15: Value1= Value1-1

LINE 16: LCD_Show_Var= Value1

LINE 17: LCD_Update

LINE 18: End If

LINE 19: Goto=2

Page 33 of 41
2- AXIS ROBOT ARM

10.0 Arm Robot Project 3– Remote Control Robotic Arm

For project 3, we will program to move robot arm left right using smartphone.

Youtube Video Link- https://youtu.be/mLWvvU7Rd78

Start

LCD display “Left” and Yes


“Left” button is
arm will turn left pressed?

No

LCD display “Right” and Yes “Right” button is


arm will turn right pressed?

No

Page 34 of 41
2- AXIS ROBOT ARM

Command Related

Command Command Function


Group
LCD_Show= On Graphic Design Show the LCD on the user interface.

LCD_Align= Middle Graphic Design Set the alignment of the LCD content.

LCD_Text_Size = 30 Graphic Design Set text size on the LCD.

ButtonA1_Show = On Graphic Design Show a specific button on the user interface.

ButtonA1_Show_Text = Text Graphic Design Clear and save new text in the memory

ButtonA1_Update Graphic Design Display the memory content of a specific


button.
If ButtonA1 = Pressed Decision If a specific button is pressed.

LCD_Show_Text= Text Graphic Design Clear and save new text in the memory of LCD.
Use ‘#’ symbol to skip a line.
LCD_Update Graphic Design Display the memory content of the LCD.

End If Decision Terminate any ‘if’ command.

Goto= 1 Other Jump to a specific line.

Servo1= 0 Controller I/O Control servo motor angle on the project board.

Page 35 of 41
2- AXIS ROBOT ARM

Program Description

LINE 1: LCD_Show= On These commands are to display LCD. It


LINE 2: LCD_Align= Middle also to align the text to the middle of the
LCD with text size of 80.
LINE 3: LCD_Text_Size= 80

LINE 4: ButtonA2_Show= On

LINE 5: ButtonA2_Show_Text= Left To display “Left” button for user to press.

LINE 6: ButtonA2_Update

LINE 7: ButtonC2_Show= On

LINE 8: ButtonC2_Show_Text= Right To display “Right” button for user to


press.
LINE 9: ButtonC2_Update

LINE 10: If ButtonA2= Pressed

LINE 11: LCD_Show_Text=Left If “Left” button is pressed, it will move the


arm to left side. Then the LCD will display
LINE 12: LCD_Update
“Left”.
LINE 13: Servo1= 0

LINE 14: End If

LINE 15: If ButtonC2= Pressed

LINE 16: LCD_Show_Text=Right If “Right” button is pressed, it will move


the arm to right side. Then the LCD will
LINE 17: LCD_Update
display “Right”.
LINE 18: Servo1= 180

LINE 19: End If

Jump to LINE 1 and execute the command


LINE 20: Goto= 1 again.

Page 36 of 41
2- AXIS ROBOT ARM

Program Operation

The diagram below shows the flow of the program when no button is pressed.

LINE 1: LCD_Show= On

LINE 2: LCD_Align= Middle

LINE 3: LCD_Text_Size= 80

LINE 4: ButtonA2_Show= On

LINE 5: ButtonA2_Show_Text= Left

LINE 6: ButtonA2_Update

LINE 7: ButtonC2_Show= On

LINE 8: ButtonC2_Show_Text= Right

LINE 9: ButtonC2_Update

LINE 10: If ButtonA2= Pressed

LINE 11: LCD_Show_Text=Left

LINE 12: LCD_Update

LINE 13: Servo1= 0

LINE 14: End If

LINE 15: If ButtonC2= Pressed

LINE 16: LCD_Show_Text=Right

LINE 17: LCD_Update

LINE 18: Servo1= 180

LINE 19: End If

LINE 20: Goto= 1

Page 37 of 41
2- AXIS ROBOT ARM

The diagram below shows the flow of the program when “Left” button is pressed.

LINE 1: LCD_Show= On

LINE 2: LCD_Align= Middle

LINE 3: LCD_Text_Size= 80

LINE 4: ButtonA2_Show= On

LINE 5: ButtonA2_Show_Text= Left

LINE 6: ButtonA2_Update

LINE 7: ButtonC2_Show= On

LINE 8: ButtonC2_Show_Text= Right

LINE 9: ButtonC2_Update

LINE 10: If ButtonA2= Pressed

LINE 11: LCD_Show_Text=Left

LINE 12: LCD_Update

LINE 13: Servo1= 0

LINE 14: End If

LINE 15: If ButtonC2= Pressed

LINE 16: LCD_Show_Text=Right

LINE 17: LCD_Update

LINE 18: Servo1= 180

LINE 19: End If

LINE 20: Goto= 1

Page 38 of 41
2- AXIS ROBOT ARM

The diagram below shows the flow of the program when “Right” button is pressed.

LINE 1: LCD_Show= On

LINE 2: LCD_Align= Middle

LINE 3: LCD_Text_Size= 80

LINE 4: ButtonA2_Show= On

LINE 5: ButtonA2_Show_Text= Left

LINE 6: ButtonA2_Update

LINE 7: ButtonC2_Show= On

LINE 8: ButtonC2_Show_Text= Right

LINE 9: ButtonC2_Update

LINE 10: If ButtonA2= Pressed

LINE 11: LCD_Show_Text=Left

LINE 12: LCD_Update

LINE 13: Servo1= 0

LINE 14: End If

LINE 15: If ButtonC2= Pressed

LINE 16: LCD_Show_Text=Right

LINE 17: LCD_Update

LINE 18: Servo1= 180

LINE 19: End If

LINE 20: Goto= 1

Page 39 of 41
2- AXIS ROBOT ARM

Exercise
Upgrade to program to move left and right and up and down using smartphone.

Youtube Video Link- https://youtu.be/1BYZxDLF-c8

Answer
LINE 1: LCD_Show= On

LINE 2: LCD_Align= Middle

LINE 3: LCD_Text_Size= 80

LINE 4: ButtonA2_Show= On

LINE 5: ButtonA2_Show_Text= Left

LINE 6: ButtonA2_Update

LINE 7: ButtonC2_Show= On

LINE 8: ButtonC2_Show_Text= Right

LINE 9: ButtonC2_Update

LINE 10: ButtonB1_Show= On

LINE 11: ButtonB1_Show_Text= Up

LINE 12: ButtonB1_Update

LINE 13: ButtonB3_Show= On

LINE 14: ButtonB3_Show_Text= Down

LINE 15: ButtonB3_Update

LINE 10: If ButtonA2= Pressed

LINE 11: LCD_Show_Text=Left

LINE 12: LCD_Update

LINE 13: Servo1= 0

LINE 14: End If

LINE 15: If ButtonC2= Pressed

LINE 16: LCD_Show_Text=Right

LINE 17: LCD_Update

LINE 18: Servo1= 180

Page 40 of 41
2- AXIS ROBOT ARM

LINE 19: End If

LINE 20: If ButtonB1= Pressed

LINE 21: LCD_Show_Text=Up

LINE 22: LCD_Update

LINE 23: Servo2= 180

LINE 24: End If

LINE 25: If ButtonB3= Pressed

LINE 26: LCD_Show_Text=Down

LINE 27: LCD_Update

LINE 28: Servo2= 0

LINE 29: End If

LINE 30: Goto= 1

Page 41 of 41

Vous aimerez peut-être aussi