Rev 413 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 413 | Rev 416 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | 31 | ||
Line 32... | Line 32... | ||
32 | DDRB |= (1<<PB7)|(1<<PB5)|(1<<PB2); // J8, MOSI, SCK Ausgang |
32 | DDRB |= (1<<PB7)|(1<<PB5)|(1<<PB2); // J8, MOSI, SCK Ausgang |
Line -... | Line 33... | ||
- | 33 | ||
33 | 34 | PORTD &= ~(1<<PD3); // J5 auf Low |
|
34 | PORTD &= ~(1<<PD3); // J5 auf Low |
35 | |
Line 35... | Line 36... | ||
35 | 36 | // Init Statemachine |
|
36 | MM3.AXIS = MM3_X; |
37 | MM3.AXIS = MM3_X; |
Line 56... | Line 57... | ||
56 | case MM3_START_TRANSFER: |
57 | case MM3_START_TRANSFER: |
57 | PORTB &= ~(1<<PB2); // J8 auf Low (war ~125 µs auf High) |
58 | PORTB &= ~(1<<PB2); // J8 auf Low (war ~125 µs auf High) |
Line 58... | Line 59... | ||
58 | 59 | ||
59 | if (MM3.AXIS == MM3_X) SPDR = 0x31; // Schreiben ins SPDR löst automatisch Übertragung (MOSI und MISO) aus |
60 | if (MM3.AXIS == MM3_X) SPDR = 0x31; // Schreiben ins SPDR löst automatisch Übertragung (MOSI und MISO) aus |
60 | else if (MM3.AXIS == MM3_Y) SPDR = 0x32; // Micromag Period Select ist auf 256 (0x30) |
61 | else if (MM3.AXIS == MM3_Y) SPDR = 0x32; // Micromag Period Select ist auf 256 (0x30) |
Line 61... | Line 62... | ||
61 | else if (MM3.AXIS == MM3_Z) SPDR = 0x33; // 1: x-Achse, 2: Y-Achse, 3: Z-Achse |
62 | else SPDR = 0x33; //if (MM3.AXIS == MM3_Z) // 1: x-Achse, 2: Y-Achse, 3: Z-Achse |
62 | 63 | ||
63 | MM3.DRDY = SetDelay(5); // Laut Datenblatt max. Zeit bis Messung fertig (bei PS 256 eigentlich 4 ms) |
64 | MM3.DRDY = SetDelay(5); // Laut Datenblatt max. Zeit bis Messung fertig (bei PS 256 eigentlich 4 ms) |
Line 221... | Line 222... | ||
221 | // Neigungskompensation |
222 | // Neigungskompensation |
222 | x_corr = x_axis * cos_nick; |
223 | x_corr = x_axis * cos_nick; |
223 | x_corr += y_axis * sin_roll * sin_nick; |
224 | x_corr += y_axis * sin_roll * sin_nick; |
224 | x_corr -= z_axis * cos_roll * sin_nick; |
225 | x_corr -= z_axis * cos_roll * sin_nick; |
Line 225... | Line 226... | ||
225 | 226 | ||
226 | y_corr = y_axis * cos_roll; |
- | |
Line 227... | Line 227... | ||
227 | y_corr += z_axis * sin_roll; |
227 | y_corr = (y_axis * cos_roll) + (z_axis * sin_roll); |
228 | 228 | ||
229 | // Winkelberechnung |
229 | // Winkelberechnung |
230 | heading = atan2_i(x_corr, y_corr); |
230 | heading = atan2_i(x_corr, y_corr); |