Hi, ich arbeite zurzeit an einem Schulprojekt. Hierfür versuche ich einen 9DOF-Sensor von Sparkfun auszuwerten. Beim Beschleunigungssensor hatte ich kaum Probleme, jedoch treten diese nun beim Gyrosensor ITG3200 auf. Das Problem ist, dass ich immer nur 0 als Werte zurückgeliefert bekomme. Ich habe auch das von Sparkfun zur Verfügung gestellte Testprogramm 1-zu-1 auf meinen Microcontroller (Arduino Leonardo, VCC an 3,3 V ausgang verbunden) gespielt, aber auch dies liefert mir nur 0en. Deshalb wollte ich euch bitten mir weiterzuhelfen, wenn ihr mein Problem lösen könnt. Freundliche Grüße
// Hier mein Quellcode #include <Wire.h> #define DLPF_FS (0x16) #define ITG (0x69) #define TO_READ_GYRO (8) byte gyroValues[TO_READ_GYRO]; //In the setup section of the sketch the serial port will be configured, the i2c communication will be initialized, and the itg-3200 will be configured. void setup() { //Create a serial connection using a 9600bps baud rate. Serial.begin(9600); //Initialize the I2C communication. This will set the Arduino up as the 'Master' device. Wire.begin(); writeTo(ITG, 0x3E, 80); writeTo(ITG, 0x3E, 03); writeTo(ITG, 0x15, 07); writeTo(ITG, DLPF_FS, 19); writeTo(ITG, 0x17, 00); } void loop() { //Create variables to hold the output rates. int gyroAddress = 0x1B; double gyroX, gyroY, gyroZ, temp; temp = (((int)gyroValues[0])<< 8) | gyroValues[1]; gyroX = (((int)gyroValues[2])<< 8) | gyroValues[3]; gyroY = (((int)gyroValues[4])<< 8) | gyroValues[5]; gyroZ = (((int)gyroValues[6])<< 8) | gyroValues[7]; Serial.print("X: "); Serial.println(gyroX); Serial.print("Y: "); Serial.println(gyroY); Serial.print("Z: "); Serial.println(gyroZ); Serial.println(" "); delay(1000); } //Writes val to address register on device void writeTo(int device, byte address, byte val) { Wire.beginTransmission(device); //start transmission to device Wire.write(address); // send register address Wire.write(val); // send value to write Wire.endTransmission(); //end transmission } //reads num bytes starting from address register on device in to buff array void readFrom(int device, byte address, int num, byte buff[]) { Wire.beginTransmission(device); //start transmission to device Wire.write(address); //sends address to read from Wire.endTransmission(); //end transmission Wire.beginTransmission(device); //start transmission to device Wire.requestFrom(device, num); // request 6 bytes from device int i = 0; while(Wire.available()) //device may send less than requested (abnormal) { buff[i] = Wire.read(); // receive a byte i++; } Wire.endTransmission(); //end transmission }
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.