Shop OBEX P1 Docs P2 Docs Learn Events
I2C difficulty — Parallax Forums

I2C difficulty

Tony CunninghamTony Cunningham Posts: 43
edited 2011-05-30 05:17 in Propeller 1
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.
«13

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-20 03:09
    This driver works. The other comment is this breakout board uses the secondary I2C address for the itg3200, it looks like you use the wrong i2c address.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-20 03:15
    Good grief, Tim! Did you just write that up really fast just now, or what?
    Wow! Your awesome!

    Ok, so from the looks of things, I display xt, yt, zt for results?
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-20 03:19
    Also, there is no writelocation in the "basic_i2c_driver"

    " i2cObject.WriteLocation(i2cSCL, _deviceAddress, ITG3200_PWR_MGM, %1000_0000) 'reset to defaults"
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-20 03:25
    Here is one of the test programs I use. It has other sensors as well but it should be straight forward to remove the other sensors.
    The basic_i2c_driver I use isn't a modified version of the obex version.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-20 23:45
    Tom,

    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.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 00:01
    Yes, my code assumes pull-ups on both scl and sda. I have 4.7K pull up to 3.3V but 10K should work.

    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/
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 00:06
    I have and i'm not getting anything. It's telling me "ITG-3200 init: failed".
    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. : )
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 00:13
    It would be worth adding the i2cscan object and calls back in, thats the code that scans all the addresses.
    The other question is which pins do you have the gyro connected to, my code assumes pins 6/7 if starting from 0.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 00:15
    yea I saw that, so I put mine on 6/7 pins also. i'll put the scan back in right now.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 00:33
    one thought, what have oyu done with the clkin pin?
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:16
    Seems to be hanging up on the scan. This time I put everything back and commented out some of the things and just changed the display apart.
    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:18
    nothing with the clk pin. Am I suppose to use it?
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 02:21
    Vcc and vlogic is 3.3V
    Gnd and clk to Gnd
    Int unconnected

    i2cscan assumes you can send to the debug port - pins 30/31
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:21
    oh, I shorted the clk pin, if that's what your asking.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:31
    How can I get the scan to show up on my lcd screen?
    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.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 02:37
    If you look in i2cscan.spin it uses uart to output, you would need to change the output to your display.
    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:47
    I changed the i2cscan.spin to display on my 7" color lcd. I ran it by itself and got nothing on the screen. It should have put something on the screen.
    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 02:59
    I downloaded the pst.exe. Cool, i like that. now I can read results from your original program, but the gyro is not giving any new numbers.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 03:05
    my uart object is designed to be usable across multiple objects for debugging, i havent looked at the lcd object to see if the same is possible.

    Are you getting teh i2cscan output from the my original program now? If so can you post it.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 03:12
    yea, here is what i'm getting,
    1440 x 900 - 117K
    scan.jpg 117.1K
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 03:19
    ok, first check I would do is the 2/3rd line in quadtest1.spin

    '  i2cSCL := config.GetPin(CONFIG#I2C_SCL1)             'uncomment this if using pin 28 for SCL
      i2cSCL := config.GetPin(CONFIG#I2C_SCL2)              'for any other pin use this line and fix pininfo table
    
    

    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 03:34
    ok,
    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 03:35
    do you think it might be the gyro address?
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 04:06
    Thats not the problem, if it was the wrong address it would still show up on the i2c scan and its not.
    it is probably something simple, can you take a photo of the wiring?
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 16:08
    here is some pics, hope this helps.

    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.
    3472 x 2604 - 331K
    2316 x 1736 - 218K
    3472 x 2604 - 1M
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 16:27
    Looks like the wiring is correct except that I dont see any pullup resistors.
    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.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 16:38
    What do you mean in case the 10k pull-ups are not enough. You mean I need to add a bigger pull-ups? the docs said that 10k was max, i think.
    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:
    1440 x 900 - 228K
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 16:52
    Did you change the commented line?
    '  i2cSCL := config.GetPin(CONFIG#I2C_SCL1)             'uncomment this if using pin 28 for SCL
      i2cSCL := config.GetPin(CONFIG#I2C_SCL2)              'for any other pin use this line and fix pininfo table
    
    

    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
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 16:57
    yeah, i forgot to do that, here is the result of the test:
    1440 x 900 - 200K
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-21 17:26
    The address found is %1010_0000 which is the eeprom address so thats correct but its not found the gyro.

    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.
Sign In or Register to comment.