Main Site Documentation

Accelerometer module


#1

I am trying to use an accelerometer module (Seeed) on my G120HDR Rev II.
As th G120HDR is not a real gadgeteer board, several questions rise:

  • I wired the accelerometer to the User socket on the G120HDR as a I-socket
    From the developer’s guide: SDA = P0.27 and SCL = P0.28
    Which GPIO! to use for INT1 (pin 3 on the accelerometer)?

  • I added “Gadgeteer” and “GTM.Seeed.Accelerometer” to the references and modified the program
    from the accelerometer user’s guide to:

using System;
using Microsoft.SPOT;
using Gadgeteer;


namespace AccMeter
{
    public class Program
    {
        public static Gadgeteer.Modules.Seeed.Accelerometer accelerometer;
        public static void Main()
        {
            accelerometer = new Gadgeteer.Modules.Seeed.Accelerometer(1);
            // Event that fires when a measurement is ready
            accelerometer.MeasurementComplete += new Gadgeteer.Modules.Seeed.Accelerometer.MeasurementCompleteEventHandler(accelerometer_MeasurementComplete);

            // Set the time between measurements and start continuous measurements.
            accelerometer.ContinuousMeasurementInterval = new TimeSpan(0, 0, 0, 0, 250);
            accelerometer.StartContinuousMeasurements();
        }

        static void accelerometer_MeasurementComplete(Gadgeteer.Modules.Seeed.Accelerometer sender, Gadgeteer.Modules.Seeed.Accelerometer.Acceleration acceleration)
        {
            Debug.Print("Y-axis acceleration: " + acceleration.Y);
        }
    }
}

I used socketnumber = 1 for the accelerometer which results in the runtime error
"An unhandled exception of type ‘Gadgeteer.Socket.InvalidSocketException’ occurred in Gadgeteer.dll

Additional information: Module Accelerometer cannot be used with invalid socket number 1"

Off course I tried several other socketnumbers, all with the same result.

My questions are: Can anybody help me starting up a project with the G120HDR and the accelerometer.
Do I use the correct wiring for the socket and how do I define the interrupt GPIO.
Is there a way to circumvent the socketnumber problem and still use the gadgeteer software or do I have to start all over using bare I2C calls in pure .NETMF

Any help will be appreciated!


#2

Heres a thread worth reviewing. https://www.ghielectronics.com/community/forum/topic?id=12508&page=1 This will give you an idea how you might deal with your problem.

As Andre says, you should post code within the CODE tags the site has. Edit your original post (that’s the pencil looking icon on the top right of it), then highlight the code, then hit the “101010” button at the TOP LEFT of the message box (not the orange one below the message box), and submit again.