Friday, July 29, 2011

GPS Signal Reception

While I was working on Data Bus I ran across a few interesting behaviors in GPS signal sensitivity.

source: geocaching.com
You may recall that Data Bus V1.0 uses a Pharos iGPS-500 GPS module, based on a SiRF StarIII chipset. I got it for under $20 through a vendor on Amazon thanks to a tip from a forum on LetsMakeRobots.

First, I noticed that the closer the GPS device was to the chassis electronics, particularly the mbed microcontroller, the worse the signal reception. So I put it up on a mast about 30cm from the main electronics.

Second, I discovered that whenever I placed the GPS on a small sheet of metal, signal reception increased by 5 to 10dB for all satellites in view. I am guessing that the metal acts as some sort of ground plane enhancement to the metal underneath the ceramic antenna on the module. Feel free to offer explanations in the comments.

On Data Bus, I placed the module on a square sheet of tin about 4" square and consistently got really good reception: 7-9 satellites in the basement, for example. Of course the accuracy still suffered in adverse conditions. Such as, oh, I don't know... sitting on the starting line at the Sparkfun AVC?!

Third, I attempted to add a CMUcam V1 with an Arduino acting as a bridge between TTL serial and I2C and whenever I turned on these devices, the GPS reception tanked. Half the satellites could no longer be seen, the other half were so weak I could hardly get a 2d lock let alone 3d. The cause? I don't know. RFI/EMI? Or dirty power supply? Haven't researched that yet.

What I do know is that mounting a GPS sitting atop a 30cm mast on an 1/10th RC truck makes for some craptastic handling.

Thursday, July 28, 2011

mbed.org now supports version control

After beta testing, mbed.org has released version control. That is a huge step forward for the usefulness and usability of an already excellent, powerful, cloud-based IDE. I can't wait to give the new feature a try!

Friday, July 22, 2011

Working With an ATtiny13

I've been wanting to play with 8-pin AVRs for awhile and finally got around to it.

Here's what's involved in downloading code to an ATtiny13 (and other AVR microprocessors for that matter). In this example, the ATtiny13 resides on a solderless breadboard for prototyping.

We'll use In-System Programming (ISP), a feature on all the AVR ATtiny and ATmega MCUs (as far as I know). It's a serial protocol, but unlike RS-232, there's a clock signal along with the TX and RX signals.

Link to more detail on JTAG ICE MkII Pinout

AVR's ISP cables have 6 pins: reset, clock (SCK), data to the chip (MOSI), data from the chip (MISO), as well as Vdd and GND.  Here's the header pinout (the top view):


Here's the ATtiny13 pinout reproduced from the datasheet for educational purposes. Every AVR has MISO, MOSI, SCK and RESET pins, and obviously Vdd and GND.

You can use Pololu's inexpensive USB AVR programmer, PGM03A, as I did. It's a great programmer and I used the older version of it for a few years before upgrading. Plug the 6-pin ribbon cable into the programmer, then use jumper wires (I use these jumpers from hacktronics.com) to connect to the ATtiny on the breadboard.

Or, you can buy my ATtiny breakout with AVRISP header which makes prototyping really easy. Just insert the ATtiny on the board, plug in the AVRISP cable, add power and go!

The embedded programming version of hello world, as you probably know, is blinking an LED. We'll cast off the fluffy, protective blanket of Arduino and try this, AVR-style. It's not as easy, but it's not very hard either.

#include <avr io.h>
#include <avr interrupt.h>
#include <avr sleep.h>
#include <util delay.h> 

/** ATtiny13 hello world; blink LED on Pin 2
 *
 * Michael Shimniok - http://www.bot-thoughts.com
 */
int main(int argc, char **argv)
{
 DDRB |= _BV(3);  // PB3 (pin2) as output
 while (1) {
  PORTB |= _BV(3); // turn on LED
  _delay_ms(500);
  PORTB &= ~_BV(3); // turn off LED
  _delay_ms(500);
 }
}

I decided to try AVRstudio 4 for the first time and Pololu has a tutorial on using AVRstudio with their programmer.

Programming the chip was fast and easy once I had powered it with a 9V battery (apparently the Pololu programmer doesn't actually supply Vdd but expects the board to provide Vdd to the programmer). Within half a second I had a blinking LED.

Note that I ran into ocassional glitches programming the ATtiny with the Pololu programmer. It may be some USB gremlins I've been fighting. Don't know. Try keeping the ATtiny13 clock speed up (9.6MHz, maybe even disable CLKDIV8) or reduce the programming speed.  Since I happened to have just borrowed an AVR JTAGICE mkII, I quickly gave up on the Pololu programmer for now. The JTAGICE works almost flawlessly.

The ATtiny13 is about as constrained as you can get, with very little program memory or runtime RAM. Still, it's enough to do some simple programs and it does have a timer with PWM modes and a multi-channel ADC. You can do a lot with it. The form factor is, well, tiny, and the 8-pin AVRs are a great addition to the geek arsenal.

I plan to use the ATtiny13 for a simple project related to my newest hobby, RC planes. More on that soon.

Friday, July 1, 2011

Cheap But Excellent Batch PCB Fabrication

I was reading a recent blog post on Life of Kenneth and saw a reference to DorkbotPDX batch PCB fabrication named Laen has been coordinating for some years now. It's know nown as: 

OSHPark.com

The printed circuit boards are made in the USA, the costs are $5/sq in with no setup fee for two-layer PCB designs. Four layer boards run more but still quite affordable. You order PCBs in sets of three. And the soldermask is a nice, custom purple! ooooo....!

Image from DorkbotPDX pcb fabrication ordering site
I've been using DorkbotPDX now OSHpark for a year or so now and have done probably a dozen printed circuit board layouts. Every one has come back with excellent quality. The silk screening is very detailed, the plating is fantastic, the soldermask are always right on. That's what you get when it's made in the USA. 

My Toshiba Camera Breakout PCB

And you get fast turnaround (in the US), usually within a couple weeks. He's now doing so much volume that he's sending 2 or more boards per week to the PCB fabrication company.

Home DIY PCB Fabrication top, DorkbotPDX bottom
Laen reports a very low error rate of about 1 in 10,000. Can't say enough good things about this service and I often prefer to wait a few weeks and just have the board fabricated than etching my own single-layer PCB at home.
MiniProp: Propeller breakout. QFP 0.6mm pitch
I've now gotten heavily into SMT designs. I've done PCBs with 0.5mm pitch QFP chips, 0603's, tiny 0.032" lettering (0.4" is better), SOICs, 12mil traces, etc. All the boards come back beautifully.

ARM LPC2103 breakout PCB. QFP 0.5mm pitch
Ultra-Micro Lost Model Alarms

SMT version of AVRcam. QFP 0.6mm pitch