Reply
Thread Tools
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#111
Originally Posted by Jack6428 View Post
I wanted to ask... i thought the N900 does have a digital compass actually? When i use Ovi Maps and the A-GPS, and set a route and drive by car... the map is turning by itself as i drive, targeting always north. For ex. when i turn right, the map turns with me. I though that can be done only with a digital compass? Or am i wrong?
I'm pretty sure it's just able to tell the direction you are going in by gaps in the gps, (ie you getting closer and farther away from them)...

If you face the other way in a taxi etc, it does the same as facing forward. So i don't think it uses a compass unfortunately
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 2,102 | Thanked: 1,309 times | Joined on Sep 2006
#112
If you've moving the GPS can tell your track, which is probably also your heading assuming you're driving.

When you're stationary it can't tell which way you're pointing
 
Posts: 71 | Thanked: 34 times | Joined on Sep 2009
#113
Originally Posted by Otaku View Post
Looks like someone named "HapticGuide" is working on a bluetooth compass prototype for the N900:
Unfortunately, reading the latest update to the project, it seems it's using GPS and movement to determine your direction, not an actual magnetic compass (though the project is advertised as a "wearable compass").

Anyone in this thread constructed a working compass prototype yet?
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#114
Not for the N900 since I don't have one, but I have an HMC5843 breakout, arduino, and bluetooth talking together sending X,Y,Z. I'm working on adding barometric pressure.
 
Posts: 243 | Thanked: 172 times | Joined on Sep 2007 @ silicon valley
#115
tz1, can you post how you did that? I'm guessing it works for any bluetooth device which handles serial ports. Thanks!
 
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#116
I2C Magnetometer:

http://www.sparkfun.com/commerce/pro...oducts_id=9371

First, you might need to fix the capacitor, see the comments.

On the page is some sample code for an ATmega328p. I basically use that merged with an improved I2C driver on my 3.3v Arduino Pro.

http://www.sparkfun.com/commerce/pro...oducts_id=9220

Normally to an FTDI 3.3v breakout to /dev/ttyUSB0, but it is just TTL serial UART levels.

I have a Parani bluetooth module from sena.com that just takes 3.3v, ground, tx, and if you need rx, or you could also use the bluetooth mate:

http://www.sparkfun.com/commerce/pro...oducts_id=9358

The HMC I have runs at around 70Hz and returns 13-14 bits for each axis so even 9600 baud should work but I usually set things faster.

Last edited by tz1; 2010-01-18 at 16:59. Reason: add link to arduino pro for completeness
 

The Following 2 Users Say Thank You to tz1 For This Useful Post:
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#117
It produces output like:

472, -9, -687
465, -4, -685
474, -4, -692
471, -8, -683
467, 1, -694
471, -5, -688
475, -11, -691
471, 2, -698
473, 8, -685
474, -3, -685
466, 0, -686
479, -1, -698
469, -7, -694
469, 1, -687
471, 2, -688
472, 5, -690
477, -2, -688

Read the datasheet for details.

Code:
#include <avr/io.h>

#define ENABTW ((1<<TWINT)|(1<<TWEN)|(0<<TWIE))   // 0x80 4 1
#define START TWCR = (ENABTW|(1<<TWSTA))  // 0x20
#define STOP TWCR = (ENABTW|(1<<TWSTO))  // 0x10
#define SEND(x)  TWDR = x;  TWCR = ENABTW;
#define RECV(ack) TWCR = ENABTW | (ack? (1<<TWEA) : 0 );
unsigned char twista;
unsigned twitmo;
#define WAIT twitmo=0; while (!((twista = TWCR) & (1 << TWINT)) && ++twitmo);

/////===================================////////////////////
void TWIinit(void)
{
    DDRC &= ~0x30;              // pullup
    PORTC |= 0x30;              // pullup
    TWBR = 2;                   // 400 khz
    TWCR |= (1 << TWEN);
}

