NXT-G, NXC, I2C..What to use to make fastest operations?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by peter-cocteau »

It's white and black but it looks orange cause of light. Well it's only lego bricks, nothing much. Inside there is two old style rotation sensors and the 6,35mm jack output.
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by aswin0 »

You schold check out this post for actual performance figures for I2C operations. Make sure to read the whole post as Improvements were made to NXC during the active life of this thread. Basicly RobotC, NXC and robotC are about 10 times faster than NXT-G.

I think the question is whether to invest in learning one of the above languages. In the end the investment will pay off for a project like this. Lejos will be hardest to learn but offers a nice collection of sound related functions. RobotC and NXC have equal learning curves but the support for NXC is better.

It took me about one month to get to grips with robotC and three month to get used to Lejos. But I had used text based programming languages before.
My blog: nxttime.wordpress.com
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by afanofosc »

I'm not sure, but the OP's problems with the SuperPro NXT-G block may be simply caused by timing the block without actually having the device attached to his NXT - at least it sounds like that is what he did. If it is trying to talk to a device at a different I2C address than the device he had attached uses the block might retry or something like that.

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by afanofosc »

Actually, I am now not certain what sensor the OP means when he refers to the LEGO Proximity sensor. Can we get some clarification? Does he mean the Ultrasonic Sensor?

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
peter-cocteau
Posts: 26
Joined: 04 Dec 2011, 12:12

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by peter-cocteau »

I've received the Hitecnics board today, I will soon test it.

Yes John, I talk about Utrasonic sensor.

Peter.
gusjansson
Posts: 18
Joined: 28 Sep 2010, 23:57

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by gusjansson »

My questions:
-I always use NXT-G, it is friendly to me. I like to think about programing without knowledge of how to use NXC, java, basic, etc... In fact those things are chinese for me.
BUT do my program would operate faster by using another thing than NXT-G ?? Which programming language is the fastest ??

-It seems I2C communication between Hitechnic SuperPro board and NXT is quite slow by using NXT-G. I have not test with card but it seems SuperPro NXT-G block takes 45ms when LEGO Proximity sensor block(another I2C device) takes only 6ms to operate.
Which laguage is the best to reduce I2C operation time?
I don't believe the NXT-G block for the SuperPro is any slower than NXC or other language. The only operation on with the NXT-G block that is potentially less efficient is the control of the analog outputs because with this action the block sends 5 bytes of data to the SuperPro, regardless if all 5 bytes need to be sent. This is one byte for mode, two for frequency and two for voltage. So, for example, If you are only changing the frequency then you only need to send two bytes. This would actually save very little.

I did some testing on the SuperPro NXT-G block and is actually faster than I expected. I tested 100 operations, subtracted a constant for the loop overhead, and then divided that by 100. Here are the results for the different actions on the SuperPro:

Code: Select all

Read analog port:      9.13ms
Read Digital port:     8.13ms
Output Digital port:   6.13ms
Write Digital Control: 6.16ms
Write Strobe:          6.13ms
Write LED:             6.15ms
Read analog:          11.12ms
Not surprising, the Read analog was the slowest but still pretty fast in my opinion. All the other output commands are fast because they only write and don't have to read anything back from the board. Read digital is a little slower because it has to read one byte back from the SuperPro and Read analog is slower yet because it reads two bytes.

Gus
- HiTechnic
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by aswin0 »

afanofosc wrote:Actually, I am now not certain what sensor the OP means when he refers to the LEGO Proximity sensor. Can we get some clarification? Does he mean the Ultrasonic Sensor?

John Hansen
The US sensor isn't A good sensor to test I2C speed. Physical (speed of sound) and technical ( it doesn't support high speed I2C) make this sensor slower than other digital sensors.

Gus, what language did you use to produce the results? And what I2C settings?
My blog: nxttime.wordpress.com
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by aswin0 »

afanofosc wrote:Actually, I am now not certain what sensor the OP means when he refers to the LEGO Proximity sensor. Can we get some clarification? Does he mean the Ultrasonic Sensor?

John Hansen
The US sensor isn't A good sensor to test I2C speed. Physical (speed of sound) and technical ( it doesn't support high speed I2C) make this sensor slower than other digital sensors.

Gus, what language did you use to produce the results? And what I2C settings?
My blog: nxttime.wordpress.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by HaWe »

another issue of the USS is that is has fixed internal repetitive US sending/reading/calculating loops of constant intervals which start in the moment the sensor once has been configured (unless you configure the sensor for single shot mode).
IIRC, if you try to read it faster than the internal loops you are supposed to read an internal buffer value, not a relevant distance reading.
That means, taking a sensor value will not cause the sensor to send an US beam, wait for response, calculate the digital sensor value and send it back via i2c.
So IMO, if you just try to check experimentally if the sensor might response to faster i2c read cmds or not it should work (although it wouldn't make any sense anyway).
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: NXT-G, NXC, I2C..What to use to make fastest operations?

Post by afanofosc »

Gus ran his tests, I am sure, using the standard LEGO I2C speed with a program written in NXT-G.
I did some testing on the SuperPro NXT-G block and is actually faster than I expected.
I think that suggests the OP was getting bad results due to not having the actual SuperPro device connected to his NXT.

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

Who is online

Users browsing this forum: No registered users and 9 guests