• No results found

The layout from 6.5 was used to etch a PCB card. The rest of the card was assembled by soldering the components on to the PCB. The assembly of the card should be done step by step, and each step should be tested before moving to next step. By doing this, each part of the circuit can be tested as isolated as possible. And it’s also possible to know, to a certain degree, that the components that are assembled and tested are working as planned.

6.6.1 to 6.6.6 describes the steps of he assembly, and the tests done after completing each step. Before soldering anything to the card, the card should be disconnected from the STK1000 card and from power supply. While soldering it’s easy to make short circuits, which should be avoided.

6.6.1 Power Regulator Circuit

The power regulator circuit consists of a power jack, a voltage regulator, two capacitors and a 3 pin header used for selecting power supply. It was tested by connecting a 9V source to the power jack, and selecting external power supply. The output voltage was measured to 5.0V , which means that the voltage regulator are working.

6.6.2 ATmega128 and JTAG Interface

After soldering the ATmega128, it’s important to check that there are no short circuits between its pins. After checking this thoroughly, the JTAG header and decoupling capac- itor was connected. The different functions of the ATmega128 will be tested when they are needed. The first test was to connect to the ATmega128 through the JTAG-interface. The avrdude command below connects to the ATmega128 and writes some info about it. This command returned correct information about the ATmega128, which means that basic operations of the ATmega128 works, and that the JTAG interface is able to program it.

sudo a vr d u d e −P usb −pm128 −c j t a g 2 −v

6.6.3 Crystal Circuit

The crystal circuit consists of a crystal (16MHz) and two capacitors. To use this circuit, the fuse bits2 of the ATmega128 has to be changed. The avrdude command below does this.

2Fuse bits are bits in AVR microcontrollers memory that defines clock source and other important

6.6. ASSEMBLY AND TEST 41

When starting up the ATmega128 with the crystal circuit and new fuse bits, the crystal pins were probed with an oscilloscope. The result was a sinus signal with a frequency of 16M Hz, which means that the crystal circuit works.

sudo a vr d u d e −P usb −pm128 −c j t a g 2 −U l f u s e : w: 0 xFE :m −U h f u s e : w: 0 x89 :m −U e f u s e : w: 0 xFF :m

6.6.4 RS-232 and Reset Circuits

These two elements were best to test together. The RS-232 circuit consists of the MAX233 IC and a 9 dsub connectors (connector used by serial port of a standard computer). The reset circuit consists of a button, a resistor and a capacitor. The RS-232 circuit was tested by sending a byte of data from the card, when it was connected to the workstation with a serial-cable. The code below sends one byte with a baud rate of 19.2kbps. When running this code, the workstation received the byte when using a program like minicom. The reset circuit worked since the same byte was received by the workstation each time the reset button was pressed.

1 // I n c l u d e s . 2 #include <a v r / i o . h> 3 4 i n t main ( ) 5 { 6 // S e t d i r e c t i o n r e g i s t e r s 7 s e t b i t (DDRD, 3 ) ; 8 c l e a r b i t (DDRD, 4 ) ; 9 10 // BAUD r a t e = 1 9 . 2 k 11 UBBR1H = 0 ; 12 UBBR1L = 5 1 ; 13 14 // E n a b l e b o t h t r a n s m i t and r e c e i v e 15 UCSR1B = (1<<RXEN1) | (1<<TXEN1) ; 16

17 // Use 8 b i t d a t a , no p a r i t y and 2 s t o p b i t s . 18 UCSR1C = (1<<UCSZ11 ) | (1<<UCSZ10 ) | (1<<USBS1 ) ; 19

20 // S t a r t s e n d i n g by w r i t i n g t o t h e s e n d d a t a r e g i s t e r . 21 UDR1 = ’A ’ ;

6.6.5 Headers for STK1000 and debugging

These headers were tested by connecting the header to the general expansion header (J29) on the STK1000 board, and try the same test as in 5.5. Since the SPI communication also worked through the header, it meant that the header are connected properly. To check if the STK1000 can be used as power supply for the I/O card, the jumper was from external power supply to STK1000. This worked, which meant that the STK1000 can supply the ATmega128 with power.

6.6.6 ADC Supply Filter

The filter for the ADC supply is a LC-filer, and it’s used to filter out digital noise, so the analog reference is kept as stable as possible. This is to ensure that the analog in is

as accurate as possible. On this prototype card, the inductor of the LC-filter was short circuited, since no inductor of correct value was available. The inductor works as a short circuit for DC current, but it stops AC current. So replacing the inductor with a short circuit will just make the filter stop high frequency noise less effective.

6.6.7 Analog Output Circuit

The analog output circuit was assembled with different filters, that were used to find a filter for the final I/O-card. 9.2.2 describes the different filters that were tested and the results.