void TWIdocmd(unsigned char *msg)
{
    unsigned int mlen, rdwrf;

    while ((mlen = *msg++)) {
        rdwrf = *msg & 1;
        START;
        WAIT;
        do {
            SEND(*msg++);
            WAIT;
            // should check for ACK - twista == SAWA or SDWA
        } while (--mlen && !rdwrf);
        // read
        while (mlen--) {
            RECV(mlen);
            WAIT;
            *msg++ = TWDR;
        }
    }
    STOP;
}

#ifndef F_CPU
#define F_CPU 8000000
#endif
#include <util/delay.h>
#include <stdio.h>

static int serout(char c, FILE * stream)
{
    if (c == '\n') {
        while( !(UCSR0A & 0x20) );
        UDR0 = '\r';
    }
    while( !(UCSR0A & 0x20) );
    UDR0 = c;
    return 0;
}
static FILE fpuart = FDEV_SETUP_STREAM(serout, NULL, _FDEV_SETUP_WRITE);

void UART_Init(unsigned centibaud) {
    unsigned acc,count;
    // we don't do this often, and it should be more accurate than divides
#define BCLK (F_CPU/800)
    acc = 0;
    count = 0;
    while( acc < BCLK )
        acc += centibaud, count++;
    if( acc - BCLK > centibaud >> 1 )
        count--;
    UBRR0 = count - 1;

    UCSR0C = 0x06;              //8N1 (should be this from reset)
    UCSR0A = 0xE0 | 2;          // clear Interrupts, UART at 2x (xtal/8)
    UCSR0B = 0x18;              // oring in 0x80 would enable rx interrupt
    stdout = &fpuart;         //Required for printf init
}

unsigned char sendhmci[] = {
    5, 0x3c, 0, 0x18, 0, 0,
    0
};
unsigned char sendhmcpr[] = {
    2, 0x3c, 9,
    0
};
unsigned char sendhmcrd1[] = {
    2, 0x3d, 0,
    0
};
unsigned char sendhmcrd2[] = {
    7, 0x3d, 0, 0, 0, 0, 0, 0,
    0
};

int main(void)
{
    unsigned char cnt, sta;
    int xo, yo, zo;

#define BAUD 57600
    UART_Init(BAUD/10);

    for (;;) {
        TWIinit();
        printf("HMC5843\n");
        TWIdocmd(sendhmci);
        printf("Init2\n");
        TWIdocmd(sendhmci);
        printf("Ready\n");
        cnt = 0;
        while (cnt++ < 20) {
            TWIdocmd(sendhmcpr);
            TWIdocmd(sendhmcrd1);
            sta = sendhmcrd1[2];
            if (sta != 5)
                continue;
            cnt = 0;
            TWIdocmd(sendhmcrd2);
            xo = sendhmcrd2[3] | (sendhmcrd2[2] << 8);
            yo = sendhmcrd2[5] | (sendhmcrd2[4] << 8);
            zo = sendhmcrd2[7] | (sendhmcrd2[6] << 8);
            printf("%5d,%5d,%5d\n", xo, yo, zo);
            _delay_ms(12);
        }
    }
}
 
Posts: 172 | Thanked: 170 times | Joined on Jan 2010 @ Sweden
#118
Have a look at:

Using PS3 SixAxis controller with N900

http://talk.maemo.org/showthread.php?t=41693
 
blackbird's Avatar
Posts: 31 | Thanked: 5 times | Joined on Jan 2010 @ The Netherlands
#119
Make that i2c magnetometer small enough to fit in the microsd card bay
 
Posts: 2 | Thanked: 1 time | Joined on Jun 2010 @ Latvia
#120
Hi!

I am also trying to get some sort of digital compass for my N900, and as far as I checked the price and shipping costs for all the parts necessary for simple IC2 -> Bluetooth digital compass, for me it is cheaper, faster and easier to just buy used Android phone (G1/Dream or Tattoo), attach it to the back of N900 with two elastic bands, and create a simple App that transmits compass coordinates from Android phone via Bluetooth/WiFi. I know it sounds completely stupid, but it solves all the battery/circuitry/soldering/etc problems for the same price or cheaper, AND I get an additional phone. Mind if I include this as one of the options in the Digital Compass wiki section?

Edgars
 

The Following User Says Thank You to edgarsz For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 12:46.