public static string Start() { //Wait for devices to stabilise Thread.Sleep(1500); #region variables const short sleep = 30; const float milliVoltPerDeg = 3.2f; //3.3mV/Deg/Sec (I needed to calibrate it to 3.2 for better readings) const short avg = 16; short gyroXZero = 0; short gyroYZero = 0; short gyroZZero = 0; short gyroXMin = 3300; short gyroYMin = 3300; short gyroZMin = 3300; short gyroXMax = 0; short gyroYMax = 0; short gyroZMax = 0; #endregion GyroGlobal = ""; var gyroXReading = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0); gyroXReading.SetLinearScale(gyroXMax, gyroXMin); var gyroYReading = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An1); gyroYReading.SetLinearScale(gyroYMax, gyroYMin); var gyroZReading = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An2); gyroZReading.SetLinearScale(gyroZMax, gyroZMin); //Calibrate the gyro gyroXZero = Calibrate(gyroXReading, ref gyroXMax, ref gyroXMin, sleep, avg, gyroXZero); gyroYZero = Calibrate(gyroYReading, ref gyroYMax, ref gyroYMin, sleep, avg, gyroYZero); gyroZZero = Calibrate(gyroZReading, ref gyroZMax, ref gyroZMin, sleep, avg, gyroZZero); //Read and print Gyro results Run(gyroXReading, gyroXMax, gyroXZero, gyroXMin, sleep, milliVoltPerDeg, "X"); Run(gyroYReading, gyroYMax, gyroYZero, gyroYMin, sleep, milliVoltPerDeg, "Y"); Run(gyroZReading, gyroZMax, gyroZZero, gyroZMin, sleep, milliVoltPerDeg, "Z"); gyroXReading.Dispose(); gyroYReading.Dispose(); gyroZReading.Dispose(); string ReturnValue = GyroGlobal; return(ReturnValue); }
public static string Start() { AccGlobal = ""; var accX = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An3); var accY = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An4); var accZ = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An5); Accelerometer_(accX, "X"); Accelerometer_(accY, "Y"); Accelerometer_(accZ, "Z"); accX.Dispose(); accY.Dispose(); accZ.Dispose(); string ReturnValue = AccGlobal; return(ReturnValue); }
public void Dispose() { adc.Dispose(); }