DSpace badge board build Instructions

Index

Introduction

Welcome to the DSpace Badge build docs.

This project is intended to support a simple course in which a student builds a simple AVR/Arduino based badge - a beginner's soldering project producing a simple object with blinky lights that can be hung around the neck from a lanyard or pinned to a jacket

A slighty more advanced student might download the Arduino development system and start to program the underlying platform.

An even more advanced student will plug the badge into a proto board or attach wires directly to build something larger such as a robot or sensor project.

Parts List


You should have been handed a baggy full of parts - check the contents, inside you should find: Not included - a CR2032 coin cell battery (shipping lithium cells is problematical) - they're available at most supermarkets for around $3

Assembly

I usually start with the parts that stick the least above the board then work outwards - this way when you place the board upside down to solder parts they stay in place more easily.

The board hangs diagonally - however CAD systems don't like that, so by convention the 'top' of the board has the switches (see the picture below with the board oriented top up), the battery (the round circle) is on the 'right' the 'reset' switch on the 'left' and the LEDs at the bottom right.

This board has been fabbed with lead free solder - of course if you use leaded solder it will be unsafe for small children to suck on etc

The schematic for what we're building is also available. And if you have a copy of the Eagle CAD program you can look at the layout as well (look in the downloads section)

Resistors


Solder in the resistors - R1 the 10K resistor at the top is the reset pullup resistor, R2-6 are all 1k and are the LED current limiting resistors - it looks prettier if they are all lined up the same way.

Push the resistors all the way in flat against the board, flip the board over and place it flat on the bench:


Solder the leads carefully and clip them as close as you can get to the board without damaging the trace or the solder joint

CPU and switches

Next install the CPU and switches - both of these have to be put in the correct way around.

First the CPU - look at the chip, on the top one corner has a dot next to it - this is pin 1 - there is a matching dot on the board - the pin 1 end of the chip should be at the 'top' side of the board. There is also a notch in this end of the chip, the notch should face up and be located right next to resistor R1.

Gently insert the pins into the holes on the board, don't force them - chances are they are splayed slightly too far apart - place one side of the chip against your work bench and very gently bend all the pins on that side to the correct angle, then do the other side.


Once the pins are in place check again that pin 1 is in the right place, turn the board over and gently solder the CPU in place. This chip can be damaged by heat so use quick soldering motions.

Now do the same with the switches - note that the word 'on' is printed on the switch and should be on the same side (the 'bottom') as the 'on' printed on the board. Do not copy the image above, I got it wrong.

The resonator, decoupling cap and LEDs

Install the resonator (blue thing with 3 in-line legs) in SV7, this is the oscillator that creates the 10MHz system clock - it doesn't matter which way around it goes, install C2, the 100nF disc ceramic decoupling capacitor next to it, it too can go in either way around. (your kit may contain two 100nF caps - if they are different sizes choose the one that fits the holes.)


At the bottom right of the board go the 5 LEDs - it DOES matter which way around they go. There are two standard ways to figure out which pin is which on an LED - either a flat side on the LED next to one of the leads or one lead is longer than the other (or both) - the shorter lead and the lead on the flat side are the same - in this case the picture above the holes for the LEDs show a flat side and one of the leads on your LED is shorter - push this lead into the hole on the flat side of each LED.

Second decoupling cap and battery holder

C1 is the second decoupling capacitor, it's an electrolytic and is polarised - by convention the -ve side is usually marked with a line of '-' signs, also in a strangely bizarre convention we often mark the +ve side on a board with a '+' - go figure. Look at the mark on the cap and on the board - slide it in - the -ve side should be facing the CPU chip ('left' of the board).


Finally solder the battery holder to the top of the board - it does matter which way around you put it in as if you get it wrong you wont be able to slide the battery in. Have a look at the picture above, the scalloped side should face the 'right' edge of the board, the flat side the centre of the board. Look carefully underneath while you do this make sure that the holder is exactly centered and neither side is touching the exposed round area on the circuit board (the -ve terminal).

Programmer's reset cap

This component is optional, it's not required, but if you want to program the board makes programming much easier - it allows the DTR (or RTS) pin from the serial cable to glitch the reset pin to trigger code download

Early versions of the kit do not contain this component - C3 - version 1.0 of the board (the yellow and blue ones) do not contain a place to solder it. On Version 2.0 and later C3 has holes next to R1 and the serial connector at the top left. On rev 1.0 boards turn the board over and orient the large hole at the other end from the LEDs to the top - solder C3 on the back of the board between the two pins on either side of this hole - one pin is the 'grn' pin of the serial connector, the other is the closest pin of R1 (also connected to pin 1 of the IC).

Optional Board elements

The board has a number of spots for adding additional functionality, you can wire things directly to the pads or add extra components - apart from the 6 pin header for a serial connector these are not included in the standard kit


Optional Board elements

Turning it on

After you've finished building your board go back over it, look for shorts, and missed or cold joints. Go back over the instructions and make sure everything is in the right way around, especially the CPU. Switch the 3 switches to 'off' at the top of the board - the switch closest to the batter holder is the 'on/off' switch, the other two are general digital inputs.

Buy a 2032 (3v lithium) battery and install it in the battery holder - the clearly marked '+' side goes up.

Turn it on with the switch closest to the battery holder. The LEDs should start cycling. If they don't turn on turn it off immediately and look at the troubleshooting section below.

The default Arduino scheme that is programmed into the CPU supports four different LED cycles chosen with the other 2 switches - they are really lame, you should write something that is far better and share it with everyone!

Troubleshooting

It didn't work? turn it off immediately and look at the board - is the CPU in the right way around? the battery the right way up? the LEDs the right way around? Are all the components there? does anything feel suspiciously warm?

If it seems OK turn it back on, check the voltages - with the black lead on a multimeter set to a voltage range grab the center pin ('-') of the 'POWER' pads, measure one of the other pads with red - it should have 3v. (keep the black lead there) Test pins 1, 7 and 20 on the CPU, they also should read 3v (if pin 1 is somewhere else check R1). Try putting the red problem on the left ends of the other resistors - the meter should swing between 3v and close to 0 - if it does this but the LEDs don't light the LEDs may be in the wrong way around.

If you have a 'scope check pin 9 on the CPU - you should see a nice 10MHz sine wave and a lesser one on pin 10. You should see square waves in the second to 1/4 second range on some of the resistors R2-6.

Programming

Download the Arduino dev system from http://www.arduino.cc/ - click 'Download' and choose the appropriate download for your platform. Follow the instructions and unpack and install it.

Before you start using it find the file ..../hardware/arduino/boards.txt in the installed software and edit it add the following to the end of the file:

##############################################################

badge.name=DSpace Badge

badge.upload.protocol=stk500
badge.upload.maximum_size=14336
badge.upload.speed=19200

badge.bootloader.low_fuses=0xc6
badge.bootloader.high_fuses=0xdd
badge.bootloader.extended_fuses=0x00
badge.bootloader.path=atmega
badge.bootloader.file=ATmegaBOOT_168_badge.hex
badge.bootloader.unlock_bits=0x3F
badge.bootloader.lock_bits=0x0F

badge.build.mcu=atmega168
badge.build.f_cpu=10000000L
badge.build.core=arduino
badge.build.variant=standard

##############################################################
That last line "badge.build.variant=standard" is required by the latest Ardiono software - remove it if you are using an earlier version and it gives you trouble.

Save the file and close it

If you have an AVR programmer you might also like to download the .hex bootstrap file, install it as ..../hardware/arduino/bootloaders/atmega/ATmegaBOOT_168_badge.hex

Before you start the Arduino program plug in your USB serial adaptor and plug the other end into the badge make sure the end of the connector with the green wire is attached to the end of the pin header marked 'green' and the other end is black to 'black'.

Start the arduino software, in the Tools-<Boards directory choose "DSpace Badge". In Tools-<Serial Port menu choose the serial USB cable you just plugged in

You're all set to now try and program the board - for something simple go into File-<Examples-<Basics-<Blink. Change the references to pin 13 to pin 7 - you should end up with something like:

	void setup() {                
	  pinMode(7, OUTPUT);     
	}

	void loop() {
	  digitalWrite(7, HIGH);   
	  delay(1000);            
	  digitalWrite(7, LOW);  
	  delay(1000);          
	}

Press the 'Upload' button or choose File-<Upload to I/O Board

If your board has 'reset capacitor' then the board should reset and load the code (note this may not work on some Macs) - so here's the hard part, this is a simple board, you may have to manually reset the board to turn it on at just the right time, in particular you need to do this as soon as you see the compile complete - it displays "Binary sketch size: ....." - if it works you'll see "Done uploading", if it doesn't you'll see a nasty red error message - if it fails no problem just try again until it works (having a real reset switch helps here - it can take a lot of trying to get it to 'catch')

You can put back the old blinky light sketch by downloading the 'badge' sketch from the Downloads section below and loading that back into the badge

Advanced Programming

Arduino refers to digital and analog bins by 'number' these are NOT actual pin numbers - here's a document that describes which pins on an atmel mega168 match the pins on our badge. The LEDs are connected:

The two switches can be read by enabling the pullups on them (mark them for input and write a 1 into the output register) - they're dual use digital/analog pins, their digital numbers are not documented on the above diagram) - have a look at the sample badge.pde sketch for an example - these pins are connected:

The CPU chip used on the badge is an ATMEGA168V-10PU - Atmel's docs for it can be found here it has 16kb of flash, 1k of sram, 512 bytes of eeprom and a 10-bit A/D converter - the version we have is clocked at it's maximum speed (10MHz) and can be run between 1.8V and 5v (though to run it below 2.7V you need to drop the clock speed) - it can run at very low power levels (0.5mW) and powered down to use even less (0.2uW).

Prototyping

If you install the 3 sets of 8-pin headers underneath the board to use for prototyping you'll need to know which pins come out where. Below is a diagram representing the pins (top is 'top') as seen from the prototype pins.


There is one issue with the board and prototyping - it's wide enough that it hides most of a proto board - there are a couple of solutions:

Dropping prototype pinouts under the board is similar to Ladyada's Boarduino the goal here wasn't to clone those boards, though we did borrow the idea - and the pinouts are NOT the same. Adafruit are good people and deserve your business.

Downloads

Everything here written or designed by Paul Campbell (the design, the layout, the initial sketch and this document) is copyright Paul Campbell and is licensed GPL. Enjoy!

The Arduino bootstrap is copyright Jason P. Kyle and is licensed GPL (view the source for full license).

Cable Suppliers

The cable we use to program the kit is a special USB-serial<->3.3v TTL cable - don't be tempted, there's no safe way to hook up a generic USB serial cable to a kit (without an RS232 level shifter) - using a 5v TTL cable can also potentially damage your kit.

Windows users seem to need to download special drivers - therse can be obtained directly from FTDI - choose the 'VCP' driver.