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

with iBlockly



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

Chapter 1

iBlockly introduction and
installation

1.1 Say Hi - iBlockly

iBlockly is a microcontroller development tool with graphical language that
developed by Innovative Experiment (INEX - www.inex.co.th). We have been developed
to help young people or beginners to make the embedded system projects easier.

iBlockly was developed from the open source software called Blockly by
Google. It was originally developed in mid-2011 and was first released at Maker Faire in
the United States. In May 2012, the Google team pushed Blockly to the OpenBlocks
used in App Inventor. The developer Blockly started with Neil Fraser and Quynh Neutron,
Ellen Spertus, Mark Friedman and his team. Blockly people have developed a lot of
versions and compatible with many programming languages such as JavaScript, Python,
Dart, PHP, Lua, but not C / C ++ .

Blockly has been very popular with kids in America since Grade 1 to Grade 9+,
and was created as a learning game. There is a US government organization that
promotes code.org as a mainstay, and Disney has created a Disney-related game for
kids to learn; HOUR OF CODE. They make a showcase of the best athletes and singers to
teach children to write programs.

Later in the 2015, a group of developers who interested in Arduino hardware
from http://ardublockly.embeddedlog.com have brought Blockly to integrate with
C / C ++ compilers and library files. Arduino comes with a built in command-line script
that compiles and uploads to Arduino hardware. It can work offline. Do not connect to
Blockly’s servers at all times. It makes programming or coding easy in any location. The
software is called Ardublockly. There is a website that contains detailed information
and source code : https://github.com/carlosperate/ardublock. The copyright of the
software is A group called carlosperate (https://github.com/carlosperate)

Until the end of 2016, INEX’s engineers led Ardublockly to develop a large number
of command blocks for use with INEX’s microcontroller boards. Originally coding was
done with C / C + through the Arduino IDE, until the beta test in January 2017, it was
released to the public at the National Science and Technology Fair in Tagaytay,
Philippines. And it started to take seriously in the Philippines.

iBlockly is alternative to programming to control INEX microcontroller boards such
as POP-X2, ATX2, and i-Duino R3B. It also supports the standard Arduino hardware.

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

1.2 iBlockly installation

Start with download this software from http://inex.co.th/store/software/
iBlockly_170330.exe

1.2.1 System requirement

iBlockly runs with Windows XP or higher. The computer must has at least 1GB
haddisk space and free a USB port for interfacing and upload the code into Arduino
hardware.

1.2.2 installation step

(1) Double click at iBlockly_Setup.exe. The setup wizard window is appeared.
Click on the Next button.

(2) Choose the path or folder installation. For examplie is C:\iBlockly

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

(4) Select the software to install. Both Arduino IDE 1.7.11 and Python 2.7 by clicking
on the box. Then click on the Next button.

(5) Create the short cut iBlockly at Start Menu. Then click on the Next button.
(6) Click on the Install button to start inbstallation. Wait until the installation is
completed

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

1.2.3 Arduino IDE 1.7.11 installation

From step (4) of the topic 2.2.2, iBlockly is installed then Arduino IDE 1.7.11 will be
start installation.

(1)The setup wizard window of Arduino IDE is appeared. Click on the Next button.

(2) Click on the Next button in every step until the installation is completed.
(3) Next, system will start the USB driver installation. There are 2 driver installations.
Then click on the Finish button after installations are completed.

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

(4) Next, the hardware default selection window will appeared. Select to POP-X2
board. Click on the OK button to finish.

1.2.4 Python 2.7.12 installation

(1) After select the Python installation, the installation wizard window is appeared.
Click to select Install for all users then click on the Next button. Next, choose the folder
for installation. Then click on the Next button.

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

(2) The customize Python window is appeared. Click on the scroll bar to choose
the Add python.exe to path > Will be install on local hard drive then click on the Next
button.

(3) The installation will start and wait until the installation is completed. Click on
the Finish button. The installation is finished. iBlockly software ready for creating the code
for INEX’s microcontroller board and standard Arduino hardware.

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

1.3 Checking the USB driver installation of POP-X2

(1) Connect the miniB-USB cable between the computer’s USB port and the
POP-X2 controller on thre POP-BOT X2. Turn on power. wait until the USB indicator blue
LED on. Now the POP-BOT X2 is connected with computer ready.

Connect to USB port

Computer or Laptop
support :
Windows XP or higher
MAC OSX

POP-BOT X2 mobile robot
(2) Click on the Start button > Control Panel.
(3) Double-click at the System.
(4) Select the Hardware tab and click on the Device Manager
(5) Check the Port listing. Note the number of COM port at the USB Serial port list.
Normally is COM3 or higher. The port number need for setting the interfacing port of
Arduino IDE later.

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

1.4 Setting the iBlockly

Before using the iBlockly, setting the default browser as Google Chrome is required.

1.4.1 Start to running the program.

Double-click on the iBlockly.exe icon for running. The software is run and display
on the Google Chrome. The main program window is appeared as picture below.

1.4.2 Set the compile path of Arduino

This is choosing the suitable Arduino compiler step for iBlockly. The Arduino 1.7.11
is recommended for now.

(1) At the main window, click on the Tool menu (the 3 strips button on the upper
right of the main window.

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

(2) The vertical menu is appeared. Select the Setting.

(3) The Setting window is appeared for setting the operation. Click at the Please
select a valid Arduino compiler directory line.

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

(4) The file browser window will be appeared. If not found, please minimize the
Chrome window. User will found the path selection window. Set to C:\Arduino17\arduino_
debug.exe. Then click on the Open button to open the file.

(5) At the Compiler Location will change to path of the selection folder. Next,
select the Arduino board as POP-X2, Select the COM Port as the USB Serial port that get
from the steps of topic 1.3. Then click on the OK button.

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

1.5 Upload code testing

1.5.1 Creat code

(1) At the main window, click on the Board/Library menu on the left. Select the
Board icon.

(2) Drag and drop to working space. Select the board listing as POP-X2

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

(3) Next, click on the Function menu. Select the Void Setup() Void Loop() block.

(4) Drag and drop the Void Setup() Void Loop() block on the working space.

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

(5) Next, click on the Sound menu. Select the Beep block.

(6) Drag and drop the Beep block into Void Loop() block and change the pin of
Beep block as 12.

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

(7) Next, click on the Time menu. Select the Wait milliseconds block.

(8) Drag and drop the Wait milliseconds block connect with Beep block within
the Void Loop() block and change the time value as 500. It means 500 milleseconds.

This code is demonstration of generating the beep sound of POP-X2 controller
boad. The beep signal frequency is 500Hz.

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

1.5.2 Upload code

(1) From step 1.5.1, Save the code by clicking on the Tools menu button. Select
the Save command.

(2) The save file window is appeared. Set the name of .xml file. This example is
BeepTest.xml. Click on the OK button to save file.

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

(3) Upload the code by clicking on the Upload button. Besure the POP-X2 board
is connected with computer and turn on power ready.

(4) iBlockly uploads the code to POP-X2 board. It runs after uploading successfully.
The POP-X2 drives a beep sound every 0.5 second.

1.5.3 Upload troubleshooting

Sometime iBlockly uploads the code failed. The error message will display in the
status window as follows :

1. Serial port unavailable : it means iBlockly did not found the correct COM port.

Solution
1.1 Check the number of USB serial port that set by USB driver in the Device
manager of Windows.
1.2 Check the other devices or software that connected with same USB serial
port. If found must disconnect or close it.

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

2. Build or Upload failed : it means iBlockly compile or upload the code
imcompleted.

Causes and Solutions :
2.1 Compiler unknown some variable in the code. Check and edit code.
2.2 Declare the variable incorrect. (The library is not completed). Check all
variable type.
2.3 Use the command block not compatible with the selected hardware. Select
the correct hardware or select the correct command block.
2.4 Choose wrong arduino hardware. Select the correct hardware

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

Figure 1-1 iBlockly components
1. Tools button for seeting the operation.
2. Code or filename bar
3. Tools bar - include Open, Save, Delete. iBlockly save the code as .xml

file.
4. C/C++ code button (for displaying C/C++ code), Complie button

and Upload button
5. Command block menu
6. Zoom button and Bin
7. Uploading status bar
8. Working space

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

Chapter 2

POP-BOT X2 example with iBlockly

Activity 1 : POP-BOT X2 basic movement

Activity 1-1 Forward and Backward movement

A1.1.1 Open the iBlockly and create the code from Listing A1-1.
A1.1.2 Upload the code to the robot.
A1.1.3 Turn-off power and Remove the download cable.
A1.1.4 Make sure the robot is on a flat surface. Turn-on the power and observe the
operation.

The POP-BOT X2 moves forward. See both LED motor indicators light in green
color. After 1 second, both indicators change color to red and the robot moves
backward.

If this is incorrect you will need to re-connect the motor cable to its opposite
port / polarity. Do this until your robot moves correctly. Once its done, Use this motor
port configuration for all your programming activities from now on. The robot will move
forward and backward continually until you turn off its power.

Listing A1-1 : pbx2_GoBack.xml ; code for simple movement control
for POP-BOT X2

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

Activity 1-2 Circle-shape movement control

With setting the different speed for each motor, it cause the robot move in circle-
shape. You can try with this procedure as follows :
A1.2.1 Create a new code from the Listing A1-2.
A1.2.2 Upload the code to the robot.
A1.2.3 Turn-off power and Remove the download cable.
A1.2.4 Make sure the robot is on a flat surface. Turn-on the power and observe the robot.

The robot moves with circle-shape continually until you press the OK button on
the POP-BOT X2 controller board to stop the robot movement.

Listing A1-2 : pbx2_CircleMove.xml; code for circle-shape movement
of the POP-BOT X2

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

Activity 1-3 Rectangular-shape movement control

A1.3.1 Create a new file following Listing A1-3.
A 1.3.2 Upload the code to the robot. Turn-off power and Remove the USB cable.
A1.3.3 Turn-on the power and observe the robot.

The robot will be activated if the OK button on the robot is being pressed. The
robot will move forward and turn right continually to make the square routing.

Listing A1-3 : pbx2_RectangleMove.xml ; code for rectangle-shape
movement of the POP-BOT X2 robot

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

Activity 1-4 Multi-direction movement

The Listing 1-4 is the code for control the robot to move on any direction. It includes
forward 0.6 second, turn left 0.4 second, backward 0.6 second, spin right 0.3 second,
backward again 0.6 second, spin left 0.3 second and back to repeat again continually.

Listing A1-4 : pbx2_MultiMove.xml ;
code for moving with multi-direction
of the POP-BOT X2

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

After upload the code, turn off power and remove the USB cable. Place the
robot on the flat floor. Turn on power. The display of the robot show title message :

Press OK
to Start
Press the OK buttton on the robot. The POP-BOT X2 begins to move. When it change
direction, the screen color will change following to report the direction changing.

Blue

ÊGÕràÇe¢eÕn Yellow

Red
Purple

White
Red

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

Activity 1-5 Improve the straight movement of POP-BOT X2
with fd2() and bk2() function

The function fd2(Left,Right) and bk2(Left,Right)are DC motor control
functions similar fd() and bk() functions. The different are fd2() and bk2() have 2
more parameters to set the speed of each mortor independent.

The inequality of the motor may result in the movement of the robot can be tilted
to one side. With separate speed setting of each motor in fd2() and bk2() functions, it
compensates the different speed of each motor. The result is robot possible to move
more straight.

Listing A1-5 is simple program that use the simple statements to control the robot
moves forward by adjusting each motor speed with fd2() and bk2() function. The
robot will move forward straight as possible.

After uplaoding, see the robot movement.

Senarion 1 : robot move slant to left

It means the left DC motor speed is slower than the rigfht DC motor. Solution is
increase the left DC motor speed by adjusting at speed1 parameter of fd2() function.

Senarion 2 : robot move slant to right

It means the right DC motor speed is slower than the left DC motor. Solution is
increase the right DC motor speed by adjusting at speed2 parameter of fd2() function.

Listing A1-5 :
pbx2_MoveAlignment.xml
; code for speed adjusting
with fd2()and bk2()
function to improve the
robot’s movement to more
straight.

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

Activity 2 : Switch sensor testing

This activity presents a simple program to test the switch sensor operation. Get
the switch status to drive a beep to the piezo speaker
(A2.1) Connect the ZX-SWITCH01 sensor to port 29/A5 and 30/A6 of the POP-BOT X2 controller
board.

(A2.2) Open iBlockly. Create the code following the Listing A2-1 and save as
pbx2_TouchTest.xml file.
(A2.3) Turn-on the robot. Connect the USB cable between the robot and the computer.
(A2.4) Compile and upload the code to POP-BOT X2 controller board
(A2.5) Run the code. At the robot’s display, it shows message :

Let’s go!
Press the OK switch on the robot to start
Try pressing the ZX-SWITCH01 sensor at port 29/A5.

The 1kHz signal is driven to piezo speaker 0.3 second and the background
screen color is change to red. If still press the switch, the signal also is driven continually

Try pressing the ZX-SWITCH01 sensor at port 30/A6.
The 2kHz signal also is driven with 0.3 second period and display color is yellow.

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

Listing A2-1: pbx2_TouchTest.xml ; code for testing the ZX-SWITCH01
sensor operation

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

Activity 3 : Wired remote control

Install 2 of ZX-SWITCH01 boards to the mobile robot for the 4 scenarios as follows :
1. No switches pressed : the robot stops. Does not move.
2. Both switches are pressed in the same time : the robot moves forward.
3. The left switch that is connected with port 29/A5 is pressed only : the robot

turns left
4. The right switch that is connected with port 30/A6 is pressed only : the robot

turns right.
From all the 4 conditions, we will write the condition for making the control program

for the POP-BOT X2 following the Listing A3-1

Listing A3-1 : pbx2_RemoteSwitch.xml; code for the wired remote
control activity of the POP-BOT X2

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

(A3.1) Remove both ZX-SWITCH01 switch sensors from the robot chasis but the cable are
still connect. The switch sensors are similar looking to that of a wired remote control for
POP-BOT X2

(A3.2) Open the iBlockly.Create the code following the Listing A3-1. Compile and upload
to the robot.
(A3.3) Run the program. Try to press both ZX-SWITCH01 sensors to control the robot
movement.

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

Activity 4 : The bumper

From Activity 3, you have learnt how to use switch sensors to control the
movement of the robot. This activity requires the switches to be installed at the front of
robot again. The codes for this activity is also changed. For normal movement, robot
moves forward continuously until any of the switches is pressed. It means a collision has
happened. The robot moves backward and changes its direction to get through
obstacles.

This activity is to program the robot to detect the collision of both switches at the
front of the POP-BOT X2 robot. After a collision is encountered on the left side, the robot
will move backward and spin right to change the direction.

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

On the other hand, if the collision is occurs at the right side. The robot moves
backwards again and spins left to change the direction.

(A4.1) Create the new code with Listing A4-1.
(A4.2) Turn-on the robot. Connect USB cable between a robot and a computer.
(A4.3) Compile and upload the code to POP-BOT X2 controller board
(A4.4) Prepare the demonstration area by placing and securing boxes or objects on the
surface.
(A4.5) Place the robot on the demonstration area.
(A4.6) Run the sketch. At the robot’s display, it shows message :

Let’s go!
(A4.7) Press the OK switch and observe the robot.

The POP-BOT X2 will read both switch status from port 29/A5 and 30/A6. If any
switch is pressed or it collides with some object, the result is logic “0”.

In a normal operation, the robot will move forward continually.
If the Left Switch module touches any object, the robot will move backward and
change its moving direction to its right to avoid the object.
If the Right Switch module touches any object, the robot will move backward
and change its moving direction to its left to avoid the object.

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

Listing A4-1: pbx2_ObjectAvoider.xml; code for object avoiding with
collision of the POP-BOT X2

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

Activity 5 : Testing black and white area

The POP-BOT X2 robot is attached with 2 of Infrared reflector modules at the
robot base. This activity will only dwell on the programming section.

Before developing the robot to track the line, developers must program the robot
to detect the difference between black and white surface.
(A5.1) Open the iBlockly and create the code from Listing A5-1.
(A5.2) Upload the sketch to the robot. Disconnect the download cable.
(A5.3) Make the black & white testing sheet similar to the illustration as shown below.
The white surface area is 30 x 30 cm. and black surface is 30 x 30cm. (recommended).

(A5.4) Check the connection of both sensors again. The left ZX-03 sensor connect with
port 25/A1 and right sensor connect with port 26/A2.
(A5.5) Place the robot on the black surface. See the detection data from the color
display.

Black surface values will range from 80 to 250.

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

Listing A5-1 : pbx2_SurfaceRead.xml ; code for reading the surface
color and shows the value on the display of the POP-BOT X2

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

(A5.6) Place the robot on the white surface. See the detection data from the color
display.

White surface values will range from 700 to1000.

The result is :
The black surface value is between 80 and 250
The white surface value is between 700 and 1000

The example reference value for detecting the line would be an average,
(100+900) /2 = 500.

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

Activity 6 : AlarmBOT

This is a sample application to make the simple alarm system. When the robot is
lifted from the floor (the power is still on), the ZX-03 sensor that is installed bottom of the
robot chasis can not detect the reflected light. The reading is very low (less than black
value).
(A6.1) Open the iBlockly and create code following the Listing A6-1.
(A6.2) Compile and upload to the POP-BOT X2. Disconnect the USB cable.
(A6.3) Place the robot on the floor. Then turn on power.

The robot will not do any work. The only indicator light is the on and the color
display screen will be black.
(A6.4) Try to lift the robot off the floor.

The POP-BOT X2 will drive a warning sound alarm and the color display of the
POP-BOT X2 is changed to red to alert you that the robot was lifted up off the floor.

Listing A6-1 : pbx2_AlarmBOT.xml ; code for AlarmBOT application
of the POP-BOT X2

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

Activity 7 : POP-BOT X2 Edge detection

This activity is extended from the Activity 6. The POP-BOT X2 can detect no light
reflected status. This activity will show about using infrared reflector sensors for surface
detection to control the robot move on the table and not fall off the edge of the table !

With a simple change of the position of the sensors and a simple program, you can
adapt the POP-BOT X2 to edge detection. Start assembling the mechanical parts place
the sensors in the right position and create the Arduino sketch for the table surface testing.
This capability can be used to detect the area with a desk top or on the board at the
floor. Then create a code to make POP-BOT X2 robot can move in the area.

(A7.1) Change the ZX-03 sensor position from bottom of the robot chasis to front by using
5-hole strip joiners, 3 x 15mm. screws and 3mm. nuts. The Edging detection robot will be
ready for programming following the picture below.

(A7.2) Use the same connection of both ZX-03 sensor same the previous activity.

(A7.3) Turn-on the robot. Connect USB cable between the robot and the computer.
(A7.4) Create the code following the Listing A7-1. Compile and upload the code to POP-
BOT X2 controller board
(A7.5) Turn off power and remove the USB cable.

(A7.6) Place the robot on the table. Turn on and press the OK switch to start.

POP-BOT X2 moves forward until the sensor is out from the table’s edge. It will
change the movement direction following these scenarios :

1. Both sensors are out from table’s edge : the robot moves backward and
spins right then moves forward again.

2 3

TB6612 TB6612
TB6612100
100
1 100

4 1005 6
100
TB6612 TB6612 100

TB6612

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

Liusting A7-1 : pbx2_EdgeDetect.xml ; code for edge detection
application of the POP-BOT X2

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

2. The left sensor is out from talbe’s edge : the robot moves backward and
spins right then moves forward again.

TB6612 100
100

100

TB6612

TB6612

3. The right sensor is out from talbe’s edge : the robot moves backward and
spins left then moves forward again.

100
100

100
TB6612
TB6612

TB6612

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

Activity 8 : POP-BOT X2 line detection

From the activity 7, we get the decision value for detection black and white
area. It is 500. Therefore, the reading sensor value which is lower 500 will be decided to
black color.

This a c tivity d e m o nstra te s a b o ut b la c k line d e te c tio n o f the PO P-BO TX2 that using
the result from the activity 6. The robot will move forward continuous until it detects the
black line. It will then stop immediately.

(A8.1) Use the robot platform from the previous activity.
(A.2) Open the iBlockly to create the code following the Lisitng A8-1.

Listing A8-1 : pbx2_BlackLineDetect.xml ;
code for the black line detection activity
of the POP-BOT X2

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

Listing A8-2 :
pbx2_BlackLineDetect02.xml ; code
for the black line detection activity of
the POP-BOT X2. This code is improved
the robot stopping after detect the line.

(A8.3) Compile and upload to the POP-BOT X2. Turn off power and remove the USB
cable.
(A8.4) Stick the black tape 30cm. length on the white floor.
(A8.5) Place the robot on the floor far from the black line about 6cm. Turn on and press
the OK switch to start.

POP-BOT X2 moves forward and stop when any ZX-03 sensor detects the black
line.
(A8.6) From testing with the code A8-1, usage of only the ao(); statement is not enough
to stop the movement immediately. We can impove this operation by moving backward
with very short time before stop. The example code is shown in Listing A8 -2
(A8.7) Upload the Listing A8-2 to POP-BOT X2 and test again. See the different operation.

POP-BOT X 2 moves and stop when detect the black line similar the previous
operation. The different is stopping better than the previous operation than Listing A8-1.

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

Activity 9 : POP-BOT X2 moves along the black
line with 2 sensors

Heart of line tracking robot is control the robot to move over the line by sensors
position bestride the line. The robot moving along the line can be in 4 different scenarios.

(1) Both sensors read values that are white : The robot will move forward. Thus,
this program is written so that the robot moves forward normally.

(2) The left sensor detects the black line : This occurs when the robot is slightly
turned to the right. Thus, the program is written for the robot to move back left to resume
its normal path.

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

(3) The right sensor detects the black line : This occurs when the robot is
slightly turned to the left. Thus, the program is written for the robot to move back to the
right to resume its normal path.

(4) Both sensor detect the black line : the program is written for the robot
to make decision to move forward, tunr left, turn right , backward or stop.

(A9.1) Change the ZX-03 sensor positon back to bottom of the robot chasis.
(A9.2) Open the iBlockly to create the code following the Lisitng A9-1.

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

(A9.3) Compile and upload to the POP-BOT X2. Turn off power and remove the USB
cable.
(A9.4) Make the simple black line field following the illustration below. The white surface
area is 90 x 60 cm. and black line width is 1 inches (2.5 cm.)

(A9.5) Place the POP-BOT X2 on the black line field. Turn on the robot. Observe the
robot movement.

POP-BOT X2 will move along the black line. It is possible that the robot moves
out of the line. You can improve the precision by editing the program with adjusting
the sensor reference value and adjust to the position of both infrared reflector sensors.

When the robot moves over the crossing line, it drives a beep sound at once.
(A13.6) Try to increase the movement speed to find the maximum speed that the robot
still move along the line completely and not move out from the line.

Troubleshooting about line traking robot

There are some suggestion about checking and find out why the robot does not
move along the line or move not complete.

1. Check the connection of ZX-03 sensors. Follow this activity, the left ZX-03 sensor
connect with port 25/A1 and right sensor is connected with port 26/A2.

2. Check the motor connection. possible to swop connection or connection is not
complete. Refer this activity, the left motor is Motor 1 and the right motor is Motor 2.

3. Installation the sensor too far from the floor or not ? The suitable distance is 5 to
10mm.

4. Test the reference value from the activity 6 still working or not ?

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

Listing A9-1 : pbx2_SimpleLineTracking.xml ; code for the Simple
line tracking activity of the POP-BOT X2 by using 2 line tracking
sensors

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

Activity 10 : Simple Maze Solving

This activity is example of the Maze Solving competition. The robot will move along
the line and turn to change its ditrection when detect the crossing line. The robotmust
move in this manner until it detects all the crossing lines of the competition

Make the field

Stick the black tape 2.5cm. width on the white surface 90 x 60cm. size. or bigger
following the illustration below.

R90() function - the important function for this activity

To solve this activity, the important factor is the precision turning 90 degrees. The
R90() function is created. It turns right 90 degrees function when detect the crossing line

For a precision turn right when detecting the crossing line, robot must move forward
for a short time and then turn right until the sensors detects the cross line. After that move
forward to along the line continuous. The figure A10-1 shows this function operation.

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

Figure A10-1 : Shows the robot operation with R90() function to
improve the movement in Maze Solving activity.

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

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

POP-BOT X2 moves along the line and turn right after detects the crossing line.
Every cross line detection, the robot drives a beep.

Listing A10-1 : pbx2_SimpleMaze.xml; code for simple maze
solving activity of the POP-BOT X2

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

Activity 11 : POP-BOT X2 with complex line tracking

The robot needs to detect multiple cross lines with with increasing complexity,
such as turn left at the first intersection, turn right at the second intersection, move
forwards at the third intersection and turn right at the forth intersection etc. Users must
create some variable to count the number of intersections that robot detected.

Procedure

(A11.1) Make the demonstration field by using the 2.5mm. width black tape. Stick the
tape on the white surface 90 x 120cm size (or bigger) following the illustration below.


Click to View FlipBook Version