Kronos Robotics and Electronics
Site Map
 
Home Zeus Projects App Notes Downloads Dios Athena Forums
 

DAN121

Interfacing the Dios to VECTOR Compass Module

  By Michael Simpson

Have you ever wanted to create a portable compass that can be used with some of your electronic applications.  Well the Vector is the answer.  Its accurate and can be read at a rate of once every 150ms.

 

Schematic 1

There are a lot of pins on the compass module but just use the above schematic and it will make things a bit simpler.   We will be reading the module in binary slave mode.  This will allow us to read a heading between 0-359 degrees.  One other thing the schematic shows the reset connected to IO port on the Dios.  This is optional.   During all my tests I never used the reset at all.

One of the most difficult aspects of working with the Vector module is that the form factor wont fit on a normal breadboard.  Here you can see how I used to connected breadboards to place the Vector.

 

You can also make a carrier board by using some sockets and/or headers.

After connecting the Dios to the Vector load the following program and enable the debug terminal.

Program 1 download it here

func main()
    dim head

    initvector()

again:
    head=readvector()
    print head
    goto again

endfunc

'------------------------------------------------------------
'Vector 2x Routines
' This routine returns 0-359
'-------------------------------------------------------------
func readvector()
    dim inbyte,retval
    gconst SCLK 1 'Vector Pin 1
    gconst SS 2 'Vector Pin 4/5
    gconst DAT 3 'Vector Pin 2
    gconst RESET 4 'Vector Pin 17 (Optional)

    low SS
    pause 150

    clear inbyte,retval

    shiftin DAT,SCLK,8+64+32+128,inbyte
    retval.byte(1)=inbyte
    shiftin DAT,SCLK,8+64+32+128,inbyte
    retval.byte(0)=inbyte

    high SS
    exit retval
endfunc

'This routine resets the vector 2x
func initvector()

    high RESET
    output RESET,SCLK,SS
    input DAT

    high SCLK
    high SS
    low RESET
    pause 100
    high RESET
    pause 200

endfunc

 

The program initializes the Vector by setting up the IO ports and creating a couple global constants.   We then make calls to the readvector function.  This function uses two shiftin commands to pull the 16 bits of data.  The data is combined into the retval variable and is returned as a 0-359 value representing the heading.

Parts

Easy RS232 Driver  

DiosPro 28 Pin Chip

Dios 32 Pin Carrier (Carrier #1)

9 Pin Cable

 

 

Vector Compass Module: Sorry but you will have to search the internet on this one.

 

Copyright © 2001 - 2007 Kronos Robotics