To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1134
1133  |  1135
Subject: 
Re: NQC, what gives the fastest code ?
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Wed, 9 May 2001 23:03:09 GMT
Viewed: 
2393 times
  
Thanks Dave !!

That was a very good explanation!

In return a problem (and solution) with the serial data transmission (not an NQC error, but you could add it to your documentation).

In doing fast data transfer from RCX to PC, there seems to be a problem in the speed of setting the packet format.
I use NQC to get the code, then I load the code (only task 9) with my own program and start this task 9.
Task 9 sends the samples from a number of sensors (or other sources) to the PC, in chunks of 100 samples per channel, after that I start task 9 again.
Task 9, start with setting serial-packet to SERIAL_PACKET_DEFAULT and then prepares and sends the samples in a while loop.
If I use 2 or more channels, it works perfect, see the example "TASK_NEEDS_NO_WAIT".
But if I'm using just one channel, I get about 10 to 20 data sets with still the famous preamble "55 FF 00".
So it seems that you've to wait a while (with 2 or more channels, the loop lasts longer) before the packet settings becomes active.
The 1-channel example "TASK_NEEDS_WAIT" I added a wait of 30 msec (20 is enough, 10 is too low), and then it works great.

==========================
task needs_no_wait()
{
int x;
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  SetSerialData(0,0xAA);   // preamble
  repeat (100)
  {
    x=SENSOR_1;
    SetSerialData(1,x);
    x=x/256;
    SetSerialData(2,x);
    x=SENSOR_2;
    SetSerialData(1,x);
    x=x/256;
    SetSerialData(2,x);
    SendSerial(0,5);
  }
}
=========================
task needs_wait()
{
int x;
  SetSerialPacket(SERIAL_PACKET_DEFAULT);
  Wait(3);                  // essential to let serial packet work on time
  SetSerialData(0,0xAA);   // preamble
  repeat (100)
  {
    x=SENSOR_1;
    SetSerialData(1,x);
    x=x/256;
    SetSerialData(2,x);
    SendSerial(0,3);
  }
}
==================

Stef Mientki



Message is in Reply To:
  Re: NQC, what gives the fastest code ?
 
It has very little to do with C itself - its really a question of compiler optimization. NQC doesn't have any explicit optimization passes, and there is no data flow or variable lifetime analysis, so often the assembly will be a bit inefficient. (...) (24 years ago, 9-May-01, to lugnet.robotics.rcx.nqc)

3 Messages in This Thread:

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

Custom Search

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