JensKrueger
Posts: 16
Joined: Sat Feb 09, 2013 11:53 pm

Re: Enable both I2C Busses

Fri Mar 01, 2013 12:25 pm

I'm using the same sensor on my RPi without any issues (on neither bus), so no negative experiences here.

Cheers
Jens

Ragu3l
Posts: 17
Joined: Thu Feb 07, 2013 9:29 pm

Re: Enable both I2C Busses

Fri Mar 01, 2013 2:53 pm

I've seen nothing like it.
Did you remember to add pull up resistors?

Raguel

StaticDet5
Posts: 21
Joined: Sun Nov 25, 2012 5:11 am

Re: Enable both I2C Busses

Fri Mar 01, 2013 3:14 pm

Yep.

Just found it. Bizarre wiring issue, I think. I've been having problems with a solderless breadboard. I switched it out, and everything looks good.

Ragu3l
Posts: 17
Joined: Thu Feb 07, 2013 9:29 pm

Re: Enable both I2C Busses

Fri Mar 01, 2013 3:55 pm

Happy to hear it

JensKrueger
Posts: 16
Joined: Sat Feb 09, 2013 11:53 pm

Re: Enable both I2C Busses

Fri Mar 01, 2013 9:47 pm

Since you mention the pull up resistors. Do I really have to add them? It always seemed to me that the RPi already has build-in pull ups?

Not that this means much, but so far my setup worked just the same with and without pull up resistors attached (I used 10K Ohm resistors).

Cheers
Jens

Ragu3l
Posts: 17
Joined: Thu Feb 07, 2013 9:29 pm

Re: Enable both I2C Busses

Sat Mar 02, 2013 12:05 am

RPi has pull ups for i2c1 on P1, but not on i2c0 if this is routed to P5.
If i2c0 is routed as default to S5 the RPi has the pull ups.
I had very bad results with i2c0 on P5 until I added pull ups

It might depend on what you are connecting to? I've seen iCs with pull ups build in on dedicated i2c pins

Raguel

JensKrueger
Posts: 16
Joined: Sat Feb 09, 2013 11:53 pm

Re: Enable both I2C Busses

Sat Mar 02, 2013 8:53 am

Seems I was just luck with my peripherals on i2c0 on P5 so far :-). Thanks for the info I guess that will save me plenty of debugging time in the future when I connect other boards that suddenly would not work in i2c0.

Cheers
Jens

wallasey
Posts: 25
Joined: Fri Nov 16, 2012 5:10 pm

Re: Enable both I2C Busses

Mon Apr 08, 2013 11:35 am

bgreat wrote:Here is my attempt to enable both I2C interfaces. It appears to work on my Raspberry Pi, but I do not have any I2C peripherals to test.
Hi,

Just wanted to thank you for posting this. Got me up and running with the second i2c bus on P5. All that's required is, as you coded, to switch off the ALT0 function on Pins 0 & 1.

You do need pull up resistors on the P5 pins (28 & 29) but you can use the RPi's internal ones and the BCM2835 data sheet provides a complete reference of how to do it under the GPPUDCLK register description.

There's a working example in the bcm2835 library http://www.airspayce.com/mikem/bcm2835/index.html

Sorry - I don't 'do' Python or I would have produced and tested a wrapper. However, If someone who does wanted to then should be simple to update Bill's code to include adding pull up resistors to pins 28 and 29.

