Page 2 of 2

Re: Are concurrent I2C calls possible?

Posted: 21 Apr 2011, 19:41
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

Re: Are concurrent I2C calls possible?

Posted: 21 Apr 2011, 20:36
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

Re: Are concurrent I2C calls possible?

Posted: 21 Apr 2011, 21:52
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!

Re: Are concurrent I2C calls possible?

Posted: 21 Apr 2011, 22:32
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?

Re: Are concurrent I2C calls possible?

Posted: 21 Apr 2011, 22:42
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

Re: Are concurrent I2C calls possible?

Posted: 25 Jul 2011, 20:22
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