en en en pt es en en en en cv en en en en en en en en en en es en en en en en en en en ca es en es ne en en en en en en en en en en en en en en en en en en en zh nl en en en en en en en en en en en en en en it en en en en en en en pt en en en en en en en en en en en en en en en en
I’ve been meaning to try building my own small mobile robot for some time. Unfortunately, hobby robotics can get pretty expensive. A simple 4-wheeled robot platform can easily cost 60 to 80 dollars, and that only gets you something big enough to carry batteries, a microcontroller and other small devices. I had this idea that it would perhaps be cheaper to build a robot based on a remote controlled car. RC cars come in a variety of sizes, can handle rough terrain, go pretty fast, and best of all, are often fairly cheap. I was able to find exactly what I needed at the Salvation Army: a used RC truck without the remote control and battery (who needs that?) for the modest sum of $1.99.
For those who want to tinker with microcontrollers, eBay is full of bargains. There are now lots of sellers selling AVR (Atmel) microcontroller boards and Arduino-compatible modules of all kinds at very low prices. For this project, I purchased the following:
ATmega64A microcontroller board ($18 shipped)
USPasp In-System Programmer for AVR MCUs ($4)
H-bridge motor controller module ($7)
Bluetooth to RS232 TTL module ($9)
4x HC-SR04 ultrasonic rangefinders ($10)
1800mAh Lithium-ion battery and charger ($11)
40x 30cm 1p-1p dupont cables ($3)
I also used various components I had on hand, such as small prototyping boards, a 5V power regulator, capacitors, resistors, a ULN2803 transistor array, LEDs, a piezo buzzer, single and dual row pin headers, wires, shrink wrap and 2.1mm male and female power jacks: total value less than $10.
Since I use Linux as my development platform, I went with avr-gcc and avrdude to program the microcontroller. I’ve had absolutely zero issues so far. Luckily, Ubuntu has preconfigured avr-gcc, avr-libc and avrdude packages in its software repository, which made it very easy to get my setup going.
One thing I would caution newbies about is that AVR chips out of the factory (including the one on my board) run at 1 MHz using their internal oscillator by default. You need to update the MCU’s fuse values in order to change this. Before you set the fuse values, the USBasp programmer has a “slow sck” jumper that needs to be enabled. If you don’t set this jumper, it will refuse to program the microcontroller or set its fuse values. If you’ve never used AVR MCUs, I highly recommend ladyada’s tutorials.
Fortunately, my robot build went very smoothly. I found the components very easy to interface with. The H-bridge controller simply requires two PWM outputs per motor (one for each direction of rotation). The bluetooth module connects directly to the MCU’s TX and RX UART ports and creates a serial connection I can interact with using a terminal program. The ultrasonic distance sensors use a two-wire interface where an input is used to trigger an ultrasonic pulse and an output goes low once the echo is received.
I wanted to add LEDs on the roof of the truck as well as a buzzer module inside so I could present status/debug info in an intuitive way. The LEDs, with a power consumption of 8mA, could have realistically been driven directly from MCU output pins, but the buzzer couldn’t, and I wanted to allow switching other devices which consumed more power. My solution to this was to solder a simple module with an ULN2803 driver chip, resistors and some pin headers.  The pin headers allow me to use color-coded dupont cables to connect everything (power and IOs), making for easy prototyping.
To power all of this, I soldered together a power distribution module. This module hosts some filtering capacitors, a 5V power regulator and various connectors. There is a two-row pin header to distribute regulated 5V to most of the modules, as well as an unregulated 12V output for the motor driver module. I put a 2.1mm female jack in an open back compartment of the truck so that I can plug the lithium-ion battery into there, or an external power supply for testing.
All of the modules are held inside the top part (plastic housing) of the truck using velcro. Because it’s still highly inconvenient to remove the cover to program the chip, I soldered an extension for the ISP header of the microcontroller board, and glued it in an accessible location.
This robot doesn’t really have much in the way of AI thus far (it only takes commands and reports distance readings over Bluetooth), but I’ve decided to make the source code available on github. This code should be helpful in understanding how to interface with the components I’ve used. Possible improvements to be made include the ability to reprogram the MCU through bluetooth.
From → Electronics, Microcontrollers, Programming
Leave a Reply Cancel reply
Enter your comment here...
Fill in your details below or click an icon to log in:
Email (required) (Address never made public)
You are commenting using your WordPress.com account. ( Log Out /  Change )
You are commenting using your Twitter account. ( Log Out /  Change )
You are commenting using your Facebook account. ( Log Out /  Change )
Notify me of new comments via email.
Notify me of new posts via email.
« A Radical Introduction to Programming
Why Do Most New Languages Fail? »
Typed vs Untyped Virtual Machines
Minimalism in Programming Language Design
Democracy, Dictatorships and Access to Information
Code that Doesn’t Rot
The Internet Changed My Life
What’s Could You Use Tesla Bot For?
NoiseCraft: a Browser-Based Visual Programming Language for Sound & Music
Art Artificial Intelligence Artificial Life Assembly Biology Compilers Creativity D Language Electronics Future Game Development Genetic Algorithms Grad studies Graphics Higgs JavaScript Microcontrollers Microprocessors Music Programming Programming Languages Psychology Rant Robotics Tachyon Technology Uncategorized work x86 Zeta
Archives Select Month June 2022  (1) May 2022  (1) March 2022  (1) February 2022  (2) January 2022  (2) December 2021  (1) June 2021  (1) February 2021  (2) December 2020  (1) September 2020  (1) January 2020  (1) November 2019  (2) October 2019  (2) June 2019  (1) January 2019  (1) December 2018  (1) May 2018  (2) February 2018  (1) January 2018  (1) December 2017  (1) October 2017  (1) June 2017  (1) April 2017  (1) January 2017  (1) December 2016  (1) November 2016  (2) September 2016  (2) May 2016  (1) March 2016  (1) February 2016  (2) January 2016  (1) November 2015  (4) October 2015  (1) September 2015  (3) August 2015  (2) July 2015  (3) June 2015  (1) May 2015  (3) April 2015  (2) March 2015  (1) February 2015  (1) December 2014  (1) November 2014  (2) October 2014  (2) September 2014  (3) July 2014  (3) May 2014  (1) April 2014  (1) March 2014  (1) February 2014  (1) January 2014  (3) December 2013  (3) October 2013  (2) September 2013  (1) August 2013  (2) July 2013  (3) June 2013  (2) May 2013  (3) March 2013  (2) February 2013  (1) January 2013  (3) December 2012  (4) November 2012  (1) October 2012  (1) September 2012  (3) July 2012  (4) June 2012  (2) May 2012  (2) April 2012  (4) March 2012  (2) February 2012  (3) January 2012  (6) December 2011  (2) November 2011  (3) October 2011  (8) September 2011  (4) August 2011  (3)