My Perl modules ( http://raspberry.znix.com ) include a GUI that already does the PUD resistor part. Thank's to Bill's post here I'll be releasing a version later today that also switches off the ALT0 function for pins 0 & 1 so that the ALT0 function applied to pins 28 & 29 will work.

One note that may prove useful if you are using the kernel device driver.

The current Raspbian Wheezy i2c kernel device driver always sets ALT0 function on pins 0 & 1 when loaded ( it actually does 0 through 3 so covering Rev 1 & 2 boards). However, you can reset this and setup pins 28 & 29 as your i2c-0 pins then /dev/i2c-0 works OK. Probably of limited use as the i2c kernel driver allows only 1 'speed' setting across both busses using the 'baudrate' param and it sets the clock using this before every transfer so it is pointless setting the the clock directly on the BCS peripheral as far as the kernel driver is concerned. I'm assuming that most practical uses of a second i2c bus is to run one at a lower speed.

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 8:36 am

Hi all,

I'm looking to run 2 i2c sensors that have the same fixed address.

Can I ask a possibly dumb question here please...

Is this possible on a rev.1 board?

Apologies if it's obvious and I missed it from reading the thread - I'm in a very steep learning curve atm:)

Best wishes,

Julian

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Tue Apr 23, 2013 10:52 am

Which sensors as a lot have an address pin for selection of more than one device.

I cannot remember if both I2C are available on connectors for Rev 1

If stuck other methods of bus switching are possible depending on how fast/often you need to access the sensors
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 11:39 am

Hi techpaul,

Many thanks for getting in touch...

They're both Omron D6T44L's (thermal imaging).
Eventually got a response from Omron tech support saying the addresses cannot be changed.

Been doing some digging on an IC switch but am very unsure of how we would then parse the data from both sensors. Without having done any experimentation my feeling is that it would be much simpler if we had another set of busses running - but if it isn't possible then that's a non-starter.

Cheers,

Julian

StaticDet5
Posts: 21
Joined: Sun Nov 25, 2012 5:11 am

Re: Enable both I2C Busses

Tue Apr 23, 2013 12:46 pm

Both buses are there, I'm just not sure where the "Pin Outs" are.

Another option is to use one of the digital lines for each sensor to enable a "shutdown" of the sensor. Mr. Townsend on the Adafruit website does a great job of explaining how to do this:
http://learn.adafruit.com/using-the-bmp ... ry-pi/faqs

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 1:19 pm

Hey StaticDet5,
StaticDet5 wrote:Both buses are there, I'm just not sure where the "Pin Outs" are.
That's good to know
StaticDet5 wrote:Another option is to use one of the digital lines for each sensor to enable a "shutdown" of the sensor. Mr. Townsend on the Adafruit website does a great job of explaining how to do this:
http://learn.adafruit.com/using-the-bmp ... ry-pi/faqs
Hmm - no XCLR on these sensors.

Cheers,

Julian

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Tue Apr 23, 2013 2:15 pm

JulianBrooks wrote:They're both Omron D6T44L's (thermal imaging).
Eventually got a response from Omron tech support saying the addresses cannot be changed.

Been doing some digging on an IC switch but am very unsure of how we would then parse the data from both sensors. Without having done any experimentation my feeling is that it would be much simpler if we had another set of busses running - but if it isn't possible then that's a non-starter.
I2C bus switch means you tell the bus switch which branch to enable, then talk to device on that branch, to talk to the other one tell switch the other branch to use then talk to sensor.

An example is PCA9548APW 8 ch i2c bus switch, which is controlled over I2C, and can have 8 of them on the same bus as well.

See http://uk.farnell.com/jsp/displayProduc ... placement} has link to datasheet
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 4:04 pm

I should have been a little clearer here. My concerns are more going the other way - it's parsing the data that the sensors are sending that I'm concerned about. The 2 sensors will be facing in different directions and it's the separating of the 2 streams coming from (i.e.) the IC switch that I'm concerned about. WE have a C program that's talking to the sensor and then streaming the temp data to Pure Data via UDP (www.puredata.info for more info:) .

So are we saying 2 i2c busses on a rev.1 board isn't doable?

Cheers,

Julian

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Tue Apr 23, 2013 4:27 pm

