public static double getGres(Gscale gscale)
    {
        switch (gscale)
        {
        // Possible gyro scales (and their register bit settings) are:
        // 250 DPS (00), 500 DPS (01), 1000 DPS (10), and 2000 DPS  (11).
        // Here's a bit of an algorith to calculate DPS/(ADC tick) based on that 2-bit value:
        case Gscale.GFS_250DPS:
            gRes = 250.0 / 32768.0;
            break;

        case Gscale.GFS_500DPS:
            gRes = 500.0 / 32768.0;
            break;

        case Gscale.GFS_1000DPS:
            gRes = 1000.0 / 32768.0;
            break;

        case Gscale.GFS_2000DPS:
            gRes = 2000.0 / 32768.0;
            break;
        }
        return(gRes);
    }
Exemplo n.º 2
0
        public static float GetGres(Gscale Scale)
        {
            switch (Scale)
            {
            // Possible gyro scales (and their register bit settings) are:
            // 125 DPS (100), 250 DPS (011), 500 DPS (010), 1000 DPS (001), and 2000 DPS (000).
            case Gscale.GFS_125DPS:
                return((float)(0.00381f * (Math.PI / 180)));    //return 124.87 / (32768.0 * 4); // per data sheet, not exactly 125!?

            case Gscale.GFS_250DPS:
                return((float)(0.007622f * (Math.PI / 180)));    //1.0 / 262.4; //return 249.75 / 32768.0;

            case Gscale.GFS_500DPS:
                return((float)(0.01524f * (Math.PI / 180)));   //1.0 / 262.4; //return 499.5 / 32768.0;

            case Gscale.GFS_1000DPS:
                return((float)(0.03048f * (Math.PI / 180)));    //1.0 / 262.4; //return 999.0 / 32768.0;

            case Gscale.GFS_2000DPS:
                return((float)(0.06097f * (Math.PI / 180)));   //1.0 / 262.4; //return 1998.0 / 32768.0;
            }

            return(0);
        }
Exemplo n.º 3
0
 public static void Init(AScale AccelerometerScale, Gscale GyroscopeScale)
 {
     aRes = GetAres(AccelerometerScale);
     gRes = GetGres(GyroscopeScale);
 }