0% found this document useful (0 votes)
116 views

Robot vb6 PDF

Uploaded by

Margo Teno
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views

Robot vb6 PDF

Uploaded by

Margo Teno
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

International Journal of Science and Research (IJSR)

ISSN (Online): 2319-7064


Impact Factor (2012): 3.358

The Command of iRobot Create Using Visual Basic


6.0 and Visual Basic .NET
Genti PROGRI1, Perika MARANGO2
MSc. Ing Genti PROGRI

Abstract: The purpose of this paper is the provision of information on how to command the robot Roomba Model 4400. Through this
paper will be shown how to command the robot using serial port commands library built for this purpose. The purpose is to show how
the Visual Basic 6.0 and Visual Basic.NET programmers, use the command library to build specific programs that control the robot
mentioned before. This library of commands and functions is intended to make easier and more comfortable commanding the robot.

Keywords: iRobot Create, Visual Basic, .Net, Robot, hardware, connection,

1. Introduction
iRobot Create is a programmable model of the Roomba
Model 4400, used for educational and scientific purposes.
To command this robot from the PC the use of the serial port
(7 pin Mini-DIN connector) or of the 25 pin port (DB 25 pin
connector) is needed, where the Bluetooth package is
inserted (Fig 1). The built library has a large variety of
commands and functions which realize specific tasks. This
library will serve as a connecting bridge, which means it will
send the proper commands from the user to the robot. In
general the commands put the robot into motion while the
functions bring to the user specific values which are the
parameters of the robot.

2. How Hardwares Realize the Connection


between the PC and the Robot Figure 1: iRobot Create and the BAM element
Instructions and commands towards the robot will be send
through the serial cable which is connected with the COM 3. Programs which Help into the Connection of
port of the PC, while in iRobot Create it is connected with the PC and the Robot
the ‘ 7 pin Mini-DIN connector‘ serial port (Fig1). After the
physical joint is made, it is needed the proper configuration The command of the iRobot Create is realized through a
of the COM port in the PC. This can be done by the simple program which has a form where buttons with the
following steps : Control Panel / System / Hardware / possible movements of the robot are placed. After a button is
Device Manager / Ports (LPT & COM). For the clicked, commands and functions in the Visual Basic 6.0 and
configuration of the serial port firstly it should be chosen Visual Basic .NET. libraries is executed. The library for the
which of the ports is connected (COM1, COM2 ...). If a PC robot is built using ActiveComport Serial Port. To realize
is being used it is suggested that the connection is made the communication with the iRobot Create through the PC
through COM1 ; however, if a laptop is being used, which serial port, we could have used Microsoft Comm Control 6.0
means it does not have the COM port physically, the (ActiveX Control për Visual Basic 6.0) or the .NET
connection is made through a USB converter into COM. The System.IO.Ports library. In both this cases the basic structure
wireless connection with the robot can be realized through of the communications would have been almost the same,
the Bluetooth package, also known as Element Direct BAM with some small changes.
(Bluetooth Adaptor Module).
4. Programming with Active Comport Serial
Port
The problem of the communication through the serial port,
even though it is widely discussed in materials, has it’s own
specifications. Being that the realization of the
communication is complex, a lot of companies built helpful
programs which are used as connecting bridges between the
serial port and the programmers [4]. One of this programs,
also called components COM, is ActiveComport Serial Port.
Volume 3 Issue 9, September 2014
www.ijsr.net
Paper ID: SEP14621 2285
Licensed Under Creative Commons Attribution CC BY
International Journal of Science and Research (IJSR)
ISSN (Online): 2319-7064
Impact Factor (2012): 3.358
Components COM is built to help the programmers with the objComport.WriteString( "any text") ose
programming languages such as : VBScript, Visual Basic objComport.WriteByte wByte
6.0, Visual Basic .Net and Visual C ++. The usage of
ActiveComport Serial Port is really wide, as: it can The first instruction (objComport.WriteString( "any text"))
command different industrial gadgets which can connect sends one information to the string-arranged port, while the
with the PC through the serial port; it commands and second (objComport.WriteByte wByte) sends to the port 1
controls different routers in the web; it controls serial byte of information (wByte). In this case, the instruction
modems, USB, Bluetooth etc. needed to send the data to the port will be that of a “ byte-
after-byte”.
To create a COM serial object, the following lines are
necessary: To realize the process where the data sent from the device
on the other side of the cable (in this case iRobot Create)
VB6: will be taken, the follow instructions are used:
Dim objComport As ACOMPORTLib.ComPort
Set objComport = CreateObject("ActiveXperts.ComPort") VB6 and vb .NET:
‘Creates a Comport instance objComport.ComTimeout = 100 ‘The time after it has
  TimeOut
