Are concurrent I2C calls possible?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: Are concurrent I2C calls possible?

Post by aswin0 »

afanofosc wrote:I don't really understand how the time= equation works but it seems to do the right thing in my NXC version. Here it is:
This is a low pass filter that smoothens the average, you can do without if you want.
afanofosc wrote: There's got to be a straightforward explanation why RobotC can make an I2C call (in slow mode) in half the time it takes the standard firmware to do the same thing.
There is a straightforward explanation. RobotC cannot do that. I reported wrong figures here, I deeply sorry and a bit ashamed as well. Here are the correct and double checked figures.

Code: Select all

	  Standard		Fast
S1		7.00	        2.00
S3	  	7.00	        2.00
S1+S3	7.00		2.61
Both		14.00	4.00
I noticed that you apply a wait of 0 msec, where I used a wait of 1 msec. I tested the difference this makes.

Code: Select all

		Standard		Fast			
		wait 1	wait 0	wait 1	wait 0	wait2	abort timeslice
S1+S3	7.00		7.20		2.61		2.76		2.51		2.61

I just can't get these tables aligned
My blog: nxttime.wordpress.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Are concurrent I2C calls possible?

Post by afanofosc »

I tried switching to Wait(0) to see if it made any difference to the results but as far as I could tell it took the same amount of time as Wait(1) did. I forgot I had made that change when I posted the NXC version of your test. Sorry about that!

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: Are concurrent I2C calls possible?

Post by gloomyandy »

Hi,
I created a test program for leJOS and with that I get the following times:

Code: Select all

          Standard        Fast
S1:        5.9             0.7
S3:        5.9             0.7
S1+s3:     5.9             1.4
Both:     11.8             1.4
Which is pretty much as I expected. So with leJOS when operating at standard speed, using two threads allows the operations to overlap and so you get double the number of reads in a fixed period. But when using fast mode there is no benefit to using two threads (because we are cpu limited at that speed), but having said that by using fast mode you will still get over 4 times as many reads in the same period as the fastest way of using standard mode.

Andy

Edited to fix my inability to divide one number by another!
Last edited by gloomyandy on 21 Apr 2011, 22:34, edited 1 time in total.
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: Are concurrent I2C calls possible?

Post by aswin0 »

Andy,

These are impressive figures. Although fast mode is just over 4 times as fast when using two sensors.

Is it hard to write a custom sensor class in lejos? I have no java experience, but I do know object oriented programming.
I saw java has support for matrices, does it know dot product and cross product?
My blog: nxttime.wordpress.com
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: Are concurrent I2C calls possible?

Post by gloomyandy »

Hi,
I've fixed the division error in the post, thanks! Here is the source of the leJOS mindsensors accelerometer driver which should give you a feel for what the code looks like:
http://lejos.svn.sourceforge.net/viewvc ... iew=markup
There are also lower level interfaces if you need them.

Here is the leJOS matrix class. I don't think it currently does dot and cross product (but they may be hiding under another name!):
http://lejos.svn.sourceforge.net/viewvc ... iew=markup

Andy
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: Are concurrent I2C calls possible?

Post by afanofosc »

I am now getting the following results with a new firmware image and the latest NXC test release:

Code: Select all

     Standard   Fast
S1       7.00   1.21
S3       7.00   1.19
S1+S3    7.50   2.44
Both    14.00   2.53
Coming soon, as they say. :D

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests