-1
\$\begingroup\$

I am using AT32UC3C microcontroller which has 64 pins. I am using gpio pin PB01 as SCK and gpio pin PA04 as SDA and ticking then manually high and low. These pins are configured as GPIO_OPEN_DRAIN and GPIO_DIR_OUTPUT. I have connected this controller to MPU9150 sensor connecting pin PB01 to SCK and PA04 to SDA of the sensor.What I observed on oscilloscope is when I read accelerometer values from MPU9150 the SDA line high voltage is 3.3V and low voltage is 0.24V. But when I see the voltage on SDA line while accessing magnetometer of MPU9150 the lower value goes up to 1.68V. The sensor is sending data and acknowledging to microcontroller but microcontroller doesn't treat 1.68V as logic low. So all register values are read as 1. Can I solve the problem without changing the hardware? I mean if I define a new threshold value for logic high and logic low level and say that if voltage is above 2V consider it logic high else logic low. Is it possible.

The datasheet of AT32UC3C says:

PIN__GPIO__PIN TYPE_______GPIO FUNCTION

                                      A             B                 C

PA04----4-----------x1/x2-----------ADCIN0-----USBC-ID-----AC1FA0-ACAOUT

Can I use Analog comparators to compare the value of this pin to some other pin whose voltage is 2V and instead of reading digital gpio value I assign 0 when voltage is below 2V and 1 if voltage is above 2V.

Or is my configuration wrong. Can I used open drain mode for gpio pins with dir_output mode? If my configuraton is wrong what should be the correct configuration.

Or is there any other way to solve the problem? Please tell me if you need any other information. Thanks in advance.MICROCONTROLLER SCHEMATICMPU9150 CONNECTION SCHEMATIC

I would like to share 1 more fact. When I read acc and gyro, Auxiliary SDA and Primary SDA as well as Auxiliary SCL and Primary SCL read exactly the same voltage levels.(seen on oscilloscope). But when I read magnetometer, Auxiliary SCL and Primary SCL read the same but Auxiliary SDA and Primary SDA has a difference.When I see Auxiliary SDA, I can find that voltage toggles between 3.3V to 0.6V(MPU9150 is able to pull down volatge to 0.6V) but when I see primary SDA, voltage toggles between 3.3V to 1.68V. Auxiliary SDA and SCL pins are left open(not connected anywhere in my circuit) whereas communication is done vis Primary SDA and SCL lines.

I would also like to add something about MPU9150 sensor.It is actually a combination of 2 sensors MPU6050(acc and gyro) and AK8975(magnetometer). SDA and SCL of MPU6050 are connected to primary SDA and SCL while SDA and SCL of AK8975 are connected to auxiliary SDA and SCL of MPU9150. AK8975 can be accesses by 2 methods. First is bypass enable method,where Primary and Auxiliary SDA gets shorted. Second is Master mode of MPU9150 where MPU9150 is master to sensors connected on Auxiliary SCL and SDA i.e. even to AK8975. I am using method 1 right now and what I have mentioned in above paragraphs are problems faced by me in method 1. I have still not implemented method 2. enter image description here

\$\endgroup\$
  • \$\begingroup\$ It seems to me that a better solution would be to find out why your magnetometer isn't pulling the I2C lines low properly. \$\endgroup\$ – Nick Johnson Jun 24 '15 at 14:33
  • 5
    \$\begingroup\$ Sounds like an issue with improper pull-up resistors selection. \$\endgroup\$ – Eugene Sh. Jun 24 '15 at 14:49
  • 2
    \$\begingroup\$ Seconded. Your pullups are too strong. \$\endgroup\$ – Ignacio Vazquez-Abrams Jun 24 '15 at 14:56
  • 1
    \$\begingroup\$ There may be a problem with the ground connection to the magnetometer. \$\endgroup\$ – Peter Bennett Jun 24 '15 at 15:05
  • \$\begingroup\$ Snap of MPU9150 schematics section will help \$\endgroup\$ – Umar Jun 24 '15 at 15:26
1
\$\begingroup\$

I'd need a schematic to see for sure, but my first suspicion is that you have series resistors on the MPU9150 I2C lines. I've seen this in a mistaken effort to address posisble EMI issues. I2C shouldn't have series resistors; it's all very slow edge rates and with strong enough pullups it's possible that the series resistor is high enough resistance and dropping enough voltage to cause this issue.

If you can paste a schematic that includes the AT32, MPU9150 and EVERYTHING connected to the I2C pins we can definitely help you with this. There is no need to try to do I2C with the analog comparator functions on the microcontroller, although I will admit this is a novel solution to your problem.

\$\endgroup\$
  • \$\begingroup\$ I have added the schematic \$\endgroup\$ – Kuldeep Soni Jun 25 '15 at 5:55
  • \$\begingroup\$ Zooming the page to view image will help \$\endgroup\$ – Kuldeep Soni Jun 25 '15 at 5:56
  • \$\begingroup\$ @KuldeepSoni Why on earth do you have four MPU9150s with a common clock and individual data lines? This is not a normal I2C connection. \$\endgroup\$ – akohlsmith Jun 25 '15 at 17:24
  • \$\begingroup\$ I am doing sensor fusion from the data of those 4 IMU's. Every sensor has some inaccuracy. To combat that and make the data much more accurate, I am doing this. I have seen significant improvement by collecting and fusing data from 4 sensors. Since I want data from all the sensors at the same time, I have a common clock. So I am doing parallel communication. @akohlsmith \$\endgroup\$ – Kuldeep Soni Jun 25 '15 at 18:12
  • 1
    \$\begingroup\$ If you're going to do that use for independent I2C buses; don't try to clock them all synchronously and read back 4 data lines. Sure you might get it to work eventually but do it the easy way. Follow the credo: Get it working, then get it good. Early optimization is the way of wailing and gnashing of teeth. :-) \$\endgroup\$ – akohlsmith Jun 25 '15 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.