Main Site Documentation

Fez mini + digital compass


#1

i have fez mini, and today got my package : compass module + gadgeteer expansion block

Connected Pin3(on expansion mdule) to compass, and connected eblock connector from expansion module to analogIn An6.

program creates an instance of compass (driver code from seeed studios), and program compiles, no problem. the problem is that compass has these references :

using System;
using Microsoft.SPOT;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GTI = Gadgeteer.Interfaces;

which are not available in fez mini netmf assemblies. is it possible to deploy one of the assemblies ? instinct tells me gadgeteer assemblies cannot be loaded on usbizi chipset but not sure.

is there another way to communicate with compass module ? compass module uses i2c bus, which is used to construct a socket. if these constructs are not available in fez mini/usbizi, what other way is possible to communicate with digital compass ?
thank you very much for your time.


#2

If you want to use Gadgeteer drivers on pure .NET MF platform you need to strip them from Gadgeteer libs and adjust them. This is always possible because Gadgeteer is built on top of .NET MF. I have adjusted the Compass driver for you. Please check if it works. If not then compare with the original code (can be found here http://gadgeteer.codeplex.com) to spot the bug.


#3

Forgot you can only attatch images to your posts, not zip files :confused: You can download the .NET MF version of this driver from here:

http://speedy.sh/ZYbkq/NETMF.Compass.zip

The original code is not very beautiful but i didn’t change that in the .NET MF version so that you can spot the differences.


#4

thank you very much Gralin. Have not had time to reply because of work issues.
What I cannot understand is how the signals are communicated between the GPIO pin to analog pin compass is connected to.

say GPIO 8, how does this relate to, say An3 ?


#5

No mather how you identify your pins it’s always a numeric value under the hood. So When you use pure Microsoft.SPOT.Hardware.Cpu.Pin enum you get this values:

        public enum Pin
        {
            GPIO_NONE = -1,
            GPIO_Pin0 = 0,
            GPIO_Pin1 = 1,
            GPIO_Pin2 = 2,
            GPIO_Pin3 = 3,
            GPIO_Pin4 = 4,
            GPIO_Pin5 = 5,
            GPIO_Pin6 = 6,
            GPIO_Pin7 = 7,
            GPIO_Pin8 = 8,
            GPIO_Pin9 = 9,
            GPIO_Pin10 = 10,
            GPIO_Pin11 = 11,
            GPIO_Pin12 = 12,
            GPIO_Pin13 = 13,
            GPIO_Pin14 = 14,
            GPIO_Pin15 = 15,
        }

And when you are using GHIElectronics.NETMF.FEZ.FEZ_Pin.Digital enum from FEZDomino_GHIElectronics.NETMF.FEZ.dlll you get this values:

        public enum Digital : byte
        {
            LDR = 0,
            UEXT6 = 1,
            Di5 = 2,
            UEXT4 = 3,
            LED = 4,
            UEXT3 = 5,
            UEXT8 = 6,
            Di6 = 7,
            UEXT7 = 8,
            UEXT9 = 10,
            UEXT5 = 11,
            UEXT10 = 12,
            Di7 = 15,
            Di1 = 18,
            Di4 = 19,
            Di0 = 20,
            An3 = 22,
            Di8 = 23,
            An2 = 24,
            Di9 = 25,
            An1 = 26,
            An0 = 28,
            An4 = 29,
            Di3 = 31,
            An5 = 32,
            Di2 = 33,
            Di10 = 35,
            Di12 = 40,
            Di11 = 41,
            Di13 = 42,
        }

#6

ok.so for An2 or An4, whose Digital enum equates to 24 & 29 respectively, where does that map to the GPIO enum ?
to make sure we’re on the same page, the JST3AA cable has to be connected to an input on the power board, not to the fez mini board, right ?


#7

the GPIO enum does not contain all values. You need to use enum specific for your CPU/board or use simple casting. In your case that would be:

var an2 = (Cpu.Pin)24;
var an4 = (Cpu.Pin)29;

#8

Ok i finally understood what you are trying to do :wink: FEZ Mini has I2C pins (SDA and SCL) on pins AN4 and AN5

You also need to connect the interrupt pin from compass (Pin 3) to interrupt pin in FEZ Mini, e.g. AN3.


#9

thank you :slight_smile: :slight_smile: as you can see by now, I’m really green when it comes to electronics.

from what i understood, I need to
a) connect pin3 of compass to say An3 (An3’s pin3 as well ?) (1 single wire between the 2 pins),
b) plug JST3AA cable (coming from expansion block, which is coming from compass) into An4 or An5 (because they are I2C pins)
c) construct Compass as

var an4 = (Cpu.Pin)29;

#10

The extender module is useless in your case so let me focus on compass + fez mini configuration. You need to connect 5 pins from compass:

Pin 1 - 3.3 V
Pin 3 - DataReady
Pin 8 - SDA
Pin 9 - SCL
Pin 10 - GND

The easiest way is to use An3 of FEZ Mini for the DataRady as it’s right next to I2C pins (An4, An5). The pin numbers i have posted before were taken from Domino. The An3 pin number is:

An3 = 22,

So you need to use 22 as the value in compass constructor.


#11

i owe you a few beers.
i dismantled jst3aa cables to connect as you explained. my question is :

the fez mini is plugged into a control board, that is pins will be ‘occupied’, or plugged into the control board. should i be connecting wires to the 5 pins, and still plug the fez mini into the control board ?
attached pic to help explaining…

thanks a lot !

by the way, for ground and 3.3v, can i use the pins sitting on the ‘top’ side of fez mini ? (that is not those getting plugged into control board


#12

Wow Garlin, you are the support master. Thanks for helping.


#13

@ greywolv Your project is like a good movie or a an atractive woman. You reveal more in every post :smiley: Now i see you have a FEZ Robot Kit mainboard! This is why you bough the eblock Expansion Module in the first place :smiley: Ok so i take that back, you cac make use out of it :slight_smile: Just connect your compass to the expansion module and connect the eblock to Robot mainboard using three jst3aa cables - SDA (Pin8), SCL (Pin9), DataReady (Pin3). The Power and Ground will be already delivered by the jst3aa cables. You can also do the way you have shown in the picture.

@ Gus Don’t mention it. This thread is a great example how gadgeteer makes life easier for beginners!


#14

Use those connectors on the mainboard


#15

:slight_smile: sorry did not realise. of course, fez mini does not imply robot kit mainboard. my bad…

it’s much easier this way. so
pin 8 on eblock (SDA) goes to An5
pin 9 on eblock (SCL) goes to An4
pin 3 on eblock (dataready) goes to An3

right ?

modified…ok switched pin 8 on eblock (SDA) goes to An4
pin 9 on eblock (SCL) goes to An5. working :slight_smile:

THANK YOU for bearing with me. yes, your support is really good. would have taken me ages (if at all) to figure this out.

my project is a for robot to navigate a path, having calculated same path using a wavefront algorithm. of course, having a compass to calculate angles reliably is a must. Thank you Gralin :wink:


#16

You got SDA and SCL mixed up. Other than that, yes. Try it and i hope it works :slight_smile:


#17

yes got them mixed up. working :slight_smile:
now will try to figure out the mathematics of calculating the angle.


#18

Glad to hear that. From this point it’s pure fun.