Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   anyone else use the I2C bus? (http://www.chiefdelphi.com/forums/showthread.php?t=77067)

skimoose 27-04-2009 18:38

Re: anyone else use the I2C bus?
 
Quote:

Originally Posted by virtuald (Post 854954)
We tried to use an I2C LCD from New Haven to work also, but unfortunately we weren't ever able to get it to work and gave up due to time constraints.

The New Haven display we used needed to have a jumper soldered onto the PCB traces to enable I2C communication. Check the New Haven literature to see if the model you used needed this jumper. The pads were not drilled so you needed to surface solder a very short piece of bare copper wire across the two adjacent pads.

Steve_Alaniz 27-04-2009 21:12

Re: anyone else use the I2C bus?
 
Quote:

Originally Posted by Joe Hershberger (Post 855381)
I'm surprised you're having trouble... I tested talking to 3 different sensors on the same bus at the same time, using the LabVIEW examples. Are you sure you could address your second sensor at all?

Perhaps you had a wiring problem. Also, the Digital Sidecar has all the needed pull-up resistors. The devices should not have pull resistors in them.



You just didn't consult the correct NI guy. The statement that we didn't expect I2C to be used this year is completely false.



Perhaps you are misinterpreting the interface. The current API to I2C on the FPGA allows you write to one register or read from between 1 and 4 sequential registers. In either case, the device will be addressed, then the register will be addressed, and finally the data will be moved. Only when you're using a device that does not have a register-level I2C API does this scheme not work nicely. You should not use a register write when you are trying to do a register read.

The intention is that it will be more flexible in the future so that other custom API types can be easily supported as well.


Wow… ok I must be overlooking something. Too many people are succeeding so it has to be something in our program. I’ve actually used the I2C bus before. 5 years ago I had three Devantech SRF08’s running from a basic stamp chip so I was aware of the addressing scheme and how to change addresses.
We had both a SRF08 Ultrasonic detector and a CMP-S03 connected to the I2C Bus. We could run the demo for SRF08 and get good readings. Then we wanted to also read the CMP-S03 compass. The compass was our priority so we programmed to read it first, then the SRF08. We got data from the compass but nothing from the SRF08. Pretty much the SRF08 should have been a cut and paste of the demo as we left it at default address. We couldn’t see what we were doing wrong and after an hour of rechecking and trying various things, we had to move on and decided to ask the NI guys at the championship.

One thing about the NI implementation, to read the Devantech CMP-S03 compass you do a write for the register number you want to read but the write doesn’t need a data byte sent. It will output one or two bytes on the next read according to which register you addressed.
I opened up the VI I2C.lvlib:write.vi block diagram and looked at the I2C config, which requires you to send at least one byte of data but it has a password lock so there is no way for me to modify it to write the register number to the device without actually sending a byte of data. I would have to rewrite the vi but there just wasn’t time for that.

Hope I didn’t slander the NI guys. They were really busy trying to be in two places at once.

virtuald 27-04-2009 22:03

Re: anyone else use the I2C bus?
 
Quote:

Originally Posted by skimoose (Post 855463)
The New Haven display we used needed to have a jumper soldered onto the PCB traces to enable I2C communication. Check the New Haven literature to see if the model you used needed this jumper. The pads were not drilled so you needed to surface solder a very short piece of bare copper wire across the two adjacent pads.

Yeah, ours had that requirement also. Its possible we soldered the wrong set on accident, however.

timmmoore 27-04-2009 22:19

Re: anyone else use the I2C bus?
 
Steve_Alaniz for the CMPS03 you should be able to do a I2C read of 2 bytes from register 2. Haven't tried it but I have one so I will connect it and see.

Steve_Alaniz 28-04-2009 01:00

Re: anyone else use the I2C bus?
 
Quote:

Originally Posted by timmmoore (Post 855527)
Steve_Alaniz for the CMPS03 you should be able to do a I2C read of 2 bytes from register 2. Haven't tried it but I have one so I will connect it and see.

Tim
Oh we DID do a two byte read initially, but that was too much resolution for our application so we dropped back to a one byte read.

Steve

timmmoore 03-05-2009 14:33

Re: anyone else use the I2C bus?
 
Steve, I have tried 1 and 2 byte reads on CMPS03 without problem with SRF08 running at the same time.
I also found a way to cause the I2C bus to hang with both devices being accessed at the same time.
Difference
hang: 2 parallel while loops, 1 accessing CMPS03, 1 accessing SRF08
no hang: 1 while loop, accessing SRF08 then CMPS using a sequence

If you remove 1 or the other device physically from the bus but leave the code running both 'work'. But with both connected it may hang - it normally works for a while then hangs the while loop - I would expect this unless the I2C FPGA code has locking behavor for multiple accesses, you would end up with multiple conflicting bus accesses.

So you probably want to put all I2C accesses in 1 thread, store the results in local/global variables and access the variables when needed.

Steve_Alaniz 05-05-2009 01:25

Re: anyone else use the I2C bus?
 
Quote:

Originally Posted by timmmoore (Post 856889)
Steve, I have tried 1 and 2 byte reads on CMPS03 without problem with SRF08 running at the same time.
I also found a way to cause the I2C bus to hang with both devices being accessed at the same time.
Difference
hang: 2 parallel while loops, 1 accessing CMPS03, 1 accessing SRF08
no hang: 1 while loop, accessing SRF08 then CMPS using a sequence

If you remove 1 or the other device physically from the bus but leave the code running both 'work'. But with both connected it may hang - it normally works for a while then hangs the while loop - I would expect this unless the I2C FPGA code has locking behavor for multiple accesses, you would end up with multiple conflicting bus accesses.

So you probably want to put all I2C accesses in 1 thread, store the results in local/global variables and access the variables when needed.


Thank you Tim... good information. We'll give it a try.


Steve


All times are GMT -5. The time now is 15:17.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi