To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 21950
21949  |  21951
Subject: 
Re: nop in NQC?
Newsgroups: 
lugnet.robotics
Date: 
Tue, 6 Jan 2004 23:15:19 GMT
Viewed: 
808 times
  
In lugnet.robotics, Brian Davis wrote:
   Is there a NQC command that will translate to a simple nop bytecode?

Here's a program that tries to analyze the various NOP options:

#pragma reserve 0

__nolist void NOP1() { Wait(0); }
__nolist void NOP2() { Wait(-1); }
__nolist void NOP3() { asm { 0x27, 1 }; }
__nolist void NOP4() { asm { 0x10 }; }
__nolist void NOP5() { asm { 0x14, 0, 0, 0, 0 }; }

int j, k, l, m, n, x1, x2;

task main()
{
  CreateDatalog(500);
  repeat (100)
  {
    x1 = FastTimer(0);
    NOP1();
    x2 = FastTimer(0);
    j = x2 - x1;
    AddToDatalog(j);
    x1 = FastTimer(0);
    NOP2();
    x2 = FastTimer(0);
    k = x2 - x1;
    AddToDatalog(k);
    x1 = FastTimer(0);
    NOP3();
    x2 = FastTimer(0);
    l = x2 - x1;
    AddToDatalog(l);
    x1 = FastTimer(0);
    NOP4();
    x2 = FastTimer(0);
    m = x2 - x1;
    AddToDatalog(m);
    x1 = FastTimer(0);
    NOP5();
    x2 = FastTimer(0);
    n = x2 - x1;
    AddToDatalog(n);
    Wait(5);
  }
}

The resulting data shows averages over 100 iterations and 6 test runs as
follows:

NOP1()  NOP2()  NOP3()  NOP4()  NOP5()
0.99    0.48    0.15    0.84    0.81
0.96    0.53    0.11    0.80    0.85
1.00    0.47    0.08    0.81    0.82
0.96    0.55    0.15    0.81    0.85
0.97    0.52    0.14    0.79    0.80
1.00    0.47    0.05    0.79    0.87

Based on this I would go with NOP3().  NOP2() is a decent second choice.

John Hansen



Message has 1 Reply:
  Re: nop in NQC?
 
(...) <snipped> (...) Or you can just forget all that. I ran the same test with the order changed and the 3rd NOP of the 5 I tried was always the fastest (regardless of which one I used). Modifying the program to try each of 5 different options in (...) (21 years ago, 7-Jan-04, to lugnet.robotics)

Message is in Reply To:
  nop in NQC?
 
Is there a NQC command that will translate to a simple nop bytecode? I'm looking for a way to do fine-precision timing, and frankly checking a timer takes too long. For very fine motor control, I'm trying to use sequences like: On(OUT_A+OUT_C); (...) (21 years ago, 5-Jan-04, to lugnet.robotics)

8 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
    

Custom Search

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