.NET:
Public objComport As ACOMPORTLib.ComPort str = objComport.ReadString ‘ Reads a text information
Try from the port
objComport = CreateObject("ActiveXperts.ComPort")
objComport.ComTimeout = 1000 wByte = objComport.ReadByte ‘ Reads a byte information
Catch from the port
MsgBox("Problem in the creation of ActiveXperts.ComPort
object", vbCritical, wByte = objComport.ReadBytes ‘ Reads a range of byte
Application.ProductName) information from the port
End Try
The closure of the communication serial port is done from:
The serial object created should be configured. In this case,
for the communication with the iRobot Create, the objComport.Close ‘Command given to close the port
configuration is as it follows:
According to what was said above, some commands and
VB6: functions will be listed, to help in the movement of the
objComport.Device = “COM1” ‘Use COM1 port with no iRobot Create.
interference from the Windows drivers
objComport.ComTimeout = 100 ‘Time out of 5. Movement Commands and State Functions
communication (timeout) of the Robot
objComport.LogFile = App.Path & "\Errors.Log" ‘Log file
where error messages are saved Some of the most used commands and functions are as
objComport.BaudRate = 57600 ‘ BoudRate ne bps (possible follows.
19200 or 57600) Opening of the serial port for the communication with the
objComport.HardwareFlowControl = 0 ‘ robot is done by the function :
objComport.SoftwareFlowControl = 0 ‘ RoombaInit “3” where “3” expresses the number of the
objComport.DataBits = objComport.asDATABITS_8 ‘ serial port where the communication will be done.
objComport.StopBits = objComport.asSTOPBITS_1 ‘
objComport.Parity = objComport.asPARITY_NONE ‘ The building of the function is as follows :
objComport.Open ‘Command for the opening of the port
Public Function RoombaInit(my_COM As String) As Boolean
.NET Dim Key As Integer
comm = "COM1" Dim s As String
objComport.Device = comm Dim comm As String
objComport.ComTimeout = 100
objComport.LogFile = ‘Output buffer must be big enough to take largest message size
System.Windows.Forms.Application.ExecutablePath & If IsNumeric(my_COM) = False Then
MsgBox "Undetermined communication port.", vbInformation,
"\Errors.Log"
App.Title
objComport.BaudRate = 57600 RoombaInit = False
objComport.HardwareFlowControl = 0 End If
objComport.SoftwareFlowControl = 0
objComport.DataBits = objComport.asDATABITS_8 ‘Determines the communication port with the Romba robot
objComport.StopBits = objComport.asSTOPBITS_1 comm = "COM" & my_COM
objComport.Parity = objComport.asPARITY_NONE objComport.Device = comm
objComport.Open()To send the data in the port, the objComport.ComTimeout = 1000
command used is as it follows : objComport.LogFile = App.Path & "\Errors.Log"

Volume 3 Issue 9, September 2014


www.ijsr.net
Paper ID: SEP14621 2286
Licensed Under Creative Commons Attribution CC BY
International Journal of Science and Research (IJSR)
ISSN (Online): 2319-7064
Impact Factor (2012): 3.358
objComport.BaudRate = 57600 When the forward movement of the robot is required, after
objComport.HardwareFlowControl = 0 the speed he will use is chosen, we need the command:
objComport.SoftwareFlowControl = 0
objComport.DataBits = objComport.asDATABITS_8
SetDriveWheelsCreate vMovement, vMovement ‘Speed of
objComport.StopBits = objComport.asSTOPBITS_1
objComport.Parity = objComport.asPARITY_NONE
vMovement =[0, 500] mm/s
objComport.Open
For the backwards movement it is needed:
confirmation = GetResult
SetDriveWheelsCreate vMovement, vMovement ‘Speed of
If objComport.IsOpened = True And objComport.LastError = 0 vMovement =[-500 , 0] mm/s
Then
Key = 128: objComport.WriteByte (Key):DoSleep 0.1 Rotation 90 degrees left and right :
Key = 132: objComport.WriteByte (Key): DoSleep 0.1

‘light LEDS
SetDriveWheelsCreate 0, vMovement ‘Speed of vMovement
Key = 139: objComport.WriteByte (Key) =[0 , 500] mm/s
Key = 25: objComport.WriteByte (Key) SetDriveWheelsCreate vMovement, 0 ‘Speed of vMovement
Key = 0:objComport.WriteByte (Key) =[0 , 500] mm/s
Key = 128:objComport.WriteByte (Key)
' set song Rotation 180 degrees left and right:
Key = 140:objComport.WriteByte (Key)
Key = 1:objComport.WriteByte (Key) SetDriveWheelsCreate - vMovement, vMovement ‘Speed of
Key = 1:objComport.WriteByte (Key)
vMovement =[0 , 500] mm/s
Key = 48:objComport.WriteByte (Key)
Key = 20:objComport.WriteByte (Key):DoSleep 0.05
SetDriveWheelsCreate vMovement, - vMovement ‘Speed of
' sing it vMovement =[0 , 500] mm/s
Key = 141:objComport.WriteByte (Key)
Key = 1:objComport.WriteByte (Key) Knowing the distance between the wheels of the robot and
RoombaInit = True the linear speeds we can obtain rotations of different
Else degrees. For this we will use some simple physic formulas.
MsgBox " Unable to open the communication port .", The problem would be : what must the linear speed of the
vbInformation, App.Title wheels be , when the rotation of the robot with angle  is
RoombaInit = False
requested.
End If
End Function
We use popular formulas which connect angular speed with
The function brings back the values True or False in case the linear speed, and linear speed with time:
connection is realized with the robot, or not. v 2v
The movements : forwards, backwards, left and right (with   (1)
r d
linear speed chosen for each wheel) are given from :

Set DriveWheels Create Speed Wheel Left, Speed Wheel  (2)
Right t
Parameters Speed Wheel Left and Speed Wheel Right chose
the speed of the left and right wheel of the robot (Fig 2). From 1 and 2 we can calculate the linear speed of the wheel
Linear speed of the robot wheels is between the values (-500 for a rotation of  degrees through time t .
– 500 mm/s) [2]. 2v t
 (3)
d
Where d is distance between the wheels of the robot Fig 3.

Figure 2: Wheels of the iRobot Create and their linear Figure 3: Rotation of iRobot Create
speeds

Volume 3 Issue 9, September 2014


www.ijsr.net
Paper ID: SEP14621 2287
Licensed Under Creative Commons Attribution CC BY
International Journal of Science and Research (IJSR)
ISSN (Online): 2319-7064
Impact Factor (2012): 3.358
The command for a composed movement in the form of an To get the above calculations in Visual Basic 6.0 and Visual
arc is: Basic .NET, functions HIBYTE (intParameter) and
LOBYTE(intParameter) must be used :
SetFwdVelRadiusRoomba vMovement, rRay
Public Function HIBYTE(ByVal Intg As Integer) As Byte
Where vMovement is the linear speed of the robot and rRay HIBYTE = (Intg And &HFF00&) / 256
is the ray of the path that the robot follows (Fig 4). End Function

Public Function LOBYTE(ByVal Intg As Integer) As Byte


LOBYTE = Intg And &HFF&
End Function

To chose the distance that the robot moves it is used the


DistanceSensorRoomba() function which turns backwards
the meters done. To put the robot into the beep state (beep
sound) it is executed the following command :
BeepRoombaVB6VBNet ().
To obtain the information of the batteries of the robot , the
folowing command is used :
BatteryChargeReaderRoombaVB6VBNet () or
BatteryVoltageRoombaVB6VBNet() which bring the
tension value of the source package.

Figure 4. Composed movement of iRobot Create 6. The Experimental Realization of the


Communication Between the PC and the
To stop the robot it is acted as it follows :
SetDriveWheelsCreate 0, 0 or SetFwdVelRadiusRoomba 0,1 iRobot Create

For both of the commands shown above, values vMovement To realize the command of the robot, the program built in
and vRay are numbers from 16 bit to 4 byte in total. In the Visual Basic 6.0 is composed from a form (window) shown
case speed will be -200 mm/s and the ray 500 mm, the in Fig 5 and from 12 modules, where each contains
information which will be sent is: commands, functions connecting with the communication of
[137] [255] [56] [1] [244] the robot and other helpful functions. The program is easy.
On the window of the communication port (Fig 5) it is
Command [137] puts the wheels of the robot under control chosen the number of the serial port. In case when the PC is
for ans arc movement. connected with the robot through a serial cable, in the
communication port is chosen either COM1 or COM2.
The range above is taken from the calculations that follow When the we have a wireless connection, in the
[7] : communication port we chose COM3 – COM8 (This choice
vMovement = -200 = hex FF38 = [hex FF] [hex 38] = [255] is obtained after the instalation of Bluetooth )
[56]
rRay = 500 = hex 01F4 = [hex 01] [hex F4] = [1] [244]

Figure 5. The program to command the robot (a)-VB6, (b)-VB .NET

Volume 3 Issue 9, September 2014


www.ijsr.net
Paper ID: SEP14621 2288
Licensed Under Creative Commons Attribution CC BY
International Journal of Science and Research (IJSR)
ISSN (Online): 2319-7064
Impact Factor (2012): 3.358
7. Conclusions

 Through this material it will be shown how can be realized


the command of the robot from a serial port using the
library built for this purpose.
 The program shows how can Active Comport Serial Port
be used in Visual Basic 6.0 and Visual Basic .NET
 Through the program built in Visual Basic 6.0 and Visual
Basic .NET it is shown how we can obtain commands to
put the robot into linear motion and rotational or in a
controlled movement.

References
[1] Connection Guide For The Irobot Create.
Http://Portal.Seas.Columbia.Edu/Matlab/
[2] Irobot Command Module Owner’s Manual. ©2007
Irobot Corporation.
[3] Pardue, J., Virtual Serial Port Cookbook.
[4] Activecomport Serial Port Toolkit Manual Pages 1999-
2005 - Activexperts Software
[5] Axelson J, Access Serial Ports With Visual Basic.NET,
Nuts & Volts, April 2008, P60.
[6] Jan Axelson’s Web Site:
Http://Www.Lvr.Com/Serport.Htm
[7] Irobot Create Open Interface (OI) Specification And
Virtual Wall. ©2006 Irobot Corporation.

Volume 3 Issue 9, September 2014


www.ijsr.net
Paper ID: SEP14621 2289
Licensed Under Creative Commons Attribution CC BY

You might also like