November 29, 2012

MSP430 LaunchPi - expansion board for the Raspberry Pi


So I got my Raspberry Pi a few days ago. (Time from order to delivery was one business day from http://lawicel-shop.se/ .) As I have been playing a bit with the MSP430 Launchpad lately, I thought it would be nice to interface MSP430 microcontrollers with the Raspi. Why not make an expansion board? Inspired by the MSP430 Launchpad, this is what I ended up with:


The expansion board, which I would like to call the MSP430 LaunchPi, is fully pin-compatible with the normal Launchpad (except for the touchbutton, wich I never used anyway). The TX/RX pins are easy to connect with the Raspi UART (GPIO pins 8 and 10) and all GPIO pins from the Raspi are accessable.

Just as on the original Launchpad, the leds and uart connections are configurable using jumpers or double female connectors.

I plan to create a hardware driver for mspdebug to be able to program the board using the GPIO pins 11 and 13 on the Raspi.


Building process

The time from idea to finished board was approximately four hours, the priority was to make something that worked. The design was done using pen and paper.
 In hindsight, it would have been easier to use wirewrap female headers (Arduino stackable) but I used normal female headers with bent legs and soldered these on the solder side of the board.
 I accidentally cut one copper strip, the one leading 3.3 V from the header. Fixed it with some wire.
 I wanted more space on the top of the board to be able to easily change the microcontrollers, so I chose to mount a 47k SMD resistor on the soldering side to pull-up the reset pin.
 After soldering headers, leds, jumpers and resistors, I connected it to the Launchpad. It worked! =)

Plugged in the Raspi. The Test and Reset pins of the MSP430 does not like the default state of the Raspi GPIO pins 11 and 13, so these are disconnected for now.

I had problems connecting to the serial port at first, this was because a getty was connected to the serial port. I disabled this in the file /etc/inittab and rebooted the Raspi.

pi@raspberrypi ~ $ tail -3 /etc/inittab
#Spawn a getty on Raspberry Pi serial line
#Commented out for use with the MSP430 LaunchPi
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
pi@raspberrypi ~ $


I had previously loaded the MSP430 with a UART test program (source code available at https://github.com/LarsH/msp430-uart).

pi@raspberrypi ~ $ screen /dev/ttyAMA0 9600

...

Unknown command.
>>>?
Uart test program
Commands:
r: blink red led
g: blink green led
t: read temperature sensor
?: print this help
>>>r
Blinking red led...
>>>g
Blinking green led...
>>>t
Temperature: d6b4
>>>


Success!

Finally I noticed that I forgot to make the green led optional, I resoldered the board a bit to make it possible to disconnect. I also moved the resistor so that I can use the led with another pin and a double female connector. Here are pictures of the final board. Wire colors are red/black for 3V/Gnd, green/yellow for UART Rx/Tx and blue/white for reset pull-up/green led.



July 23, 2012

The inner workings of a keycard terminal

I recently got my hands on an old key-card terminal. I decided to take it apart and figure out how it worked.

It is quite heavy for its size, the case is made out of 2mm thick stainless steel. It weighs about 0.7 kg.

The front is attached to the main pcb with 7-wire connector. It turned out to be an ordinary 4*3 button array. The connected wires were:
Rows, top-down: brown, blue, green, white
Columns, left-right: black, red, purple
The pcb is all through-hole technology. There is no microcontroller, no epoxy blobs and all the IC's are from the 74HC and 4000 series, so the circuit should be fairly easy to reverse engineer.

The card reader was easily removed.

Swedish quality.

I guess this board was manufactured in march 1999. I could not find any information on ASI konsult, but Teletron was a Swedish security systems company that merged with ISEC in 2002 and was declared bankrupt in 2003.

I thought the card reader could be a good part to start analyse. The first hit on google revealed the datasheet! =) It is a single track reader for track 2 of a magnetic card. I hooked it up to my BusPirate:

I used the raw-bitbang-mode of the BusPirate to read out data from the data and clock lines. With a few lines of python code I ended up with this plot after swiping an old discount card:

The blue line is the clock and the red is the data line. (The units on the horizontal axis are the sample numbers.) This looks very much like figure 2-2 in the datasheet.

Sampling the data for every falling edge on the clock resulted in this binary data:

...0000000011010100111110010101010000100011001000100100010011110010110101000111001001100001001001011010000010000000101000111110111000000000...

The Wikipedia article on magnetic cards describes the format of track 2. With this information, the bits were decoded to:

;9752238293627904=1109?6
Wich is the card number and expiration date. The '6' in the end is the checksum; all values xor:ed together should equal 0.

This started out well, I'll have a closer look at the PCB later on.