I2C difficulty
Tony Cunningham
Posts: 43
Well, I've tried everything I can do, with what little understanding I have of I2C communication. I have a tri-axis gyro from Sparkfun :
http://www.sparkfun.com/commerce/product_info.php?products_id=9801
Here is the docs for it :
http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf
In the program, I think I'm picking the addresses on the gyro, but all I'm getting on the display is:
X Axis -1 0
Y Axis -1 0
Z Axis -1 0
So, I'm sure once you see the what I got, you can point me in the right direction.
http://www.sparkfun.com/commerce/product_info.php?products_id=9801
Here is the docs for it :
http://www.sparkfun.com/datasheets/Sensors/Gyro/PS-ITG-3200-00-01.4.pdf
In the program, I think I'm picking the addresses on the gyro, but all I'm getting on the display is:
X Axis -1 0
Y Axis -1 0
Z Axis -1 0
So, I'm sure once you see the what I got, you can point me in the right direction.
Comments
Wow! Your awesome!
Ok, so from the looks of things, I display xt, yt, zt for results?
" i2cObject.WriteLocation(i2cSCL, _deviceAddress, ITG3200_PWR_MGM, %1000_0000) 'reset to defaults"
The basic_i2c_driver I use isn't a modified version of the obex version.
Did you add pull-up resistors on your gyro? I put a 10k on the SCL and SDA. I'm still not getting anything yet.
The quadtest code runs a i2c scan of all addresses and prints out the device addresses that it gets a response from. Try that and check you are getting an ack from the device/
I kind of hack up your code to just narrow down the gyro, so if you could see if I messed up anything.
I really appreciate your help. : )
The other question is which pins do you have the gyro connected to, my code assumes pins 6/7 if starting from 0.
I don't think I commented out the wrong stuff. I get the "Quadtest1 ESC/ITG-3200/ADXL345/BMP085 test" on the display but that's it, nothing else happens.
Gnd and clk to Gnd
Int unconnected
i2cscan assumes you can send to the debug port - pins 30/31
what are you using for debugging?
Sorry if i'm be air headed, but you have a big program and i'm not that good at this. I can hunt and peck my way around, but this is more than I handle.
I really appreciate your patience with me, though!
I really want to get this to work.
But if you are just debugging, are you using using a propplug to program? then for a quick debug, leave the cable plugged in and run pst.exe (available from parallax.com) and set the speed to 115200 this will enable the debug to the PC.
I ran the quadtest after this modification and the first line comes up, but then when the scan initiates, my screen goes berserk.
Do I put my uart.start(12) (which is the start for my tv_text) in both the quadtest AND the scan. I'll have to try something there.
Are you getting teh i2cscan output from the my original program now? If so can you post it.
uncomment the 1st line and comment the 2nd line.
Run it, it should now find the eeprom on address A0 that checks the code is working.
If that works, switch the lines back and look at the wiring.
1. the pin numbering·start at 0, is the hardware numbering starting at 0 or 1?
2. Pull ups going to 3.3
3. scl/sda the correct way round.
I did the first thing and that worked, said it found one device.
I switched the lines and still get nothing on the gyro, and says it's not found.
Checked the wiring, I have the breakout board for the gyro. The clock has been grounded, scl is pin6 and sda is pin7. Both of these pins have 10k ohm pull-ups to vcc 3.3. Vlogic is also tied to vcc 3.3v.
You know, I hate this part where i'm looking to find something and i'm missing the obvious somewhere. Everything seems in order, but there is obviously something wrong. And it's probably right under my nose!
At least we got the results on screen.
it is probably something simple, can you take a photo of the wiring?
I'm still experimenting with different pins and stuff.
oh, by the way. when I ran the program without the gyro connected at all, the scan seem to work, but when i hooked the gyro back up the scan didn't work. something is not making since.
For a check, plug scl/sda into 28/29 and run the test I asked a few posted ago, with the 2 line for scl1 and scl2 changed which one is commented. If its the pull-up problem you should see 2 devices show up rather than 1.
I just noticed you added the pull-ups to the board, along with the jumper for clkin to gnd. So it should be fine.
I would try plugging into 28/29 anyway just in case the 10K pull-ups are not enough.
If that doesn't work, I would get a meter and check the continuity of the connections.
The scan working without the board plugged in is expected. It is looking for a 0 response from the board, without the board plugged in, without pullups you may see a 0 at the right time but you are likely to see it for a lot of addresses rather than just a few.
I did check the continuity of the connections, everything seems fine.
I connected it to the 28/29 pin, making sure scl and sda were on the right pins and ran the test, heres what I got:
So SCL1 is uncommented.
The scan is showing all addresses so there is no pull-up on the pins being scanned which suggests you are not scanning 28/29
Not enough means too big - "there is not enough current pulling the pins to 3.3V". If you plug the board into 28/29 then the resistors on the main board and the resistors on the gyro will be in parallel and you have the equalivalent of a 5k pullup
The only think I can think of at the moment is that the inversense evaluation board has 2K pullups, the system I have happens to have 2K pulls as well. The itg-3200 spec isn't clear on the current requirements for the pullups at 3.3V so you could try changnig the 10k pullups on the gyro board to 2K pullups.
The other thing is I managed to kill one of these gyros, it was working and stopped. I never did work out what I had done. It could be it is very sensitive to static, I wasn't being particular careful about static handling.