Control robot via serial port

Robots can be controlled by a microcontroller (MCU) or a computer installed on-board – autonomous robots, or connected to a computer via communication channel – remotely operated robots. Both approaches have pros and cons:

  • Autonomous robots have everything they need on-board, they do not depend on a quality and bandwidth of communication channels. But they may have limitations on computer performance and size, its not easy to modify controlling algorithms and monitor state.
  • Remotely operated robots can be controlled by more powerful computer, monitoring is available for operator or developer, modification of a controlling program is much easy. But quality and bandwidth of communication channels are critical and limiting part of such system.

Intermediate solution is develop the controlling program on remotely operated robot and when it is completed – setup the program on on-board computer, leaving communication channel only for monitoring which is not such critical.

This article describes how remotely operate a robot where on-board MCU (represented by Arduino) takes care about hardware – controlling motor-drivers, monitoring sensors, providing communication, etc; a remotely connected computer displays monitored data and runs controlling algorithm. Program will be implemented on C++. Platform is Ubuntu.

Find device which an Arduino board is connected to computer

1. Do not connect Arduino or disconnect if connected already. Start the Terminal (hit Ctrl+Alt+T)3. Run following commands to find any serial ports connected ( where “*” means “any letters or numbers”). If results of both commands “No such file or directory” – there is no any communication devices connected.

ll /sys/class/tty/ttyACM*

UbuntuFindSerialPortsNotExist

ll /sys/class/tty/ttyUSB*

UbuntuFindSerialPortsOverUSBNotExist

2. Connect an Arduino board with USB cable to a computer and run commands again to see which device is available now

In this example the Arduino board connected to the computer via “ttyACM0”

UbuntuFindSerialPortsOverArduinoConnected

In this example a USB-to-UART adapter on a chip SILABS CP2102 connected to the computer via “ttyUSB0”

UbuntuFindSerialPortsUSB2UARTCP2102Connected

hint Why devices have different types: ttyACM0 or ttyUSB0

It depend on protocol and software or hardware implementation. This article contains some brief explanation.

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail