To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.nxtOpen lugnet.robotics.nxt in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / NXT / 909
908  |  910
Subject: 
Re: Ooops! NXT Software Comparison correction
Newsgroups: 
lugnet.robotics.nxt
Date: 
Sun, 2 Sep 2007 20:46:31 GMT
Viewed: 
22290 times
  
In lugnet.robotics.nxt, John Hansen wrote:
Nearly all of the speed test numbers on Steve's page are wrong.  That's because
Steve's loop boils down to "how fast can you reliably read the LEGO Ultrasonic
Sensor".  You can't reliably read a value from that device faster than about
once every 15 milliseconds at the very fastest. If you try to read from it
faster than that then you will get back bad data.


So if I cheat I can move the I2C transaction out of the actual timing loop
(which may be what some other folks are doing, effectively) then with a "read"
of the Ultrasonic sensor value in the loop and all sensors and motors attached I
get

9,422 with LCD drawing
17,707 without LCD drawing

Again, that's by cheating.  A separate task actually reads the Ultrasonic sensor
value and stores it in a global variable which is what I read inside the timing
loop.  To report these numbers as the results of Steve's timing test would be
dishonest since that is not what the pseudo code requires.

By the way, I looked at Steve's pseudo code for the first time in many months
last night and wrote a program in NXC that implemented it without any IDE aids
or any documentation in ~9 minutes. After I wrote it I compared it with the one
on Steve's page (written by Philo) and it was nearly identical.

A simple NBC program took ~12 minutes to write. In cheating mode I get

16,287 with LCD drawing
36,841 without LCD drawing


Here's the 12 minute NBC code:

dseg segment
   gUSSensorValue sword
dseg ends

thread USSensorTask
USLoop:
  ReadSensorUS(IN_4, gUSSensorValue)
  jmp USLoop
endt

thread TimingLoopTask
dseg segment
   limit sdword
   cur sdword
   rs sword
   ls sword
   us sword
   sum sword
   rnd sword
   A sword
   LoopCount sdword
dseg ends
set A, 0
set LoopCount, 0

gettick limit
add limit, limit, 60000
Loop:
mov ls, InputIOScaledValue(IN_3)
// ReadSensorUS(IN_4, gUSSensorValue)
mov us, gUSSensorValue
mov rs, OutputIORotationCount(OUT_B)
// NumOut(10, LCD_LINE1, rs)
Random(rnd, 100)
add rnd, rnd, 1
add sum, ls, us
add sum, sum, rs
mul sum, sum, 100
div sum, sum, rnd
// NumOut(10, LCD_LINE2, sum)
OnFwd(OUT_BC, rnd)

brcmp GTEQ, CheckSub, rnd, 50
add A, A, 1
CheckSub:
brcmp EQ, NoChange, rnd, 50
sub A, A, 1
NoChange:
// NumOut (10, LCD_LINE3, A)
OnFwd (OUT_A, A)
// NumOut (10, LCD_LINE4, LoopCount)
add LoopCount, LoopCount, 1

gettick cur
brcmp LT, Loop, cur, limit

NumOut (10, LCD_LINE4, LoopCount)
Off(OUT_ABC)
wait 10000
stop TRUE
endt

thread main
SetSensorLight(IN_3)
SetSensorLowspeed(IN_4)
ClearScreen()
precedes USSensorTask, TimingLoopTask
exit
endt

To switch it back into non-cheating mode just replace the commented out call to
ReadSensorUS in TimingLoopTask and remove the referene to USSensorTask in the
precedes statement near the end of main.

John Hansen



Message has 1 Reply:
  Re: Ooops! NXT Software Comparison correction
 
I can further manipulate the numbers for this timing test by using the enhanced standard firmware's support for adjusting a thread's priority. Here's the results when I tweak priorities: W/O LCD LCD Priorities ---...--- 50617 22608 40/5 63211 27375 (...) (17 years ago, 2-Sep-07, to lugnet.robotics.nxt)

Message is in Reply To:
  Re: Ooops! NXT Software Comparison correction
 
(...) Nearly all of the speed test numbers on Steve's page are wrong. That's because Steve's loop boils down to "how fast can you reliably read the LEGO Ultrasonic Sensor". You can't reliably read a value from that device faster than about once (...) (17 years ago, 2-Sep-07, to lugnet.robotics.nxt)

13 Messages in This Thread:





Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in NXT programmable brick

 
Verified and Trusted Team of Hackers
13 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR