Ifyou visit any electronics store these days, you’ll find more and more devices being controlled over the Internet. If you have ever wanted to experiment with controlling a robot in this way, this article is for you. Before we get into the details of over-the-web control, let’s explore the basic principles of Internet
TCP and UDP
The two primary ways to communicate over the Internet
are TCP (Transmission Control Protocol) and UDP (User
Datagram Protocol). UDP is the less complex of the two
because it’s not a connection-oriented protocol.
A UDP socket can send to any other UDP socket without
establishing a link first. There is no exclusive or maintained
connection between the two communicating machines.
TCP is a more sophisticated standard for moving data
over a network, and is a client-server protocol. A server
socket can accept connections from multiple client sockets,
but a client socket can only be connected to one server
socket at a time.
Once a client connects to a server, it becomes as if there
is a direct wire between them, and data can be exchanged
between the two sockets. This article will concentrate on
TCP communication because — in my experience — it is more
widely used by third-party devices.
IP Addresses, Ports, and Sockets
To establish a link between two computers on an LAN
Each individual number in the four fields ranges from
0 to 255. If you have several computers in your home all
connected to your LAN (with cables or wireless), then each
will have its own IP address.
Each computer can further subdivide its address by
specifying a port number, which can range from 1 to 65535.
A socket can be thought of as a program communicating
from a particular IP and port. It’s one endpoint of a
bidirectional communication over the Internet.
Hardware and Software
Many computer languages offer TCP functions to
facilitate Internet communications. If your language runs on
a complex computer (such as a Window’s PC), it will have
the capability to connect to your LAN. If one of your devices
is a microcontroller though, you may need to purchase
additional hardware to enable the LAN connection.
RobotBASIC (available free from www.RobotBASIC.org)
has functions for both TCP and UDP communication and
will be used here for the example programs. The principles
shown are universal though, so applying them to other
languages should be straightforward.
Setting Up the Server
As mentioned earlier, TCP is a client-server protocol.
Over the Internet
is much easier than you
might imagine, and once
you know how, controlling
a robot from a remote
location requires little
ef for t.
64 SERVO 09/10.2018