The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by kru.rinyaphat, 2020-12-01 00:51:06

iBlockly_popbotX2

iBlockly_popbotX2

Easy coding the POP-BOT X2 robot with iBlockly49

(A11.2) Open the iBlockly to create the code following the Lisitng A11-1.
(A11.3) Compile and upload to the POP-BOT X2. Turn off power and remove the USB
cable.
(A11.4) Place the POP-BOT X2 over the line. Turn on power and press OK switch to start.

POP-BOT X2 moves following the line, turn left when detects the 1st, 2nd, 4th,
5th, 6th, 7th and 8th intersection and turn right at the 3rd intersection. Then, robot drive
a beep at every intersection detected.

50Easy coding the POP-BOT X2 robot with iBlockly

Listing A11-1 : MultipleCrossingTrack.xml; code for muitiple crossing
line tracking activity of the POP-BOT X2

Easy coding the POP-BOT X2 robot with iBlockly51

Activity 12 : POP-BOT X2 with GP2Y0A41

Activity 12-1 GP2Y0A41 installation

(A12.1.1) Fix the 2 x 3 holes right-angle metal shaft with GP2Y0A41 module at both installation
holes by using 3 x 10mm. screws and 3mm. nuts following the picture below.

GP2Y0A41 module 2 x 3 hole right-angle
metal shaft

3 x 10mm. screw 3mm. nut
hole of metal shaft

(A12.1.2) Attach the GP2Y0A41 in front of the robot chasis by using 3 x 10mm. screws and
3mm. nuts following the pictures below.

(A12.1.3) Connect GP2Y0A41 cable to port 24/A0 of the POP-BOT X2 controller board.

52Easy coding the POP-BOT X2 robot with iBlockly

Activity 12-2 Measure distance with GP2Y0A41

GP2Y0A41 module gives the output voltage relate the distannce. The
microcontroller use the analog reading function to get the distance raw data from
GP2Y0A41. The POP-BOT X2 also have the special library to read the value. If reading
value is high, means the object is near the GP2Y0A41. In the other hands, low value
result means that the object is far from GP1D120.
(A12.2.1) Open the iBlockly to create the code following the Lisitng A12-1.
(A12.2.2) Compile and upload to the POP-BOT X2. Turn off power and remove the USB
cable.

Listing A12-1 :
pbx2_DistanceReading.xml ; code for
GP2Y0A41 distance measurement of
the POP-BOT X2

Easy coding the POP-BOT X2 robot with iBlockly53

(A12.2.3) Place the POP-BOT X2 on the table. Put an object in front of the GP2Y0A41. Turn
on the POP-BOT X2. Try to move an object near and far from GP2Y0A41 sensor. Observe
the result at the display of the robot.

Move the object near
and far from the robot
within 4 to 30cm.
range

54Easy coding the POP-BOT X2 robot with iBlockly

Activity 13 : Touchless object avoiding robot

With the GP2Y0A41 module, it adds the distance measuring and obstacle detection
using infrared light feature to your robot. Your POP-BOT X2 can avoid obstacles without
having to make any physical contact. The detected distance of this activity is 10cm.
(A13.1) Open the iBlockly and create the code from Listing A13-1.
(A13.2) Upload the code to the robot and disconnect the USB cable.

Listing A13-1 : pbx2_TouchlessAvoider.xml; code for Touchless object
avoider activity of the POP-BOT X2

Easy coding the POP-BOT X2 robot with iBlockly55

(A13.3) Place the POP-BOT X2 on thefloor. Try to place any object at the front of the
robot and see its operation.

The robot will check the distance of the object in 10cm. range. If not any
obstacle, robot will move forward continue. If found the object, it will move backward,
spin left and move forward again.

The display of the robot will change the color background everytime an object
detecion is detected. The color changing is random from 8 colors including red, green,
blue, yellow, black, white, skyblue and magenta.

56Easy coding the POP-BOT X2 robot with iBlockly

Activity 14 : Simple servo motor control

This activity demonstrates the simple example about control the standard RC servo
motor with a KNOB button on the POP-BOT X2 controller board.
(A14.1) Open the iBlockly and create the code from Listing A14-1.
(A14.2) Upload the code to the robot. Turn off power.
(A14.3) Connect the standard RC servo motor to SERVO PORT 1 (SV1). Make sure the
connection is correct. The black wire is ground (GND), red wire is +Vm and white or yellow
wire is signal (S).

(A14.4)Turn on power, Press the OK switch to start. Adjust the KNOB button on the POP-
BOT X2 controller board. Observe the servo motor operation when adjust the KNOB.

Adjusting the KNOB causes the color display to show the KNOB value and servo
motor is driven following the KNOB adjustment.

Easy coding the POP-BOT X2 robot with iBlockly57

