Friday, August 31, 2012

$10 Robot Design Challenge Update

Boring. That's what my design is probably going to be. Boring and unimaginative... but hopefully also mainstream and really useful for education in developing countries (or any country) or in those robot classes I've been wanting to put on.

I've been working on the AFRON $10 Robot Design Challenge in between a massive garage reorganization project and installing fuel injection on my vintage Jeep Grand Wagoneer.

I thought for awhile about unorthodox approaches. A bristle-bot occurred to me, and was also suggested by a pal of mine. I am evaluating using a spring mousetrap instead of a DC motor.

What about a boat of some type? Or some kind of solenoid powered scooter thingy? There's opportunity to add some physics lessons to the robot this way, sure.

On the other hand, I'm concerned about the practicality of each approach. A simple tabletop wheeled robot seems most conducive to teaching programming and basic electronics.

I found a source for really inexpensive robot parts. Yes, from China. In the unlikely event that they arrive before the deadline, they represent quite a cost savings in the design without sacrificing functionality.

See ebay seller  ce10wy  among others
This source sells, for under $3, a dual axle motor/gearbox combo. Even cheaper is an entire electric car with motor, gearbox, tires, axles, battery holder. At another retailer, I've found bulk AA batteries, which will count towards the design's total cost, for under a quarter each.

I've found hobby DC motors for well under $1 but a geartrain is hard to put together and can be costly. Using a motor to drive a large wheel directly is probably best in that case.

I spent a lot of time thinking of ways to develop actuators for steering or environment manipulation but none are cheaper than, as well as superior to, a $3 micro servo.

It seems I'm turning this into a shopping exercise more than anything else.

Tower Pro SG90 9g servo, $3
On the electronics side I'm struggling to get costs down without sacrificing too much. I really want to go with an Arduino-compatible platform for reasons I'll reveal after September 12.

An ATmega328P costs just about $3 from Digi-Key, yet an ATmega168 or ATmega8 cost more. Cheaper options exist that are less Arduino-compatible, and some that are totally incompatible.

I've spent quite a bit of time on motor control. There are a few small ICs that can drive low voltage motors from low voltage power supplies (2 x AA). A cheaper option is a MOSFET h-bridge, but finding the right MOSFETs has been a significant challenge.

As for sensors, discrete infrared LEDs and phototransistors seem cheapest. My Microrobot uses these and I recall they worked reasonably well for basic obstacle avoidance, but I've not used them for line following.

I'm pretty confident I can make a functional, decent, mainstream line follower for $20 or less. Bulk discounts will definitely help get the price pretty low.

I don't expect to win the competition at this point. I'm sure others will come up with truly brilliant, creative designs leaving me slapping my forehead in dismay.

Still, I'll consider my efforts a success if I can come up with a useful design that can be used to teach kids.

Friday, August 24, 2012

AVR Assembly Interrupt Handlers

Here's an example of assembly interrupt handler routines for AVR using WinAVR / gcc. Hopefully I can save you the couple of hours it took me to figure this out.

Using AVR Studio 4 with gcc, write your assembly code like this:

.global INT0_vect ; tells the linker this is where INT0_vect lives

INT0_vect:
 reti

The .global directive tells the linker "here's the interrupt service routine" and the appropriate jump instruction is filled into the vector table. When the interrupt fires, the program counter moves to that spot in the vector table, the jmp is issued and your ISR code is run, then returns from interrupt with the reti instruction.

You can find the correct interrupt service routine labels to use by looking inside your device-specific io file, e.g., io328p.h
/* Interrupt Vectors */
/* Interrupt Vector 0 is the reset vector. */
#define INT0_vect         _VECTOR(1)   /* External Interrupt Request 0 */
#define INT1_vect         _VECTOR(2)   /* External Interrupt Request 1 */
#define PCINT0_vect       _VECTOR(3)   /* Pin Change Interrupt Request 0 */
#define PCINT1_vect       _VECTOR(4)   /* Pin Change Interrupt Request 0 */
...
If you want to check to be sure your interrupt routines are getting populated within the interrupt vector table (starting at address 0x0000), then do:

avr-objdump -h -S -z AVRcam.elf > AVRcam.lss

...and edit the file, and look for the __vectors table, excerpt below. You can see below that I have vectors 1 and 2 defined and several undefined. These interrupts would result in jumps to __bad_interrupt, halting the MCU.

Disassembly of section .text:

00000000 <__vectors>:
       0:       0c 94 34 00     jmp     0x68    ; 0x68 <__ctors_end>
       4:       0c 94 95 01     jmp     0x32a   ; 0x32a <__vector_1>
       8:       0c 94 96 01     jmp     0x32c   ; 0x32c <__vector_2>
       c:       0c 94 51 00     jmp     0xa2    ; 0xa2 <__bad_interrupt>
      10:       0c 94 51 00     jmp     0xa2    ; 0xa2 <__bad_interrupt>
      14:       0c 94 51 00     jmp     0xa2    ; 0xa2 <__bad_interrupt>
...

So, what are these mysterious __vector_XX addresses?

You can find out by consulting your datasheet. For example, in the ATmega328P datasheet, reproduced here for educational purposes: Vector 1 is INT0, vector 2 is INT1, and so on.


Friday, August 10, 2012

$10 Robot Design Challenge. I Accept.

The African Robotics Network (AFRON) is sponsoring the $10 Robot Design Challenge wherein competitors are to design educational, programmable robots approaching $10 in cost for use by African (and other) schoolchildren.

I saw this about a month ago and have been thinking it over.

Why consider this? I want robotics to be the future and I want the doors opened for kids around the world. I've been considering doing a local robotics class for awhile. Well, it's time for me to stop thinking and do something.

So, ok. I hereby accept the challenge. A couple of years ago I wasn't sure how I could possibly build a useful, interesting $50 robot and now I'm committing to designing a $10 robot. Call my crazy.
The goal of the AFRON "10 Dollar Robot" Design Challenge is to design a new class of affordable robots for learning (especially in primary and secondary schools). Robots excite people of all ages. Their physical behavior in response to programs and/or sensors inspires student interest in computers, science, math, and engineering more broadly. However, existing platforms are often too expensive for students in many African countries and other emerging economies (this competition is open to anyone worldwide).
Note that US$ 10 is a target but we are happy to accept designs that don't reach this goal.
Deadline is Sept 12, 2012 at which point I'll post up my entry.

Some initial thoughts...

  • I plan to use a real microcontroller, probably Arduino based, and probably supported by Minibloq, but the rest of the components have to be pico-cheap and clever. 
  • I want the robot to be functional and interesting. 
  • Even one Sharp IR sensor blows the entire budget and then some. What can be done with IR LEDs? 
  • Two 280-size DC motors blow most if not all of the budget. How to move the robot inexpensively? 
  • The cheapest servos I know about still knock out at least a third of the budget, each. Can an actuator be scratch-built that works well enough and costs even less? 
  • What about power supply?

Friday, August 3, 2012

TSSOP Prototyping Boards

A few months ago I was investigating use of a nice 20MSPS analog to digital converter for a high frame rate machine vision system based on the Game Boy camera. Unfortunately the ADC, a Linear LTC1406, comes in a narrow TSSOP form factor. 

TSSOP is already hard to work with. The pin pitch is only 0.635mm. While I've successfully etched a TSSOP footprint at home, it's at the fringe of reliable home toner transfer etching.

Some sort of breakout board is a wiser idea. I had a chance to evaluate three breakout boards recently, and here are the results.

Sparkfun SSOP-28

Sparkfun Electronics sells a 28-pin SSOP to DIP breakout board.


It looks like a perfectly good board for standard SSOP footprints, but not for narrow SSOPs.

I soldered up the chip on one side and it was just barely reaching to the pads on the other side. In some spots I had to solder in single wires pulled from stranded wire to bridge the gap.

If I'd had any other breakout boards available at the time I would not have gone through such a nerve-wrecking, tedious experience.

Schmartboard

I've really enjoyed using Schmartboard's EZ technology for a variety of chips including tiny SC-70 and SOT-23 ADCs, ARM MCUs in 0.5mm pitch QFPs, Propellers in 0.8mm QFP, and more. I recommend them to folks intimidated by SMT soldering.

Neal Greenberg was kind enough to send along a board for evaluation along with some of their excellent jumper wires so I could prototype my ADC. Thanks!


As with all the above, aligning the chip into the pad grooves was a snap. The grooves keep the chip aligned. This is so much easier than a standard SMT footprint where the flight of a passing gnat could knock the thing out of alignment.

Normally one applies solder flux and then runs the iron down the groove towards the chip leg and all is well. I didn't quite get the technique right. I should've read this review for the proper approach.

I gouged the solder mask more than actually pushing the solder on some legs and ended up lifting a trace off the board (it didn't break, however). I should've used flux paste instead of a flux pen. And I should've used a hotter iron for the lead-free solder.



The good news is that it looks like it'll work just fine but it's really ugly.

I still recommend Schmartboard. My flub-up was my fault.  I was easily able to solder tiny 0.5mm pitch QFPs a few months ago.

DorkbotPDX aka Laen.org PCB

In a recent order from DorkbotPDX, a little surprise was waiting for me in the bag; a free pair of TSSOP/SOIC breakout boards where one side has a SOIC footprint and the other, an SSOP.

The footprint was just wide enough to cleanly accommodate the LTC ADC. I used my hot air rework station to remove the chip from the Sparkfun board and then soldered it onto the Laen board with my iron.


Of the three options this board worked best but requires advanced soldering techniques.

Other Options

There are other options for TSSOP / SSOP and other SMT breakout boards. One site that seems popular is http://www.proto-advantage.com but I haven't had a chance to look at their SSOP offering.