Spreading codes as used in CDMA are binary-vectors that can be used to encode multiple binary streams to be sent over a  shared medium at the same time using the same carrier frequency. Sounds funky? It is! The secret is to use vectors which are mutually orthogonal. An easy mathematical way to create those is constructing Hadamard matrices as a base for the vectors, because it’s rows are orthogonal to each other.

Constructing those is surprisingly easy. You start with a matrix of order n and create a new of order 2n

$H_{2n} = \begin{pmatrix} H_n & H_n \\ H_n & -H_n \end{pmatrix}$

A trivial Hadamard matrix is (1), lets expand it:
$H_1=(1) \rightarrow H_2=\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \rightarrow H_4=\begin{pmatrix} 1 & 1 & 1 & 1 \\ 1 &-1 & 1 &-1 \\ 1 & 1 & -1 & -1 \\ 1 &-1 & -1 & 1 \\ \end{pmatrix}$
$H_4$ allows 4 transmitters to simultaneously use the medium. To achive this you must encode each data stream. This is done by multiplying the data segment with the code. E.g: Sending 1011 =(1,-1,1,1) using code (1,-1,-1,1) becomes (1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,1,-1,-1,1). If you’re represent the negatives as zeros, this becomes a simple bitwise AND-operation.

Now what happens if multiple emitters try to transmit this at the same time? This is where the fancy math comes into play. Orthogonal vectors form a right angle in space. We have 4-dimensional vectors UMTS uses 512-dimensional vectors, so don’t try to picture it :) – instead think about what you know about dot products of vectors:

$\overrightarrow{v_1} \cdot \overrightarrow{v_2} = |\overrightarrow{v_1}||\overrightarrow{v_2}|\cdot cos(\alpha)$
Where $\alpha$ is the angle formed by the vectors.

As cos(90°) is 0, the dot product becomes 0 for orthogonal vectors.

When you send information at the same time, the carrier waves interfere with each other therefore the sending process of multiple transmitters could be described as follows (the different $c_n$s represent differences in transmitting power):

$c_1 \cdot \overrightarrow{v_1} + c_2 \overrightarrow{v_2} + ... + c_n \overrightarrow{v_n}$
Because the vectors are mutually orthogonal the reciever only has to dot-multiply the signal with the desired channel vector. All other subtotals become 0.

E.g: S1 sends 11 and uses code (1,-1,-1,1), S2 sends 10 and uses code (1,1,1,1),

$S1: \begin{array}{rrrrrrrrr} & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ \cdot & 1 & -1 & -1 & 1 & 1 &-1 &-1 & 1 \\ \hline = & 1 & -1 & -1 & 1 & 1 &-1 &-1 & 1 \end{array}$

$S2: \begin{array}{rrrrrrrrr} & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ \cdot & 1 & 1 & 1 & 1 &- 1 &-1 &-1 & -1 \\ \hline = & 1 & 1 & 1 & 1 &- 1 &-1 &-1 & -1 \end{array}$

$Sum: \begin{array}{rrrrrrrrr} & 1 & -1 & -1 & 1 & 1 &-1 &-1 & 1 \\ + & 1 & 1 & 1 & 1 &-1 &-1 &-1 & -1 \\ \hline = & 2 & 0 & 0 & 2 & 0 &-2 &-2 & 0 \end{array}$

The reciever doesn’t need the exact results of this, aslong as the signs preserve he can extract the the desired channel by dot multiplication:
First bit S1:
$\begin{pmatrix} 2 \\ 0 \\ 0 \\ 2 \end{pmatrix} \cdot \begin{pmatrix} 1 \\ -1 \\ -1 \\ 1 \end{pmatrix} = 2 \cdot 1 + 0 \cdot -1 + 0 \cdot -1 + 2 \cdot 1 = 4$

Second bit S2:
$\begin{pmatrix} 0 \\ -2 \\ -2 \\ 0 \end{pmatrix} \cdot \begin{pmatrix} 1 \\ 1 \\ 1 \\ 1 \end{pmatrix} = 0 \cdot 1 + -2 \cdot 1 + -2 \cdot 1 + 0 \cdot 1 = -4$

As you can see positive results represent logical ones and negative represent logical zeros. The result is gained by the dimension (length) of the code vector. This is a nice sideeffect of CDMA as in practice this means you can use significant lower emiting power.

Categories: Math, Networking

## Towel day! also: student bodies election

While the election (ÖH-Wahl) isn’t a big deal usually, this year – at least for some fans of the author Douglas Adams – it definitely was: one of the election dates was Towel Day, giving you a socially tolerated reason to bring a towel into the polling booth. This didn’t happen within the last 10 years…

• 1999: May 18th, 19th and 20th
• 2001: May 15th, 16th and 17th
• 2003: May 20th, 21st and 22nd
• 2005: May 31st, June 1st and 2nd
• 2007: May 22nd, 23rd and 24th
• 2009: May 26th, 27th and 28th
• 2011: May 24th, >>25th<<, 26th