Listing A14-1 : pbx2_ServoKnob.xml; code
for the simple servo motor control of the
POP-BOT X2

58Easy coding the POP-BOT X2 robot with iBlockly

Activity 15 : ObjectHitter-BOT

Activity 15-1 Installation servo motor with POP-BOT X2

(A15.1.1) Attach 2 of the 2 x 3 holes bracket together by using 3 x 6mm. screws and 3mm.
nuts following the figure below.

2 x 3 holes bracket #2
3 x 6mm. screw

3mm. nut

2 x 3 holes bracket #1 hole of the metal
bracket

(A15.1.2) Unscrew the screw at servo motor shaft and remove the horn. Attach a bracket
with servo motor body by using 3 x 10mm. screws and 3mm. nuts following the figure
below.

installation hole of servo motor

3 x 10mm. servo motor
screw

3mm. nut

3 x 10mm. The 2 x 3 hole bracket
screw from step (A15.1.1)

bracket's hole

Easy coding the POP-BOT X2 robot with iBlockly59

(A15.1.3) Attach the servo motor from step (A15.1.2) at the front of the robot chasis (see
the circle) by using 2 sets of 3 x 10mm. screw and 3mm. nut

(A15.1.4) Make an arm from 10-hole strip joiner. Attach it with servo motor shaft. Tighten
with a servo motor screw that release from stpe (A15.1.2). Connect the servo motor to
SV1 output. The ObjectHitter-BOT is ready for doing the mission.

60Easy coding the POP-BOT X2 robot with iBlockly

Activity 15-2 ObjectHitter-BOT basic operation

The mission of this activity is move to find the line and hit an abject at the end of
each line.
(A15.2.1) Open the iBlockly and create the code from Listing A15-1.
(A15.2.2) Upload the code to the robot. Turn off power.
(A15.2.3) Stick the black line on the white surface. Place the robot far from the black
line 30cm.
(A15.2.4) Turn on power. Press the OK switch to start.

POP-BOT X 2 will move forward to the black line. After detect lhe blakc line,
robot will stop and drive a servo motor to move from 0 degree to 180 degrees and
back to 0 degree position again. The arm that connect with servo shaft will move from
right to left and back to left again. The arm will hit an object at the black line.

Listing A15-1 : pbx2_ServoHitting.xml;
code for controlling the servo motor to
hit an object

STOP Easy coding the POP-BOT X2 robot with iBlockly61
START
Activity 15-3 ObjectHitter-BOT mission

The mission field for this activity is shown below.

From start point, the robot must move following the line and do something when
the robot detects the intersection as follows :

1. Turn left
2. Turn right
3. Move forward
4. Hit the object and move back to the same path
Mission is move to the end of each line to hit the object. Moving path of this mission
is as follows :
1. Detect 1st intersection, robot turn left
2. Detect 2nd intersection, robot hit an object, turn back and move forward.
3. Detect 3rd intersection, robot move forward to cross the intersection.
4. Detect 4th intersection, robot hit an object, turn back and move forward.
5. Detect 5th intersection, robot turn right

62Easy coding the POP-BOT X2 robot with iBlockly

(A15.3.1) Open the iBlockly and create the code from Listing A15-2.
(A15.3.2) Upload the code to the robot. Turn off power.
(A15.3.3) Make the mission field by using the 2.5cm. width black tape and the white
board.
(A15.3.4) Place the robot on the start point
(A15.3.5) Turn on power. Press the OK switch to start.

The POP-BOT X2 moves and do mission following the illustration below :

Easy coding the POP-BOT X2 robot with iBlockly63

Listing A15-2 : pbx2_ObjectHitterBOT.xml
(continue) ; code for ObjectHitter-BOT
mission of the POP-BOT X2

64Easy coding the POP-BOT X2 robot with iBlockly

Listing A15-2 : pbx2_ObjectHitterBOT.xml (completed) ; code for
ObjectHitter-BOT mission of the POP-BOT X2

Easy coding the POP-BOT X2 robot with iBlockly65

About this mission operation is described as
follows :

Firstly, POP-BOT X2 moves along the line. After
meet the 1st intersection, it turns left and moves forward
until it meets the 2nd intersection. It drives a servo motor
to hit an object at the end of line. After that, it turns
back and moves forward to the main path.

Robot will meets the 3rd intersection at the main
path. It moves forward over this intersection and moves
to meets the 4th intersection. After that it drives a servo
motor again to hit the object at the end of line. Then it
turns back and moves forward back to the main path
again.

It meets the 5th at the main path then turns right.
The movement will loop to detect the 1st intersection.
POP-BOT X2 will move, detect the intersection and drive
the servo motor to hit object at the end of each line.

After it hits all object already, it moves to the
Stop point. The mission is completed.


Click to View FlipBook Version