It's been 3 years since I started using Teensy 3.6. Thank you very much for designing such a card. I have come up to date without any problems. However, there is a problem I could not solve for 10 days. I'm exhausted.
I want to do angular control on my robot using MPU6050 with my Teensy 3.6 card. I use J. Rowberg's library. I can read data from SDA0 and SCL0 (18,19) pins. But on the card I designed, SDA and SCL pins are connected to pins 38 and 37. So SDA1 and SCL1.
I can use SDA0 and SCL0 (18,19) pins with Wire.begin (). Logically, I should be able to use SDA1 and SCL1pins with Wire1.begin (). But no data is displayed on the serial screen.
I read all the articles I could find in the forum. I worked 10 days in Wire, i2c_t3, i2cdev and mpu6050 libraries. But I did not get any results. SDA and SCL pins were pulled up with both 2.7kohm and 4.7kohm resistors. There is no problem with electronic connection because it works with SDA0 and SCL0. I would be grateful if you tell me how to use pins 38 and 37 as SDA and SCL. Thank you all so much in advance.
I want to do angular control on my robot using MPU6050 with my Teensy 3.6 card. I use J. Rowberg's library. I can read data from SDA0 and SCL0 (18,19) pins. But on the card I designed, SDA and SCL pins are connected to pins 38 and 37. So SDA1 and SCL1.
I can use SDA0 and SCL0 (18,19) pins with Wire.begin (). Logically, I should be able to use SDA1 and SCL1pins with Wire1.begin (). But no data is displayed on the serial screen.
I read all the articles I could find in the forum. I worked 10 days in Wire, i2c_t3, i2cdev and mpu6050 libraries. But I did not get any results. SDA and SCL pins were pulled up with both 2.7kohm and 4.7kohm resistors. There is no problem with electronic connection because it works with SDA0 and SCL0. I would be grateful if you tell me how to use pins 38 and 37 as SDA and SCL. Thank you all so much in advance.
Code:
#include "I2Cdev.h"
#include "MPU6050.h"
//#define I2CDEV_IMPLEMENTATION == I2CDEV_TEENSY_3X_WIRE
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif
MPU6050 accelgyro;
int16_t ax, ay, az;
int16_t gx, gy, gz;
float t1 = 0, t2 = 0;
float gyroZt1 = 0;
float gyroZt2 = 0;
float aciZ = 0;
int steta, teta, hata;
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
Wire.begin();
Serial.begin(115200);
accelgyro.initialize();
accelgyro.setXAccelOffset(-649);
accelgyro.setYAccelOffset(507);
accelgyro.setZAccelOffset(1429);
accelgyro.setXGyroOffset(58);
accelgyro.setYGyroOffset(31);
accelgyro.setZGyroOffset(100);
delay(5000);
digitalWrite(13, LOW);
gyroZt2 = gyroZt1;
t2 = t1;
t1 = millis();
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
gyroZt1 = gx;
aciZ = aciZ + 0.00000001 + ((t1 - t2) * (gyroZt1 + gyroZt2 )) * 0.00000382;
steta = int(aciZ + 180.0);
Serial.print("aciZ\t");
Serial.print(aciZ);
Serial.print("\t");
Serial.print("steta\t");
Serial.println(steta);
delay(1000);
}
void loop()
{
gyroZt2 = gyroZt1;
t2 = t1;
t1 = millis();
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
gyroZt1 = gx;
aciZ = aciZ + ((t1 - t2) * (gyroZt1 + gyroZt2 )) * 0.00000382; //0.00000001
teta = int(aciZ + 180.0);
Serial.print("teta\t");
Serial.println(teta);
}