Sunday, July 12, 2015

Meet F.A.R.T.

I am proud to present the first prototype of my Fully Autonomous Roaming Tank (F.A.R.T.):

It is a "robot" tank that roams the house by itself without crashing into things (too much).
What is most special about it is that it is built from Lego parts (chassis an motors), but driven by Arduino!
All I had to do was to cut one of the Lego's wires, do some easy soldering and voila - I can drive Lego motors from Arduino!
The possibilities this opens are huge, FART is just the first example.
Both the code and the mechanics are just quick prototypes - about 2 hours to build the chassis from Lego and maybe an hour coding ... no wonder it doesn't behave too well.

Just as a reference, more than an year and a half ago, I built something similar, but made entirely of Lego (using the Lego brick as a brain, not an Arduino):

Here is the parts list:
1x Arduino Nano - $3.20 (less if you buy more at once)
2x US100 Ultrasonic Sensors - $7 (for both)
2x Transparent Breadboards - $5.24 (for both)

Did you spot the biggest problem already? :)
Lego is fucking expensive!
Since I already have it anyway, it is not that much of a problem.
But, the price (along other problems) makes it useful only for prototyping.
I can't build something and keep it like this, because the price of that thing would be insane.
So, the plan is to replace it with this $10 kit when it arrives.
Still, the option to quickly prototype something with Lego is priceless!

On the other hand, if I wanted to buy an ultrasonic sensor for the Lego, I would need to spend a fortune ($60+), instead of $3.50 from China.

Plans for future improvements are:
- Improve the code for better obstacle avoidance, stuck detection and unstuck procedure.
- Make it internet-enabled, so it can be controlled from any web browser, including from the phone.
- Add some more sensors (maybe 1-2 infrared distance sensors).
- Add some servos, so I can rotate the sensors, like in the pure Lego roamer.
- Add FPV (a camera streaming video of what the robot sees). Ideally, over the internet.
- Replace the breadboards with PCBs
- Replace the Lego with the final chassis

If all goes well (and I don't just abandon the project), at the end I will have a tank, which I can control over the internet and see what it sees. How cool would that be? Well, at least until the batteries die.  

Overall, it was fairly easy to do it, but still I stumbled into few problems:

Problem 1: Ultrasonic sensors take a while to get a distance measurement. And they also need some time between measurements (so they don't pick some echoes). Having 2 of these, I have to measure one first, wait for some time (20ms), measure the second one, wait some more. As a result, I am getting measurements every ~60ms, and the second is about 30ms later than the first. These times might sound small, but actually are big enough to cause problems.

Problem 2: Speed controlling the motors using PWM from the Arduino turned out to be problematic. At low speeds the motors don't turn at all, jut make some noise. I am not sure exactly why, but I suspect the PWM frequency is too high. I could be wrong, but at least I can test that later and if needed fix it (either by reprogramming the Arduino timers or by manually setting the signal low-high from code). For now, I just put a lower limit at the speed control, so if the logic says it wants the motor rotating at 30% speed it actually rotates at 75%. Far from ideal, but enough for the early prototype. It might also help if I use a 9V step up regulator to provide 9V to the motors (currently the batteries provide 7-8). Testing with 9V wall power supply showed it is better, but does not eliminate the problem. I will have the 9V voltage regulator in a few days.

Problem 3: I am running out of digital pins. Motors take 2 pins each. Sensors also take 2 pins each. Adding and ESP8266 for internet connectivity would eat 2 more pins. If I want to read the motor encoders (so I can detect when a motor is stuck or balance the speed of the two motors) it would take 1-2 pins per motor (the encoders output through 2 pins, but I could only use one if I only want to detect if the motor is stuck). Adding extras, like servos, more sensors, speakers, LCD display, LEDs might turn out impossible (without adding second arduino or a GPIO extender).

Problem 4: I somehow burned an Arduino. Fartie was roaming around just fine, then got stuck under a chair and out of a sudden it stopped. It surprised me, because the logic it uses never stops. Then I saw the light I have programmed to blink when the batteries get low was actually blinking. This explained the stop, except the batteries were freshly charged. I measured them just in case - they were indeed fine. But since I unplugged the batteries, the Arduino won't boot from batteries anymore. It boots from USB, but not from batteries. And when hooked up to batteries its 5V output produces something like 1.5V. So, I am guessing its internal 5V regulator is gone. Maybe, because Fartie was stuck, the motors tried to draw too much current (I measured 1.5A, even 2A stall current before). The motor driver chip does have over current protection, but still, something might have happened to the battery power supply, which went through the Vin on the Arduino and fried its voltage regulator. This is only a theory though, I don't know for sure. What is worse, I have no guarantees that it won't happen again and kill the next Arduino.

Problem 5
Cat hair! Lots of it!
There is no solution to this problem (getting rid of the cats is not an option at all).
Billy (my robotic vacuum cleaner) suffers from the same problem.

No comments:

Post a Comment