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

I2C difficulty

2

Comments

  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 17:35
    I'll change out the pull-ups and see if it helps.

    Great, hope I didn't static mine to death.

    Dude, you have been very patient about this! I really do thank you for all your help.

    And for some dumb reason I can't get this stupid thing work, I'll probably order another one. If that don't work then I'm going to be very ticked!
    My accelerometer works great and had it for years with no problems. I just wanted to add a gyro for my humanoid, so he can keep better balance. Right now the only thing balancing is my patience!
    Cross your fingers.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 18:10
    well, I put 2.2k ohm pull-ups, and still not working!
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-21 18:51
    I ordered the evaluation board this time, hopefully this one will work.
    When it gets here, i need you to show me how you hooked up yours and what jumpers you have set.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 00:54
    Well, Tim, i got the eval board like you got, connected scl and sda and the 3vo and ground and ran the quadtest and still not getting it.
    Now i'm really frustrated. Can you tell me how you have yours hooked up, or a picture of it?
    I moved the jumpers to 2-3 on both since I'm using prop 3.3v, did you use that or the LDO?
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 01:18
    clkin needs to go to gnd - pin 11
    vlogic needs to go to 3.3V - pin 8
    resv-g needs to go to gnd - pin 21 - I know this says dont connect but the chip spec·says connect to gnd
    gnd to pins 15/17
    3.3 to pin 23 VCC·- if you use jumpers 2/3 then you connect to pin 23 not 19

    The first 3 are the ones you didn't mention and check 3.3V needs to be to VCC not pin 19 if you changed the jumpers to 2/3 for JP2 and 7
  • JasonDorieJasonDorie Posts: 1,930
    edited 2010-06-26 02:25
    I have mine working as well, with 4.7K pull ups on it. I initially got the address wrong, and I also messed up soldering the pull-up resistors (I bridged the two lines together), so I'd double check that your connections are clean. It's really easy to get a blob of solder under those things, or bridge them.

    I was also going to mention grounding the clock line, and tying VDD and VIO, but it looks like you've done that too.

    Jason
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 03:08
    Jason,

    Which gyro are you using, the eval board from CDI or the breakout board from Sparkfun?
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 03:10
    Tim,

    do yu have the eval board from CDI? Are pin numbers aren't jivin'.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 03:16
    I had the evaluation from inversense and the breakout from sparkfun. I had the evaluation board working but fried it somehow, I am currently running the sparkfun breakout board.

    with the inversense board the connector starts at pin no 5 not 1, there are 4 spare pins either end of the connector.

    Post Edited (Timmoore) : 6/26/2010 3:21:16 AM GMT
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 03:43
    ok,
    I got the quadtest to find the address. I changed the pins to pin0 and pin1 in the DAT routine. but it still want read the gyro data.

    Here's what I got:
    1440 x 900 - 200K
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 03:49
    Check the address set for teh gyro in the i2cinfo table at the bottom of the file.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 03:52
    it's 1101_0010
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 04:00
    Can you add this line
      uarts.hex(0, gyro.GetID(i2cSCL, gyroAddr), 8)
    
    

    after

      uarts.str(0, string("ITG-3200 init: "))
      if gyro.Init(i2cSCL, gyroAddr)                        'init gyro
        uarts.str(0, string("ok", 13))
      else
        uarts.str(0, string("failed", 13))
    

    Run it and post the output
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:03
    here's the result
    1440 x 900 - 202K
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:06
    i put bin in place of hex and got 11111111.
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 04:11
    Thats weird its finding it but reading ff.
    Lets check all the parameters, can you try replacing that line with
      uarts.dec(0, i2cSCL)
      uarts.tx(0, " ")
      uarts.hex(0, gyroAddr, 8)
      uarts.tx(0, " ")
      uarts.hex(0, gyro.GetID(i2cSCL, gyroAddr), 8)
      uarts.tx(0, 13)
    
    
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:14
    here it is:
    1440 x 900 - 205K
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 04:19
    Can you attach the quadtest1.spin file, the i2cscl and gyro address are not correct.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:22
  • TimmooreTimmoore Posts: 1,031
    edited 2010-06-26 04:32
    The problem is the gyro i2c address, the drivers work with the i2c shifted left 1,
    The i2cinfo table needs to have
                  byte CONFIG#ITG3200
                  byte %1101_0010                   'gyro I2C address
    
    

    The lowest bit is used for read/write in i2c. To save shifting all the time, the addresses are shifted by default and the lowest but is set to 1 when needed.
    ·
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:36
    here is what I got,
    1440 x 900 - 99K
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-26 04:37
    I was playing around with that earlier, so I changed it back.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2010-06-26 09:12
    Tony, I've got the SparkFun breakout, same as you.

    Not sure this code is going to do any better than what Tim has given you, but it works for me.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-27 02:11
    Thanks Jason.

    I'm getting a reading off of the x but not the y or z. And for some reason it's not looping through, so i'm getting just the one read. I'm still playing with it though.
  • Tony CunninghamTony Cunningham Posts: 43
    edited 2010-06-27 03:00
    Jason,

    I've been playing around with your code and have the X reading just fine but can't seem to get the Y and Z still.
    Take a look and see what you think:
  • naigonnaigon Posts: 7
    edited 2011-05-21 15:47
    I am experiencing the same issues as Tony; my ITG 3200 breakout from SparkFun won't work with either of the two code examples given in this thread.

    Using Tim's code, a scan of the object returns the correct %1101_0010 ACK but initialization fails. When I run this code as Tim suggested:
    [SIZE=2]uarts.dec(0, i2cSCL)   uarts.tx(0, " ")   uarts.hex(0, gyroAddr, 8)   uarts.tx(0, " ")   uarts.hex(0, gyro.GetID(i2cSCL, gyroAddr), 8)   uarts.tx(0, 13)[/SIZE]
    

    I get the following:
    Quadtest1 ESC/ITG-3200/ADXL345/BMP085 test
    Scanning I2C Bus....
    Scan Addr :  %11010010 01101001,  ACK
    i2cScan found 1 devices!
    ITG-3200 init: failed
    22 000000D2 000000D3
    

    It looks like the Address being retrieved from the Gyro is actually D3 when the address being pulled is D2; D2 is the correct address %1101_0010 as far as I can tell, so why is the Gyro itself return D3?

    For Jason's code I see the same behavior where the x value is updated but the y/z values are not. Is there something wrong with the read logic of this code?

    Please let me know, thanks!
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-05-21 18:14
    I am not sure I can help. Here is a suggestion...

    I note you are seeing address D3 but expect D2. IIRC on the ITG-3200 there is an address bit that can be selected by tying a pin High or Low. Perhaps Sparkfun have tied the opposite to Tim's code. Perhaps you could try the D3 address in the initialisation call.

    Perhaps you could describe your prop hardware?
  • naigonnaigon Posts: 7
    edited 2011-05-21 19:08
    Thanks for the response. I got Jason's code to work though; instead of doing one contiguous read at address 29 I added code to restart reading at 31 and 33 for y and z. It works great!
    StartRead( constant(29) )
        'ignore temp.
        'ContinueRead
        'ContinueRead
        temp := ContinueRead << 8
        temp |= (FinishRead & $FF)
        x := ~~temp - x0
        'pst.clear                                     
        pst.Str(String(pst#NL, "X=   "))                                 
        pst.dec(X)
        StartRead(31)   
        temp := ContinueRead << 8
        temp |= (FinishRead & $FF)
        y := ~~temp - y0
          
        pst.Str(String(pst#NL, "Y=   "))                                 
        pst.dec(Y)
        StartRead(33)
        temp := ContinueRead << 8
        temp |= (FinishRead & $FF)
        z := ~~temp - z0
          
        pst.Str(String(pst#NL, "Z=   "))                                 
        pst.dec(Z)
    
    

    You need to do this for the average as well, but I'll let you take care of that.

    Hope this helps anyone that is having trouble like I was!
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-05-21 23:08
    Glad you found the problem, and posted the solution too :)
  • LtechLtech Posts: 380
    edited 2011-05-30 05:17
    My dof 09 gyro adress Sparkfun sen-10321

    "i2cinfo
    byte CONFIG#ITG3200
    byte %1101_0000 'gyro I2C address"



    and not :

    "i2cinfo
    byte CONFIG#ITG3200
    byte %1101_0001 'gyro I2C address"
Sign In or Register to comment.