Subject:
|
Re: time sampling under the rcx standard OS
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Sat, 17 Sep 2005 08:52:41 GMT
|
Viewed:
|
5911 times
|
| |
| |
In lugnet.robotics.rcx.nqc, Francois Bardet wrote:
> but it seems that the RCX
> loops at very low and unreliable frequency (few Hertz). Please see example at
> the end of this post.
> I heard that BrickOS might allow a more reliable time control, but I'd
> appreciate a solution to keep me using the standard OS and NQC !
>
> - Can the standard RCX OS sample a sensor value at a known and constant rate ?
>
> - Can this rate be higher (at least 50Hz) in order to get a good regulation?
Francois,
I think you should be able to get much faster sampling. I can easily get 10-20
Hz, and others have claimed to get down to 3 ms. Whether it can be done at a
constant rate, I'm not sure, and think it probably depends on what else is in
the loop.
Your loop has Wait() statements, which together account for at least 100
milliseconds I think. Also the LCD display takes time to update.
Try the code below, that just samples the sensor constantly, then upload the
Datalog to your computer and look at it with a spreadsheet program. Note that
the time and data will be interleaved, so you'll need to unpack them somehow.
You may also be able to get higher rates by replacing the Lego firmware with
this:
http://drjsoftware.com/Firmware.htm
Looks promising, and is advertised as being 100% compatible with NQC, but I have
not tried it yet.
Matt
task main()
{
ClearTimer(0); // Set timer #0 to 0 // This timer will be read at 10 ms resolution using FastTimer()
CreateDatalog(1000); // This will hold the data, and you can upload it to your
computer for plotting later.
SetSensor(SENSOR_2,SENSOR_ROTATION);
SetPower(OUT_A,1);
OnFwd(OUT_A);
int actif, passif;
while(true)
{
actif=SENSOR_2;
passif=10-actif;
AddToDatalog( FastTimer(0) ); // this should be much more accurate than the LCD
AddToDatalog( actif );
}
}
|
|
Message has 2 Replies: | | RE: time sampling under the rcx standard OS
|
| Here are some comments on how to improve your code for real-time performance. 1. Move the "SetUserDisplay" out of the loop and put it just before the loop. 2. I think the "OnFwd" macro is actually two instructions: "Fwd" and then "On". Replace this (...) (19 years ago, 17-Sep-05, to lugnet.robotics.rcx.nqc)
| | | Re: time sampling under the rcx standard OS
|
| Thank you Matt, the RCX loops much faster with your advices : about 10 loops per second. But as this frequency depends on the calculations included in the loop, Im afraid this will not be enough. So I tried to download (URL) but it just appears as (...) (19 years ago, 18-Sep-05, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | time sampling under the rcx standard OS
|
| Hi list, I'm trying to implement a position regulation (using a motor and a rotation sensor), using for instance a PID (Proportional-Integr...erivative) regulation. I tried to code it in NQC, using the standard OS, but it seems that the RCX loops at (...) (19 years ago, 17-Sep-05, to lugnet.robotics.rcx.nqc)
|
10 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
|
|
|
|