Skip to content

RADU: From Stationary to Moving Robot

By Sebastian Günther

Posted in Robots, Radu, Arduino

The development of my robot continues steadily. In the last post, I showed an immoveable box of the robot, which means a fully sensor equipped machine with the Raspberry Pi, the Arduino Nano, LED display and IR receiver. This box is now put on wheels so that it can move around freely.

In this article I reflect the essential difficulties that I encountered during this transition.

Mounting Wheeled Chassis

Putting all the sensors on top of the moving chassis was surprisingly easy, but I was very lucky with the chassis itself: It is simply big enough to put everything on top of it! I would like to have put some components between the top and the bottom compartments, but the bigger motors did not leave enough space for this. Which brings me right to the next point.

Motor Control

To control the 4 different motors, I decided to use an L293D motor shield. This IC allows me to use only 8 wires for controlling 4 dc motors. Because of this, the RADU prototype only requires one Arduino Nano for connecting all components. This simplifies the setup to a great deal, because I do not need to setup MCU connection with UART or I2C.

However, getting the L293D to work is a different story altogether. Connecting all the required wires, and feeding an extra power supply to the L293D, and uploading the trusted Arduino lib, I could not get all 4 motors to work correctly. Most of the time, just two motors moved, and sometimes the forward and backward direction changed seemingly random.

After spending more than 6 hours, tri- and quad checking the wiring, using a multimeter, trying different libraries, a notice in one of the countless tutorials caught my intention: Use 12 V it said. Hmm.... my 9V battery not capable enough? So, I checked similar robot builds, and saw that they used the battery type 18650, which comes with impressive 3000mha and 3.7V. I ordered these batteries, connected them to the chassis, and ... it worked! Powerful, 4-wheel acceleration, forward and backward. The library, the wiring, the hardware was working flawlessly - I did just not provide enough power. A crucial learning indeed.

Library Incompatibilities

Once the car moved, I attached all sensors from the Radu Box again, uploaded the sketch, and then tried to interpret IR commands as move commands. This worked until I added the distance sensor. Suddenly, the program code for interpreting IR commands showed strange output, it could not process anymore. When I unplugged the IR module, it worked again. Researching this issue, I found out that both the IR library and the distance sensor library refer to the very same timer. A timer is an Arduino Framework abstraction for controlling the clock speed of specific hardware processes and interfacing with the GPIOs. When searching on the internet for solutions, you find various hacks about modifying the header libs of the respective libraries, and/or setting header guards to prevent that certain code is loaded. I could follow along, but at the time I encountered the problem, I had too few C experience to effectively understand and work the problem. At the end, I decided to ignore the distance sensor completely, but still added the component to the prototype because the I like the design of it.

Mobile Power Supply

In addition to powering the motors, I also need to supply the Arduino and the Raspberry Pi. A very common solution is to take a USB power bank. It has a high capacity, provides the right amount of voltage, and it has several USB outputs for connecting multiple boards. I took a quite sturdy model, with a big surface, to which I, well, duck taped the breadboard and other sensors. Not an engineering masterpiece, but it works.

Connecting the MCSUs and Remote Programs

The final part is to connect the microcontrollers amongst each other. First, I connected the Arduino with the Raspberry Pi via a USB cable. The Arduino is therefore powered by the PI, and they share an USB cable for exchanging data. By using serial-over-USB, and the command line interface I explained in an earlier article, the two devices can exchange text messages.

In addition to using the IR, I can also send move commands from to Raspberry Pi to the Arduino. Therefore, I open a minicom connection on the Raspberry, and then can enter any commands to the Arduino. And then remote control via a terminal is also achieved. I simply connect via SSH to the raspberry Pi, then open the minicom shell, and can execute any commands.

Conclusion

Moving the RADU box to a chassis gave my valuable insights. First, get the power supply to all MCUS, sensors and actuators right. By providing not enough power, you will get strange behavior in your program and can waste a lot of time chasing ghosts. Second, if you use multiple libraries, incompatibilities might occur. I have no remedy for this yet as my programming experience is limited at the time of writing, but I just advise to be aware of this problem in complex projects. Despite the problems, assembling the moving RADU was fun. Seeing the robot assembled piece by piece, then powering it up and get LEDs flashing. The first-time remote login via Wifi and issue a command. And then there was the magic moment when I put RADU on the ground, pressed the forwarded button on the IR, and it just moved.

This article finished the 2nd phase of my robot project - here is the status so far:

  • ✅ Essentials: Software & Hardware
  • ✅ Moving Robot
  • Simulation
  • Visual Sensors
  • Self-Navigation
  • Pickup & Deliver