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.
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!
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.
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?
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.