JulianBrooks wrote:I should have been a little clearer here. My concerns are more going the other way - it's parsing the data that the sensors are sending that I'm concerned about. The 2 sensors will be facing in different directions and it's the separating of the 2 streams coming from (i.e.) the IC switch that I'm concerned about. WE have a C program that's talking to the sensor and then streaming the temp data to Pure Data via UDP (http://www.puredata.info for more info:) .
So you are getting data via i2c data from ONE sensor and I bet it is not maxed out the i2c and that it is only grabbing some data and streaming that with gaps in time. Unless your application already maxes out the Pi in which case it will not cope with a second sensor.
So are we saying 2 i2c busses on a rev.1 board isn't doable?
Not as far as I know, but the i2c switch I showed would make it possible to connect upto 8 of them.

I suggest you look at how much data is transferred, for how long and when. I bet you find the system is not very busy and there is lots of time to work with two senseors even the small amount of extra bytes to to switch which one is being talked to.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Tue Apr 23, 2013 4:41 pm

I suggest you look at this http://www.mouser.com/pdfdocs/D6T01_The ... epaper.pdf Also mentions using I2C bus switches

Another URL http://media.digikey.com/pdf/Data%20She ... l_Note.pdf

You are once every interval grabbing data from ONE sensor, so what you do for two sensors is

1/ Set switch to first sensor
2/ Get data packet from sensor 1
3/ Set switch to second sensor
4/ Get data packet from sensor 2
5/ WAIT for next interval to get data.

A packet is 35 data bytes for D6T44L so I cannot understand your problem.

If you were grabbing from sensor 512 bytes as quickly as possible and repeatedly I might start to think you have a problem. I doubt you are streaming 1000 packets a second to your puredata solution.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 6:45 pm

Cheers Paul - learning all the time:) - also seem to be ordering endlessly from Farnell atm too, their £20 minimum spend has caught me out a few times. Might wait it out for a few more days and will no doubt need more stuff by then!

Cheers,

Julian

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Tue Apr 23, 2013 7:11 pm

techpaul wrote:I suggest you look at this http://www.mouser.com/pdfdocs/D6T01_The ... epaper.pdf Also mentions using I2C bus switches
Yes - this paper seems to have appeared in the last couple of days - the previous N.A. distributor was digikey up until last week.
Yip yip - this is the one we got most info out of up until the Mouser one which we spotted this afternoon. This is the paper we got the C code from. Fortunately someone on the pd-list (Martin Peach) who's an excellent C coder and is into sensors has bought himself a couple of these recently so we've been thrashing it out between us over the last few weeks or so. He's done most of the C coding with me tweaking and testing mainly. Up until last week I'd never done any C at all. Like I said - steep curve but good: I like it when I'm in over my head!

The pdf from Farnell is not very informative/helpful at all btw.
techpaul wrote:You are once every interval grabbing data from ONE sensor, so what you do for two sensors is

1/ Set switch to first sensor
2/ Get data packet from sensor 1
3/ Set switch to second sensor
4/ Get data packet from sensor 2
5/ WAIT for next interval to get data.

A packet is 35 data bytes for D6T44L so I cannot understand your problem.
Ok - what you say above I can follow - thank you.
My problem is that I'm a composer who likes to dabble in electronics most often for particular projects. I willingly throw myself into these things without knowing what I'm doing and am hugely grateful that there are people willing to lend their expertise and knowledge to help people like me. Conversely - if you become interested in coding in Pd then I'm around on the mailing list and would be delighted to do the same:)
techpaul wrote:If you were grabbing from sensor 512 bytes as quickly as possible and repeatedly I might start to think you have a problem. I doubt you are streaming 1000 packets a second to your puredata solution.
Absolutely - hit the nail on the head. This is something I'm wondering about but as the sensor is finally working and I have a shedload of other things that currently aren't working it's not top of my priorities. But yeah - how come the clock's running really fast (100kbs) yet I'm receiving data maybe every 100ms or so?

Anyway, onwards eh,

Julian

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Tue Apr 23, 2013 7:22 pm

JulianBrooks wrote:
techpaul wrote:If you were grabbing from sensor 512 bytes as quickly as possible and repeatedly I might start to think you have a problem. I doubt you are streaming 1000 packets a second to your puredata solution.
Absolutely - hit the nail on the head. This is something I'm wondering about but as the sensor is finally working and I have a shedload of other things that currently aren't working it's not top of my priorities. But yeah - how come the clock's running really fast (100kbs) yet I'm receiving data maybe every 100ms or so?
Without knowing where you mean receiving that is difficult to say, could be anything from how you are doing the i2c trnasfers, scheduling of your tasks, poor UDP, poor network and loist packets to Pi or server loading.

However I dont know why anything faster than once a second or at best 0.5 sec is of any practical use. You are not tracking bullets or fast animals but mainly slow moving objects. Depends on field of view and distance of objects as to how fast an update you actually need.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Thu Apr 25, 2013 9:27 am

Hi again,

Paul - I've been looking at your add-on boards and they look really good I have to say. Wish that I'd spotted these before we started as I think it would have saved us much faffing about.
We went for one of the adafruit proto boards which is causing us occasional problems and feels a bit flimsy tbh. Unfortunately everything's soldered together now and we've made a frame for the unit so would rather not replace it at this late stage.

What I would like to ask though is do you do something like these which, please correct me if I'm wrong, would sort out the IC switching?

http://uk.farnell.com/roth-elektronik/r ... dp/1426182
and one of these:
http://uk.farnell.com/nxp/pca9546apw/ic ... dp/2212120

Although my understanding is that these would work the soldering required appears fearsome! At least with the tools we have to hand. Soldering up the sensors housings and pins was incredibly fiddly/tricky - they are tiny.

If you don't do something like that could you/someone please recommend a ready made small board we could attach to the protoplate?

Very many thanks for the assistance so far.

Best wishes,

Julian

techpaul
Posts: 1514
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Enable both I2C Busses

Thu Apr 25, 2013 9:52 am

I dont have ready made solution for that dont know of any others that do for that type of device, but have not looked.

Yes those adapter boards are good for adding a SM device to other circuitry, still have to do the tiny soldering. Soldering requires patience, solder wick (narrow) and usually a cheap magnifier helps. The wick is to remove solder bridges and excess solder, the magnifier to help you see what you are doing and inspection after finishing soldering to check every pin.

The 4 ch switch should suit your needs even if only using 2 channels.
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: Enable both I2C Busses

Thu Apr 25, 2013 3:15 pm

JulianBrooks wrote: Without having done any experimentation my feeling is that it would be much simpler if we had another set of busses running - but if it isn't possible then that's a non-starter.
You could use software (bitbanged) I²C bus provided by i2c-gpio kernel module. Using my module from here you can easily spawn couple busses on any GPIO pins.

JulianBrooks
Posts: 35
Joined: Wed Mar 20, 2013 1:08 pm

Re: Enable both I2C Busses

Fri Apr 26, 2013 12:03 am

Hey Kadamski,

Wow - looks good.
Will investigate further, very useful looking tool.

Thanks for weighing in and sharing,

Julian

TechColab
Posts: 27
Joined: Tue Mar 06, 2012 10:27 am

Re: Enable both I2C Busses

Wed May 01, 2013 2:26 am

I too have successfully got the second I2C working by some very delicate soldering on the base of S5 (not P5) of my Rev.1 Model B.
I have a pair of BMP085 pressure sensors (from Adafruit) with one on each bus and they both work fine without any software/driver/GPIO re-configuration. You just need to specify which bus in the sample python program.
In practical terms, I used about 33cm of very fine wire, soldered to pins 13,14 & 15 of S5 and an earth soldered to the edge of the HDMI connector. I twisted SDA (pin 14) with 3v3 (pin 15) about 7 twists and then SLC (pin 13) with the earth also 7 twists. Then about 1cm of heat shrink sleving and quite a big dollop from a hot glue gun to stick it firmly to the top of the HDMI connector. The new cable shares the same hole in the case as the power plug and terminates in a 3-way header pins (with the 3v3 not connected).

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 4 guests