…in fact I don’t even know if it ever happened before. Anyway I think this is an opportunity a student could only have once in a lifetime.

Categories: non-technical

I used to replace my arduino NG’s (which is using an atmega168) bootloader in
order to receive a clean prototyping interface which doesn’t use the arduino’s IDE and libraries. There’re a lot of benefits when doing so, but also disadvantages

pros:

• experienced atmega users will get a familiar programming interface
• software written for atmega is highly portable, old code could be reused even for non arduino applications
• more flash-space for actual programs
• as you’re programming the atmega directly without the arduinos interface you’ll have more possibilities of configuring and using your arduino

cons:

• your arduino won’t be compatible with wiring and arduino software
• your EEPROM won’t be programmable via USB
• writing code for the atmega wont be that easy anymore and you’ll need
more understanding of the microcontroller you’re using.

Hardware you’ll need:

• an atmega compatible ISP (In System Programmer)

Software you’ll need:

• avrdude or similar
• an avr toolchain (compiler,assembler, etc…)

I’ve decided using FastBoot by Peter Dannegger. For build and configuration instructions

Step 1: Connecting the arduino with the ISP

Make sure to configure your arduino to use an external power supply
and connect the ISC cable with arduinos “ISCP” contacts on it’s right side
 1_ _ |_|_|  MISO  VCC |_|_|  SCK   MOSI |_|_|  RESET GND ISCP 
Note: Pin1 is often marked by a red wire or a small triangle (or similar)

If your ISP doesn’t supply the Atmega itself (PWR led’s not glowing)  you’ll
need an external power supply

Step 2: Write the bootloader into atmega’s flash

You’ll need avrdude (or similar software)
to check if your ISP is connected right execute the following command:
 > avrdude -F -p MCU -c PROGRAMMERID -b BAUD for me: > avrdude -F -p atmega168  -c usbtiny -b 19200 
which gives following output :
 avrdude: AVR device initialized and ready to accept instructions Reading | #####...### | 100% 0.01s avrdude: Device signature = 0x1e9406 avrdude: safemode: Fuses OK avrdude done.  Thank you. 

 > avrdude -F -p MCU  -c PROGRAMMERID -b BAUD -U flash:w:yourfile.hex 
for me:
 > avrdude -F -p atmega168  -c usbtiny -b 19200 -U flash:w:bootloader.hex 

Step 3: Setting up the atmega’s secure bits (fuses) to setup the chip

Check your MCU’s datasheet and use [2] for desired configuration. Be careful
because this could easily lock you out of your microcontroller, so only a high power

First read the fuses: > avrdude -F -p MCU -c PROGRAMMERID -b BAUD -v
for me: > avrdude -F -p atmega168  -c usbtiny -b 19200 -v 
output: ... avrdude: safemode: lfuse reads as FF avrdude: safemode: hfuse reads as DF avrdude: safemode: efuse reads as 0 avrdude: safemode: Fuses OK 

On an arduino with atmega168 0xFF;0xDF; should be ok, which is external clock
with 8MHz+; Serial Flashing on; and no other special features
However efuse=0 (which reserves 512 KB of size for the bootloader) may not fit your bootloader check its documentation for efuse values

To burn the fuses use: > avrdude -F -p MCU  -c PROGRAMMERID -b BAUD -U lfuse:w:0xFF:m > avrdude -F -p MCU  -c PROGRAMMERID -b BAUD -U hfuse:w:0xDF:m > avrdude -F -p MCU  -c PROGRAMMERID -b BAUD -U efuse:w:0x00:m for me:
> avrdude -F -p atmega168  -c usbtiny -b 19200 -U lfuse:w:0xFF:m > avrdude -F -p atmega168  -c usbtiny -b 19200 -U hfuse:w:0xDF:m > avrdude -F -p atmega168  -c usbtiny -b 19200 -U efuse:w:0x00:m 

Step 4: upload the actual programm

The bootloader uses the ihex format so you’ll need to convert your application binary
to an ihex file (.hex)

 > ./bootloader -d /dev/ttyUSBx -b BAUD -p yourapp.hex

for me:
 > ./bootloader -d /dev/ttyUSB0 -b 19200 -p yourapp.hex 

Note:The’re is also an app for programming the atmega on windows x86 (not x84-64) systems
it will also work with DOSBox on x64 systems and linux (linux users better use [3]).

I’ve made a full package .tgz with a blinking-led-example (on digital pin 13). Here:

References:

[2] Fusebit Calculator:
http://www.engbedded.com/fusecalc/

[3] Linux programming tool (search for lboot.tgz or BootloaderXX_YYYYMMDD.tar.gz) (GER):
http://www.mikrocontroller.net/topic/73196#1955077

http://www.mikrocontroller.net/topic/146638#1824790

Arduino-to-Atmega168 Pinout:

Use an arduino as an ISP:
http://arduino.cc/en/Tutorial/ArduinoISP

A neat USB-ISP:

Atmega168 Datasheet:
http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf

Writing a bootloader by yourself (in german):